Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2777243004: Allow URL loading if WebState::GetView was not called. (Closed)
Patch Set: N Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/test/web_int_test.mm ('k') | ios/web/webui/web_ui_mojo_inttest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #import <objc/runtime.h> 9 #import <objc/runtime.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 - (void)clearTransientContentView; 505 - (void)clearTransientContentView;
506 // Returns a lazily created CRWTouchTrackingRecognizer. 506 // Returns a lazily created CRWTouchTrackingRecognizer.
507 - (CRWTouchTrackingRecognizer*)touchTrackingRecognizer; 507 - (CRWTouchTrackingRecognizer*)touchTrackingRecognizer;
508 // Shows placeholder overlay. 508 // Shows placeholder overlay.
509 - (void)addPlaceholderOverlay; 509 - (void)addPlaceholderOverlay;
510 // Removes placeholder overlay. 510 // Removes placeholder overlay.
511 - (void)removePlaceholderOverlay; 511 - (void)removePlaceholderOverlay;
512 512
513 // Creates a web view if it's not yet created. 513 // Creates a web view if it's not yet created.
514 - (void)ensureWebViewCreated; 514 - (void)ensureWebViewCreated;
515 // Creates and configures |_containerView|.
516 - (void)createContainerView;
515 // Creates a web view with given |config|. No-op if web view is already created. 517 // Creates a web view with given |config|. No-op if web view is already created.
516 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; 518 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config;
517 // Returns a new autoreleased web view created with given configuration. 519 // Returns a new autoreleased web view created with given configuration.
518 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config; 520 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config;
519 // Sets the value of the webView property, and performs its basic setup. 521 // Sets the value of the webView property, and performs its basic setup.
520 - (void)setWebView:(WKWebView*)webView; 522 - (void)setWebView:(WKWebView*)webView;
521 // Removes webView, optionally tracking the URL of the evicted 523 // Removes webView, optionally tracking the URL of the evicted
522 // page for later cache-based reconstruction. 524 // page for later cache-based reconstruction.
523 - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache; 525 - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache;
524 // Called when web view process has been terminated. 526 // Called when web view process has been terminated.
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 [_delegate webDidUpdateSessionForLoadWithParams:params 1837 [_delegate webDidUpdateSessionForLoadWithParams:params
1836 wasInitialNavigation:initialNavigation]; 1838 wasInitialNavigation:initialNavigation];
1837 1839
1838 [self loadCurrentURL]; 1840 [self loadCurrentURL];
1839 } 1841 }
1840 1842
1841 - (void)loadCurrentURL { 1843 - (void)loadCurrentURL {
1842 // If the content view doesn't exist, the tab has either been evicted, or 1844 // If the content view doesn't exist, the tab has either been evicted, or
1843 // never displayed. Bail, and let the URL be loaded when the tab is shown. 1845 // never displayed. Bail, and let the URL be loaded when the tab is shown.
1844 if (!_containerView) 1846 if (!_containerView)
1845 return; 1847 [self createContainerView];
1846 1848
1847 // Reset current WebUI if one exists. 1849 // Reset current WebUI if one exists.
1848 [self clearWebUI]; 1850 [self clearWebUI];
1849 1851
1850 // Abort any outstanding page load. This ensures the delegate gets informed 1852 // Abort any outstanding page load. This ensures the delegate gets informed
1851 // about the outgoing page, and further messages from the page are suppressed. 1853 // about the outgoing page, and further messages from the page are suppressed.
1852 if (_loadPhase != web::PAGE_LOADED) 1854 if (_loadPhase != web::PAGE_LOADED)
1853 [self abortLoad]; 1855 [self abortLoad];
1854 1856
1855 DCHECK(!_isHalted); 1857 DCHECK(!_isHalted);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 1898
1897 - (BOOL)shouldLoadURLInNativeView:(const GURL&)url { 1899 - (BOOL)shouldLoadURLInNativeView:(const GURL&)url {
1898 // App-specific URLs that don't require WebUI are loaded in native views. 1900 // App-specific URLs that don't require WebUI are loaded in native views.
1899 return web::GetWebClient()->IsAppSpecificURL(url) && 1901 return web::GetWebClient()->IsAppSpecificURL(url) &&
1900 !_webStateImpl->HasWebUI(); 1902 !_webStateImpl->HasWebUI();
1901 } 1903 }
1902 1904
1903 - (void)triggerPendingLoad { 1905 - (void)triggerPendingLoad {
1904 if (!_containerView) { 1906 if (!_containerView) {
1905 DCHECK(!_isBeingDestroyed); 1907 DCHECK(!_isBeingDestroyed);
1906 // Create the top-level parent view, which will contain the content (whether 1908 [self createContainerView];
1907 // native or web). Note, this needs to be created with a non-zero size
1908 // to allow for (native) subviews with autosize constraints to be correctly
1909 // processed.
1910 _containerView.reset(
1911 [[CRWWebControllerContainerView alloc] initWithDelegate:self]);
1912
1913 // This will be resized later, but matching the final frame will minimize
1914 // re-rendering. Use the screen size because the application's key window
1915 // may still be nil.
1916 // TODO(crbug.com/688259): Stop subtracting status bar height.
1917 CGFloat statusBarHeight =
1918 [[UIApplication sharedApplication] statusBarFrame].size.height;
1919 CGRect containerViewFrame = [UIScreen mainScreen].bounds;
1920 containerViewFrame.origin.y += statusBarHeight;
1921 containerViewFrame.size.height -= statusBarHeight;
1922 _containerView.get().frame = containerViewFrame;
1923 DCHECK(!CGRectIsEmpty(_containerView.get().frame));
1924
1925 // TODO(crbug.com/691116): Remove this workaround once tests are no longer
1926 // dependent upon this accessibility ID.
1927 if (!base::ios::IsRunningOnIOS10OrLater())
1928 [_containerView setAccessibilityIdentifier:@"Container View"];
1929
1930 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]];
1931 // Is |currentUrl| a web scheme or native chrome scheme. 1909 // Is |currentUrl| a web scheme or native chrome scheme.
1932 web::NavigationItem* item = self.currentNavItem; 1910 web::NavigationItem* item = self.currentNavItem;
1933 const GURL currentNavigationURL = 1911 const GURL currentNavigationURL =
1934 item ? item->GetVirtualURL() : GURL::EmptyGURL(); 1912 item ? item->GetVirtualURL() : GURL::EmptyGURL();
1935 BOOL isChromeScheme = 1913 BOOL isChromeScheme =
1936 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL); 1914 web::GetWebClient()->IsAppSpecificURL(currentNavigationURL);
1937 1915
1938 // Don't immediately load the web page if in overlay mode. Always load if 1916 // Don't immediately load the web page if in overlay mode. Always load if
1939 // native. 1917 // native.
1940 if (isChromeScheme || !_overlayPreviewMode) { 1918 if (isChromeScheme || !_overlayPreviewMode) {
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 forHost:base::SysNSStringToUTF8(host) 3975 forHost:base::SysNSStringToUTF8(host)
3998 status:info.cert_status]; 3976 status:info.cert_status];
3999 [self loadCurrentURL]; 3977 [self loadCurrentURL];
4000 } 3978 }
4001 })); 3979 }));
4002 3980
4003 _webStateImpl->OnVisibleSecurityStateChange(); 3981 _webStateImpl->OnVisibleSecurityStateChange();
4004 [self loadCancelled]; 3982 [self loadCancelled];
4005 } 3983 }
4006 3984
3985 - (void)createContainerView {
3986 // Create the top-level parent view, which will contain the content (whether
3987 // native or web). Note, this needs to be created with a non-zero size
3988 // to allow for (native) subviews with autosize constraints to be correctly
3989 // processed.
3990 _containerView.reset(
3991 [[CRWWebControllerContainerView alloc] initWithDelegate:self]);
3992
3993 // This will be resized later, but matching the final frame will minimize
3994 // re-rendering. Use the screen size because the application's key window
3995 // may still be nil.
3996 // TODO(crbug.com/688259): Stop subtracting status bar height.
3997 CGFloat statusBarHeight =
3998 [[UIApplication sharedApplication] statusBarFrame].size.height;
3999 CGRect containerViewFrame = [UIScreen mainScreen].bounds;
4000 containerViewFrame.origin.y += statusBarHeight;
4001 containerViewFrame.size.height -= statusBarHeight;
4002 _containerView.get().frame = containerViewFrame;
4003 DCHECK(!CGRectIsEmpty(_containerView.get().frame));
4004
4005 // TODO(crbug.com/691116): Remove this workaround once tests are no longer
4006 // dependent upon this accessibility ID.
4007 if (!base::ios::IsRunningOnIOS10OrLater())
4008 [_containerView setAccessibilityIdentifier:@"Container View"];
4009
4010 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]];
4011 }
4012
4007 - (void)ensureWebViewCreated { 4013 - (void)ensureWebViewCreated {
4008 WKWebViewConfiguration* config = 4014 WKWebViewConfiguration* config =
4009 [self webViewConfigurationProvider].GetWebViewConfiguration(); 4015 [self webViewConfigurationProvider].GetWebViewConfiguration();
4010 [self ensureWebViewCreatedWithConfiguration:config]; 4016 [self ensureWebViewCreatedWithConfiguration:config];
4011 } 4017 }
4012 4018
4013 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { 4019 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config {
4014 if (!_webView) { 4020 if (!_webView) {
4015 [self setWebView:[self webViewWithConfiguration:config]]; 4021 [self setWebView:[self webViewWithConfiguration:config]];
4016 // The following is not called in -setWebView: as the latter used in unit 4022 // The following is not called in -setWebView: as the latter used in unit
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
5087 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5093 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5088 _lastRegisteredRequestURL = URL; 5094 _lastRegisteredRequestURL = URL;
5089 _loadPhase = web::LOAD_REQUESTED; 5095 _loadPhase = web::LOAD_REQUESTED;
5090 } 5096 }
5091 5097
5092 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5098 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5093 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5099 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5094 } 5100 }
5095 5101
5096 @end 5102 @end
OLDNEW
« no previous file with comments | « ios/web/test/web_int_test.mm ('k') | ios/web/webui/web_ui_mojo_inttest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698