blob: ccf016e9edb20f1150dcd19097ea1d6e78226654 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_NET_CRW_SSL_STATUS_UPDATER_H_
#define IOS_WEB_NET_CRW_SSL_STATUS_UPDATER_H_
#import <Foundation/Foundation.h>
#import <Security/Security.h>
#include "base/mac/scoped_cftyperef.h"
#include "ios/web/public/security_style.h"
#include "net/cert/cert_status_flags.h"
namespace web {
class NavigationItem;
class NavigationManager;
}
@protocol CRWSSLStatusUpdaterDataSource;
@protocol CRWSSLStatusUpdaterDelegate;
// Updates SSL Status for web::NavigationItem.
@interface CRWSSLStatusUpdater : NSObject
// Delegate for CRWSSLStatusUpdater. Can be nil.
@property(nonatomic, weak) id<CRWSSLStatusUpdaterDelegate> delegate;
// Initializes CRWSSLStatusUpdater. |navManager| can not be null, will be stored
// as a weak pointer and must outlive updater. |dataSource| can not be nil, will
// be stored as a weak reference and must outlive updater.
- (instancetype)initWithDataSource:(id<CRWSSLStatusUpdaterDataSource>)dataSource
navigationManager:(web::NavigationManager*)navigationManager
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
// Updates SSL status for the current navigation item. The SSL Status is
// obtained from |host|, |chain| and |hasOnlySecureContent| flag.
- (void)updateSSLStatusForNavigationItem:(web::NavigationItem*)navigationItem
withCertHost:(NSString*)host
trust:
(base::ScopedCFTypeRef<SecTrustRef>)trust
hasOnlySecureContent:(BOOL)hasOnlySecureContent;
@end
// |SSLStatusUpdater:querySSLStatusForTrust:host:completionHandler| completion
// handler.
typedef void (^StatusQueryHandler)(web::SecurityStyle, net::CertStatus);
// DataSource for CRWSSLStatusUpdater.
@protocol CRWSSLStatusUpdaterDataSource
@required
// Called when updater needs SSLStatus for the given |certChain| and |host|.
// |completionHandler| is called asynchronously when web::SecurityStyle and
// net::CertStatus are computed.
- (void)SSLStatusUpdater:(CRWSSLStatusUpdater*)SSLStatusUpdater
querySSLStatusForTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust
host:(NSString*)host
completionHandler:(StatusQueryHandler)completionHandler;
@end
// Delegate for CRWSSLStatusUpdater.
@protocol CRWSSLStatusUpdaterDelegate<NSObject>
@optional
// Called if SSLStatus has been changed for the given navigation item. May be
// called multiple times for a single update or not called at all if SSLStatus
// has not been changed for the requested navigation item.
- (void)SSLStatusUpdater:(CRWSSLStatusUpdater*)SSLStatusUpdater
didChangeSSLStatusForNavigationItem:(web::NavigationItem*)navigationItem;
@end
#endif // IOS_WEB_NET_CRW_SSL_STATUS_UPDATER_H_