| // 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> |
| |
| #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. |certGroupID| will be |
| // used for accessing web::CertStore. |
| - (instancetype)initWithDataSource:(id<CRWSSLStatusUpdaterDataSource>)dataSource |
| navigationManager:(web::NavigationManager*)navigationManager |
| certGroupID:(int)certGroupID 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 |
| certChain:(NSArray*)chain |
| 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 |
| querySSLStatusForCertChain:(NSArray*)certChain |
| 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_ |