Commit d53dd34a authored by Eugene But's avatar Eugene But Committed by Commit Bot

Make LoadIfNecessary work after WebState::GetView() call.

LoadIfNecessary was no-op if _containerView already exists. This is
incorrect, because WebState::GetView() creates _containerView, but
LoadIfNecessary should still work after WebState::GetView() call.

This CL introduces _currentURLLoadWasTrigerred variable which is used
inside LoadIfNecessary to prevent extra subsequent loads.

Bug: 820484
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Id199789094a25fe414015dd586bf1411f2e81bea
Reviewed-on: https://chromium-review.googlesource.com/1067440
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560698}
parent 876dcfb7
......@@ -271,6 +271,10 @@ NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) {
// |self.view| from within this class, as |self.view| triggers creation while
// |self.containerView| will return nil if the view hasn't been instantiated.
CRWWebControllerContainerView* _containerView;
// YES if the current URL load was triggered in Web Controller. NO by default
// and after web usage was disabled. Used by |-loadCurrentURLIfNecessary| to
// prevent extra loads.
BOOL _currentURLLoadWasTrigerred;
// If |_contentView| contains a native view rather than a web view, this
// is its controller. If it's a web view, this is nil.
id<CRWNativeContent> _nativeController;
......@@ -1068,6 +1072,7 @@ GURL URLEscapedForHistory(const GURL& url) {
_touchTrackingRecognizer.touchTrackingDelegate = nil;
_touchTrackingRecognizer = nil;
[self resetContainerView];
_currentURLLoadWasTrigerred = NO;
}
}
}
......@@ -1850,6 +1855,8 @@ registerLoadRequestForURL:(const GURL&)requestURL
if (!_containerView)
return;
_currentURLLoadWasTrigerred = YES;
// Reset current WebUI if one exists.
[self clearWebUI];
......@@ -1899,7 +1906,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
- (void)loadCurrentURLIfNecessary {
if (_webProcessCrashed) {
[self loadCurrentURL];
} else if (!_containerView) {
} else if (!_currentURLLoadWasTrigerred) {
[self ensureContainerViewCreated];
// TODO(crbug.com/796608): end the practice of calling |loadCurrentURL|
......@@ -5557,6 +5564,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
#pragma mark Testing-Only Methods
- (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView {
_currentURLLoadWasTrigerred = NO;
[self removeWebView];
[_containerView displayWebViewContentView:webViewContentView];
......@@ -5564,6 +5572,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
}
- (void)resetInjectedWebViewContentView {
_currentURLLoadWasTrigerred = NO;
[self setWebView:nil];
[self resetContainerView];
}
......
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