Commit e652ec40 authored by Hiroshi Ichikawa's avatar Hiroshi Ichikawa Committed by Commit Bot

Add -[CWVWebView visibleSSLStatus].

Bug: 786891
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I7b51609b0b4382d28e34ec63ac5d81d60eb84b2d
Reviewed-on: https://chromium-review.googlesource.com/c/1293057Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Hiroshi Ichikawa <ichikawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602242}
parent c1710b54
......@@ -17,6 +17,7 @@
#include "google_apis/google_api_keys.h"
#include "ios/web/public/favicon_url.h"
#include "ios/web/public/load_committed_details.h"
#import "ios/web/public/navigation_item.h"
#import "ios/web/public/navigation_manager.h"
#include "ios/web/public/referrer.h"
#include "ios/web/public/reload_type.h"
......@@ -36,6 +37,7 @@
#import "ios/web_view/internal/cwv_navigation_action_internal.h"
#import "ios/web_view/internal/cwv_script_command_internal.h"
#import "ios/web_view/internal/cwv_scroll_view_internal.h"
#import "ios/web_view/internal/cwv_ssl_status_internal.h"
#import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
#import "ios/web_view/internal/translate/cwv_translation_controller_internal.h"
#import "ios/web_view/internal/translate/web_view_translate_client.h"
......@@ -113,6 +115,7 @@ class WebViewHolder : public web::WebStateUserData<WebViewHolder> {
@property(nonatomic, readwrite) BOOL loading;
@property(nonatomic, readwrite, copy) NSString* title;
@property(nonatomic, readwrite) NSURL* visibleURL;
@property(nonatomic, readwrite) CWVSSLStatus* visibleSSLStatus;
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
@property(nonatomic, readonly) CWVAutofillController* autofillController;
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
......@@ -154,6 +157,7 @@ static NSString* gUserAgentProduct = nil;
@synthesize UIDelegate = _UIDelegate;
@synthesize scrollView = _scrollView;
@synthesize visibleURL = _visibleURL;
@synthesize visibleSSLStatus = _visibleSSLStatus;
+ (void)initialize {
if (self != [CWVWebView class]) {
......@@ -321,6 +325,9 @@ static NSString* gUserAgentProduct = nil;
[self updateNavigationAvailability];
[self updateCurrentURLs];
// TODO(crbug.com/898357): Remove this once crbug.com/898357 is fixed.
[self updateVisibleSSLStatus];
NSError* error = navigation->GetError();
SEL selector = @selector(webView:didFailNavigationWithError:);
if (error && [_navigationDelegate respondsToSelector:selector]) {
......@@ -357,6 +364,10 @@ static NSString* gUserAgentProduct = nil;
[self updateTitle];
}
- (void)webStateDidChangeVisibleSecurityState:(web::WebState*)webState {
[self updateVisibleSSLStatus];
}
- (void)renderProcessGoneForWebState:(web::WebState*)webState {
SEL selector = @selector(webViewWebContentProcessDidTerminate:);
if ([_navigationDelegate respondsToSelector:selector]) {
......@@ -650,6 +661,7 @@ static NSString* gUserAgentProduct = nil;
[self updateNavigationAvailability];
[self updateCurrentURLs];
[self updateTitle];
[self updateVisibleSSLStatus];
self.loading = NO;
self.estimatedProgress = 0.0;
}
......@@ -681,6 +693,17 @@ static NSString* gUserAgentProduct = nil;
self.title = base::SysUTF16ToNSString(_webState->GetTitle());
}
- (void)updateVisibleSSLStatus {
web::NavigationItem* visibleItem =
_webState->GetNavigationManager()->GetVisibleItem();
if (visibleItem) {
self.visibleSSLStatus =
[[CWVSSLStatus alloc] initWithInternalStatus:visibleItem->GetSSL()];
} else {
self.visibleSSLStatus = nil;
}
}
#pragma mark - Internal Methods
- (void)shutDown {
......
......@@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol CWVNavigationDelegate;
@protocol CWVScriptCommandHandler;
@protocol CWVUIDelegate;
@class CWVSSLStatus;
// A web view component (like WKWebView) which uses iOS Chromium's web view
// implementation.
......@@ -75,6 +76,10 @@ CWV_EXPORT
// and |lastCommittedURL|.
@property(nonatomic, readonly) NSURL* lastCommittedURL;
// The SSL status displayed in the URL bar. KVO compliant.
// It is nil when no page is loaded on the web view.
@property(nonatomic, readonly, nullable) CWVSSLStatus* visibleSSLStatus;
// The current page title. KVO compliant.
@property(nonatomic, readonly, copy) NSString* title;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment