Commit de8b8209 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Move the NativeContent code out of WebController

This CL moves the NativeCode part of WebController out to
LegacyNativeContentController.
This object exposes an API to interact with the NativeContent. Its
delegate (the WebController) contains the rest of the methods to allow
interactions with the rest of content.

It also moves the ownership of the NativeContent from
WebControllerContainerView to the LegacyNativeContentController.
The WebControllerContainerView can access the NativeContent through
its delegate.

Bug: 956523
Change-Id: Ie92be0afc95c5e77499bb7d62d3dab15c962a3b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1587891Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661722}
parent bde87c12
......@@ -30,6 +30,7 @@
#import "ios/web/public/navigation_item.h"
#import "ios/web/public/navigation_manager.h"
#import "ios/web/public/web_state/ui/crw_native_content.h"
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
#import "ios/web/public/web_state/web_state.h"
#include "ios/web/public/web_state/web_state_observer_bridge.h"
#import "ios/web/public/web_state/web_state_policy_decider_bridge.h"
......@@ -277,7 +278,7 @@ bool IsPrerenderTabEvictionExperimentalGroup() {
DCHECK(![self isWebStatePrerendered:webState.get()]);
Tab* tab = LegacyTabHelper::GetTabForWebState(webState.get());
[[tab webController] setNativeProvider:nil];
[tab.webController nativeContentHolder].nativeProvider = nil;
webState->RemoveObserver(webStateObserver_.get());
breakpad::StopMonitoringURLsForWebState(webState.get());
......@@ -403,7 +404,7 @@ bool IsPrerenderTabEvictionExperimentalGroup() {
Tab* tab = LegacyTabHelper::GetTabForWebState(webState_.get());
DCHECK(tab);
[[tab webController] setNativeProvider:self];
[tab.webController nativeContentHolder].nativeProvider = nil;
webState_->SetDelegate(webStateDelegate_.get());
webState_->AddObserver(webStateObserver_.get());
......@@ -448,7 +449,7 @@ bool IsPrerenderTabEvictionExperimentalGroup() {
PRERENDER_FINAL_STATUS_MAX);
Tab* tab = LegacyTabHelper::GetTabForWebState(webState_.get());
[[tab webController] setNativeProvider:nil];
[tab.webController nativeContentHolder].nativeProvider = nil;
webState_->RemoveObserver(webStateObserver_.get());
breakpad::StopMonitoringURLsForWebState(webState_.get());
webState_->SetDelegate(nullptr);
......
......@@ -210,6 +210,7 @@
#import "ios/web/public/web_state/context_menu_params.h"
#import "ios/web/public/web_state/js/crw_js_injection_receiver.h"
#import "ios/web/public/web_state/navigation_context.h"
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
#import "ios/web/public/web_state/ui/crw_native_content_provider.h"
#import "ios/web/public/web_state/ui/crw_web_view_proxy.h"
#import "ios/web/public/web_state/ui/crw_web_view_scroll_view_proxy.h"
......@@ -2741,7 +2742,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
Tab* tab = LegacyTabHelper::GetTabForWebState(webState);
// Install the proper CRWWebController delegates.
tab.webController.nativeProvider = self;
[tab.webController nativeContentHolder].nativeProvider = self;
tab.webController.swipeRecognizerProvider = self.sideSwipeController;
tab.webState->SetDelegate(_webStateDelegate.get());
SadTabTabHelper::FromWebState(webState)->SetDelegate(_sadTabCoordinator);
......@@ -2795,7 +2796,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// TODO(crbug.com/960950): Remove this once webController is moved out of tab.
Tab* tab = LegacyTabHelper::GetTabForWebState(webState);
tab.webController.nativeProvider = nil;
[tab.webController nativeContentHolder].nativeProvider = nil;
tab.webController.swipeRecognizerProvider = nil;
webState->SetDelegate(nullptr);
if (AccountConsistencyService* accountConsistencyService =
......@@ -2834,7 +2835,8 @@ NSString* const kBrowserViewControllerSnackbarCategory =
}
- (id)nativeControllerForTab:(Tab*)tab {
id nativeController = tab.webController.nativeController;
id nativeController =
[tab.webController nativeContentHolder].nativeController;
return nativeController ? nativeController : _temporaryNativeController;
}
......@@ -3649,7 +3651,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
Tab* currentTab = self.tabModel.currentTab;
if (!self.currentWebState ||
self.currentWebState->GetLastCommittedURL() != url ||
[currentTab.webController.nativeController
[[currentTab.webController nativeContentHolder].nativeController
isKindOfClass:[nativeController class]]) {
_temporaryNativeController = nativeController;
}
......
......@@ -77,7 +77,7 @@
[super close];
}
- (GURL)virtualURL {
- (const GURL&)virtualURL {
return _virtualURL;
}
......
......@@ -66,6 +66,7 @@ source_set("public") {
"web_state/session_certificate_policy_cache.h",
"web_state/ui/crw_context_menu_delegate.h",
"web_state/ui/crw_native_content.h",
"web_state/ui/crw_native_content_holder.h",
"web_state/ui/crw_native_content_provider.h",
"web_state/ui/crw_web_view_proxy.h",
"web_state/ui/crw_web_view_scroll_view_proxy.h",
......
......@@ -38,7 +38,7 @@
return _URL;
}
- (GURL)virtualURL {
- (const GURL&)virtualURL {
return _virtualURL;
}
......
......@@ -4,6 +4,7 @@
#import "ios/web/public/test/native_controller_test_util.h"
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
#import "ios/web/web_state/web_state_impl.h"
......@@ -17,7 +18,8 @@ namespace test {
id<CRWNativeContent> GetCurrentNativeController(WebState* web_state) {
web::WebStateImpl* web_state_impl =
static_cast<web::WebStateImpl*>(web_state);
return [web_state_impl->GetWebController() nativeController];
return [[web_state_impl->GetWebController() nativeContentHolder]
nativeController];
}
} // namespace test
......
......@@ -77,7 +77,7 @@ struct ContextMenuParams;
// The URL that will be displayed to the user when presenting this native
// content.
- (GURL)virtualURL;
- (const GURL&)virtualURL;
// The content inset and offset of this native view.
- (CGPoint)contentOffset;
......
// Copyright 2019 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_PUBLIC_WEB_STATE_UI_CRW_NATIVE_CONTENT_HOLDER_H_
#define IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_NATIVE_CONTENT_HOLDER_H_
#import <Foundation/Foundation.h>
@protocol CRWNativeContent;
@protocol CRWNativeContentProvider;
// Protocol describing an object having ownership of a native controller.
@protocol CRWNativeContentHolder
// The provider for the native content.
@property(nonatomic, weak) id<CRWNativeContentProvider> nativeProvider;
// The native controller owned by this object.
- (id<CRWNativeContent>)nativeController;
@end
#endif // IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_NATIVE_CONTENT_HOLDER_H_
......@@ -36,6 +36,7 @@ source_set("ui") {
"//ios/web/web_state:web_view_internal_creation_util",
"//ios/web/web_state/js",
"//ios/web/web_state/ui:wk_web_view_configuration_provider",
"//ios/web/web_state/ui/controller",
"//ios/web/web_view",
"//ios/web/webui:webui",
"//services/metrics/public/cpp:ukm_builders",
......
# Copyright 2019 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.
source_set("controller") {
sources = [
"crw_legacy_native_content_controller.h",
"crw_legacy_native_content_controller.mm",
"crw_legacy_native_content_controller_delegate.h",
]
deps = [
"//ios/web/navigation:core",
"//ios/web/net",
"//ios/web/public",
"//ios/web/web_state:web_state_impl_header",
"//ui/base",
"//url",
]
libs = [ "WebKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
// Copyright 2019 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_WEB_STATE_UI_CONTROLLER_CRW_LEGACY_NATIVE_CONTENT_CONTROLLER_H_
#define IOS_WEB_WEB_STATE_UI_CONTROLLER_CRW_LEGACY_NATIVE_CONTENT_CONTROLLER_H_
#include <UIKit/UIKit.h>
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
namespace web {
class NavigationContextImpl;
class NavigationItemImpl;
class WebStateImpl;
}
@protocol CRWLegacyNativeContentControllerDelegate;
@protocol CRWNativeContent;
class GURL;
// Object managing the native content controller and its interactions with other
// objects.
@interface CRWLegacyNativeContentController : NSObject <CRWNativeContentHolder>
- (instancetype)initWithWebState:(web::WebStateImpl*)webState
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
@property(nonatomic, weak) id<CRWLegacyNativeContentControllerDelegate>
delegate;
// Return YES if there is a native content controller currently initialized.
- (BOOL)hasController;
// Returns |YES| if |URL| should be loaded in a native view.
- (BOOL)shouldLoadURLInNativeView:(const GURL&)URL;
// Informs the native controller if web usage is allowed or not.
- (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled;
// Loads the current URL in a native controller if using the legacy navigation
// stack. If the new navigation stack is used, start loading a placeholder
// into the web view, upon the completion of which the native controller will
// be triggered.
- (void)loadCurrentURLInNativeViewWithRendererInitiatedNavigation:
(BOOL)rendererInitiated;
// Notifies the native content that the navigation associated with |context| and
// |item| did finish.
- (void)webViewDidFinishNavigationWithContext:
(web::NavigationContextImpl*)context
andItem:(web::NavigationItemImpl*)item;
// Lets the native content handle its part when there is a cancellation error.
- (void)handleCancelledErrorForContext:(web::NavigationContextImpl*)context;
// Lets the native content handle its part when there is an SSL error.
- (void)handleSSLError;
// Stops the loading of the Native Content.
- (void)stopLoading;
// Removes the current native controller.
- (void)resetNativeController;
// *****************************************
// ** Calls related to the NativeContent. **
// *****************************************
// Notifies the CRWNativeContent that it has been shown.
- (void)wasShown;
// Notifies the CRWNativeContent that it has been hidden.
- (void)wasHidden;
// Dismisses any outstanding modal interaction elements (e.g. modal view
// controllers, context menus, etc).
- (void)dismissModals;
// A native content controller should do any clean up at this time when
// WebController closes.
- (void)close;
// The URL represented by the content being displayed.
- (const GURL&)URL;
// Reloads any displayed data to ensure the view is up to date.
- (void)reload;
// The content inset and offset of the native content.
- (CGPoint)contentOffset;
- (UIEdgeInsets)contentInset;
@end
#endif // IOS_WEB_WEB_STATE_UI_CONTROLLER_CRW_LEGACY_NATIVE_CONTENT_CONTROLLER_H_
// Copyright 2019 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_WEB_STATE_UI_CONTROLLER_CRW_LEGACY_NATIVE_CONTENT_CONTROLLER_DELEGATE_H_
#define IOS_WEB_WEB_STATE_UI_CONTROLLER_CRW_LEGACY_NATIVE_CONTENT_CONTROLLER_DELEGATE_H_
#include "ios/web/public/referrer.h"
#include "ui/base/page_transition_types.h"
namespace web {
class NavigationContextImpl;
}
@protocol CRWNativeContent;
@class CRWLegacyNativeContentController;
class GURL;
// Delegate for the CRWLegacyNativeContentController.
@protocol CRWLegacyNativeContentControllerDelegate
// Whether the web usage is enabled.
- (BOOL)legacyNativeContentControllerWebUsageEnabled:
(CRWLegacyNativeContentController*)contentController;
// Whether the delegate is being destroyed.
- (BOOL)legacyNativeContentControllerIsBeingDestroyed:
(CRWLegacyNativeContentController*)contentController;
// Asks the delegate to remove the web view.
- (void)legacyNativeContentControllerRemoveWebView:
(CRWLegacyNativeContentController*)contentController;
// Called when a page (native or web) has actually started loading (i.e., for
// a web page the document has actually changed), or after the load request has
// been registered for a non-document-changing URL change. Updates internal
// state not specific to web pages.
- (void)legacyNativeContentControllerDidStartLoading:
(CRWLegacyNativeContentController*)contentController;
// Loads a blank page directly into WKWebView as a placeholder for a Native View
// or WebUI URL. This page has the URL about:blank?for=<encoded original URL>.
// If |originalContext| is provided, reuse it for the placeholder navigation
// instead of creating a new one. See "Handling App-specific URLs"
// section of go/bling-navigation-experiment for details.
- (web::NavigationContextImpl*)
legacyNativeContentController:
(CRWLegacyNativeContentController*)contentController
loadPlaceholderInWebViewForURL:(const GURL&)originalURL
rendererInitiated:(BOOL)rendererInitiated
forContext:(std::unique_ptr<web::NavigationContextImpl>)
originalContext;
// Prepares web controller and delegates for anticipated page change.
// Allows several methods to invoke webWill/DidAddPendingURL on anticipated page
// change, using the same cached request and calculated transition types.
// Returns navigation context for this request.
- (std::unique_ptr<web::NavigationContextImpl>)
legacyNativeContentController:
(CRWLegacyNativeContentController*)contentController
registerLoadRequestForURL:(const GURL&)requestURL
referrer:(const web::Referrer&)referrer
transition:(ui::PageTransition)transition
sameDocumentNavigation:(BOOL)sameDocumentNavigation
hasUserGesture:(BOOL)hasUserGesture
rendererInitiated:(BOOL)rendererInitiated
placeholderNavigation:(BOOL)placeholderNavigation;
// Set the title of the native content.
- (void)legacyNativeContentController:
(CRWLegacyNativeContentController*)contentController
setNativeContentTitle:(NSString*)title;
// Notifies the delegate that the native content did change.
- (void)legacyNativeContentController:
(CRWLegacyNativeContentController*)contentController
nativeContentDidChange:
(id<CRWNativeContent>)previousNativeController;
// Notifies the delegate that the native controller finished loading the URL.
- (void)legacyNativeContentController:
(CRWLegacyNativeContentController*)contentController
nativeContentLoadDidFinishWithURL:(const GURL&)targetURL
context:(web::NavigationContextImpl*)context;
@end
#endif // IOS_WEB_WEB_STATE_UI_CONTROLLER_CRW_LEGACY_NATIVE_CONTENT_CONTROLLER_DELEGATE_H_
......@@ -21,8 +21,7 @@ enum class WKNavigationState;
} // namespace web
@class CRWJSInjector;
@protocol CRWNativeContent;
@protocol CRWNativeContentProvider;
@protocol CRWNativeContentHolder;
@protocol CRWSwipeRecognizerProvider;
@class CRWWebViewContentView;
@protocol CRWWebViewProxy;
......@@ -47,7 +46,6 @@ class WebStateImpl;
// Defaults to NO; this should be enabled before attempting to access the view.
@property(nonatomic, assign) BOOL webUsageEnabled;
@property(nonatomic, weak) id<CRWNativeContentProvider> nativeProvider;
@property(nonatomic, weak) id<CRWSwipeRecognizerProvider>
swipeRecognizerProvider;
......@@ -176,8 +174,9 @@ class WebStateImpl;
// Notifies the CRWWebController that it has been hidden.
- (void)wasHidden;
// Returns the native controller (if any) current mananging the content.
- (id<CRWNativeContent>)nativeController;
// Returns the object holding the native controller (if any) currently managing
// the content.
- (id<CRWNativeContentHolder>)nativeContentHolder;
// Called when NavigationManager has completed go to index same-document
// navigation. Updates HTML5 history state, current document URL and sends
......
This diff is collapsed.
......@@ -9,10 +9,11 @@
#import "ios/web/common/crw_content_view.h"
@protocol CRWNativeContent;
@protocol CRWNativeContentHolder;
@class CRWWebControllerContainerView;
@class CRWWebViewContentView;
@class CRWWebViewProxyImpl;
@protocol CRWNativeContent;
@protocol CRWWebControllerContainerViewDelegate<NSObject>
......@@ -30,11 +31,19 @@
- (BOOL)shouldKeepRenderProcessAliveForContainerView:
(CRWWebControllerContainerView*)containerView;
// Instructs the delegate to add the |viewToStash| to the view hieararchy to
// Instructs the delegate to add the |viewToStash| to the view hierarchy to
// keep the render process alive.
- (void)containerView:(CRWWebControllerContainerView*)containerView
storeWebViewInWindow:(UIView*)viewToStash;
// Resets the native controller.
- (void)containerViewResetNativeController:
(CRWWebControllerContainerView*)containerView;
// Returns the native content holder.
- (id<CRWNativeContentHolder>)containerViewNativeContentHolder:
(CRWWebControllerContainerView*)containerView;
@end
// Container view class that manages the display of content within
......@@ -45,8 +54,6 @@
// The web view content view being displayed.
@property(nonatomic, strong, readonly)
CRWWebViewContentView* webViewContentView;
// The native controller whose content is being displayed.
@property(nonatomic, strong, readonly) id<CRWNativeContent> nativeController;
// The currently displayed transient content view.
@property(nonatomic, strong, readonly) CRWContentView* transientContentView;
@property(nonatomic, weak) id<CRWWebControllerContainerViewDelegate>
......@@ -77,8 +84,8 @@
// Replaces the currently displayed content with |webViewContentView|.
- (void)displayWebViewContentView:(CRWWebViewContentView*)webViewContentView;
// Replaces the currently displayed content with |nativeController|'s view.
- (void)displayNativeContent:(id<CRWNativeContent>)nativeController;
// Notifies the container that the native content changed
- (void)nativeContentDidChange:(id<CRWNativeContent>)previousNativeController;
// Adds |transientContentView| as a subview above previously displayed content.
- (void)displayTransientContent:(CRWContentView*)transientContentView;
......
......@@ -9,6 +9,7 @@
#import "ios/web/common/crw_web_view_content_view.h"
#include "ios/web/common/features.h"
#import "ios/web/public/web_state/ui/crw_native_content.h"
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
#import "ios/web/web_state/ui/crw_web_view_proxy_impl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -20,17 +21,18 @@
// Redefine properties as readwrite.
@property(nonatomic, strong, readwrite)
CRWWebViewContentView* webViewContentView;
@property(nonatomic, strong, readwrite) id<CRWNativeContent> nativeController;
@property(nonatomic, strong, readwrite) CRWContentView* transientContentView;
// Convenience getter for the proxy object.
@property(nonatomic, weak, readonly) CRWWebViewProxyImpl* contentViewProxy;
// The native controller whose content is being displayed.
@property(nonatomic, strong, readonly) id<CRWNativeContent> nativeController;
@end
@implementation CRWWebControllerContainerView
@synthesize webViewContentView = _webViewContentView;
@synthesize nativeController = _nativeController;
@synthesize transientContentView = _transientContentView;
@synthesize delegate = _delegate;
......@@ -63,6 +65,11 @@
#pragma mark Accessors
- (id<CRWNativeContent>)nativeController {
return
[[self.delegate containerViewNativeContentHolder:self] nativeController];
}
- (void)setWebViewContentView:(CRWWebViewContentView*)webViewContentView {
if (![_webViewContentView isEqual:webViewContentView]) {
[_webViewContentView removeFromSuperview];
......@@ -72,20 +79,6 @@
}
}
- (void)setNativeController:(id<CRWNativeContent>)nativeController {
if (![_nativeController isEqual:nativeController]) {
__weak id oldController = _nativeController;
if ([oldController respondsToSelector:@selector(willBeDismissed)]) {
[oldController willBeDismissed];
}
[[oldController view] removeFromSuperview];
_nativeController = nativeController;
// TODO(crbug.com/503297): Re-enable this DCHECK once native controller
// leaks are fixed.
// DCHECK(!oldController);
}
}
- (void)setTransientContentView:(CRWContentView*)transientContentView {
if (![_transientContentView isEqual:transientContentView]) {
[_transientContentView removeFromSuperview];
......@@ -173,9 +166,21 @@
#pragma mark Content Setters
- (void)resetNativeContent:(id<CRWNativeContent>)nativeControllerToReset {
__weak id oldController = nativeControllerToReset;
if ([oldController respondsToSelector:@selector(willBeDismissed)]) {
[oldController willBeDismissed];
}
[[oldController view] removeFromSuperview];
// TODO(crbug.com/503297): Re-enable this DCHECK once native controller
// leaks are fixed.
// DCHECK(!oldController);
}
- (void)resetContent {
self.webViewContentView = nil;
self.nativeController = nil;
[self resetNativeContent:self.nativeController];
[self.delegate containerViewResetNativeController:self];
self.transientContentView = nil;
self.contentViewProxy.contentView = nil;
}
......@@ -183,17 +188,20 @@
- (void)displayWebViewContentView:(CRWWebViewContentView*)webViewContentView {
DCHECK(webViewContentView);
self.webViewContentView = webViewContentView;
self.nativeController = nil;
[self resetNativeContent:self.nativeController];
[self.delegate containerViewResetNativeController:self];
self.transientContentView = nil;
self.contentViewProxy.contentView = self.webViewContentView;
[self updateWebViewContentViewForContainerWindow:self.window];
[self setNeedsLayout];
}
- (void)displayNativeContent:(id<CRWNativeContent>)nativeController {
DCHECK(nativeController);
- (void)nativeContentDidChange:(id<CRWNativeContent>)previousNativeController {
DCHECK(self.nativeController);
self.webViewContentView = nil;
self.nativeController = nativeController;
if (![self.nativeController isEqual:previousNativeController]) {
[self resetNativeContent:previousNativeController];
}
self.transientContentView = nil;
self.contentViewProxy.contentView = nil;
[self setNeedsLayout];
......
......@@ -40,6 +40,7 @@
#import "ios/web/public/test/fakes/test_web_view_content_view.h"
#import "ios/web/public/test/web_view_content_test_util.h"
#import "ios/web/public/web_state/ui/crw_native_content.h"
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
#import "ios/web/public/web_state/ui/crw_native_content_provider.h"
#include "ios/web/public/web_state/url_verification_constants.h"
#include "ios/web/public/web_state/web_state_observer.h"
......@@ -307,7 +308,8 @@ TEST_P(CRWWebControllerTest, AbortNativeUrlNavigation) {
TestNativeContent* content =
[[TestNativeContent alloc] initWithURL:native_url virtualURL:native_url];
[mock_native_provider setController:content forURL:native_url];
[web_controller() setNativeProvider:mock_native_provider];
[[web_controller() nativeContentHolder]
setNativeProvider:mock_native_provider];
AddPendingItem(native_url, ui::PAGE_TRANSITION_TYPED);
......@@ -1003,7 +1005,8 @@ class CRWWebControllerNativeContentTest
void SetUp() override {
ProgrammaticWebTestWithWebController::SetUp();
mock_native_provider_ = [[TestNativeContentProvider alloc] init];
[web_controller() setNativeProvider:mock_native_provider_];
[[web_controller() nativeContentHolder]
setNativeProvider:mock_native_provider_];
}
void Load(const GURL& URL) {
......
......@@ -33,6 +33,7 @@
#import "ios/web/public/web_client.h"
#import "ios/web/public/web_state/context_menu_params.h"
#import "ios/web/public/web_state/ui/crw_native_content.h"
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
#import "ios/web/public/web_state/web_state_delegate.h"
#include "ios/web/public/web_state/web_state_interface_provider.h"
#include "ios/web/public/web_state/web_state_observer.h"
......@@ -702,7 +703,7 @@ GURL WebStateImpl::GetCurrentURL(URLVerificationTrustLevel* trust_level) const {
navigation_manager_->GetLastCommittedItemImpl();
GURL lastCommittedURL;
if (item) {
if ([web_controller_.nativeController
if ([[web_controller_ nativeContentHolder].nativeController
respondsToSelector:@selector(virtualURL)] ||
item->error_retry_state_machine().state() ==
ErrorRetryState::kReadyToDisplayErrorForFailedNavigation) {
......
......@@ -30,6 +30,7 @@
#import "ios/web/public/test/web_view_interaction_test_util.h"
#import "ios/web/public/web_client.h"
#import "ios/web/public/web_state/navigation_context.h"
#import "ios/web/public/web_state/ui/crw_native_content_holder.h"
#include "ios/web/public/web_state/web_state_observer.h"
#import "ios/web/public/web_state/web_state_policy_decider.h"
#include "ios/web/test/test_url_constants.h"
......@@ -866,7 +867,8 @@ class WebStateObserverTest
virtualURL:GURL::EmptyGURL()];
WebStateImpl* web_state_impl = reinterpret_cast<WebStateImpl*>(web_state());
web_state_impl->GetWebController().nativeProvider = provider_;
[web_state_impl->GetWebController() nativeContentHolder].nativeProvider =
provider_;
test_server_ = std::make_unique<EmbeddedTestServer>();
test_server_->RegisterRequestHandler(
......
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