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

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

Issue 2711683002: (Set)IsOverridingUserAgent should be called on VisibleItem (Closed)
Patch Set: Remove IsUsingDesktopUserAgent in NavigationManagerImpl Created 3 years, 10 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
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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // This method can change the state of the CRWWebController, as it will display 451 // This method can change the state of the CRWWebController, as it will display
452 // an error if the returned URL is not reliable from a security point of view. 452 // an error if the returned URL is not reliable from a security point of view.
453 // Note that this method is expensive, so it should always be cached locally if 453 // Note that this method is expensive, so it should always be cached locally if
454 // it's needed multiple times in a method. 454 // it's needed multiple times in a method.
455 @property(nonatomic, readonly) GURL currentURL; 455 @property(nonatomic, readonly) GURL currentURL;
456 // Returns the referrer for the current page. 456 // Returns the referrer for the current page.
457 @property(nonatomic, readonly) web::Referrer currentReferrer; 457 @property(nonatomic, readonly) web::Referrer currentReferrer;
458 458
459 // Returns YES if the user interacted with the page recently. 459 // Returns YES if the user interacted with the page recently.
460 @property(nonatomic, readonly) BOOL userClickedRecently; 460 @property(nonatomic, readonly) BOOL userClickedRecently;
461 // Returns whether the desktop user agent should be used when setting the user
462 // agent.
463 @property(nonatomic, readonly) BOOL useDesktopUserAgent;
464 461
465 // Facade for Mojo API. 462 // Facade for Mojo API.
466 @property(nonatomic, readonly) web::MojoFacade* mojoFacade; 463 @property(nonatomic, readonly) web::MojoFacade* mojoFacade;
467 464
468 // Updates Desktop User Agent and calls webWillFinishHistoryNavigationFromEntry: 465 // Updates Desktop User Agent and calls webWillFinishHistoryNavigationFromEntry:
469 // on CRWWebDelegate. TODO(crbug.com/684098): Remove this method and inline its 466 // on CRWWebDelegate. TODO(crbug.com/684098): Remove this method and inline its
470 // content. 467 // content.
471 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry; 468 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry;
472 // Recreates web view if |entry| and |fromEntry| have different value for 469 // Recreates web view if |entry| and |fromEntry| have different value for
473 // IsOverridingUserAgent() flag. 470 // IsOverridingUserAgent() flag.
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 // The page should be closed if it was initiated by the DOM and there has been 2329 // The page should be closed if it was initiated by the DOM and there has been
2333 // no user interaction with the page since the web view was created, or if 2330 // no user interaction with the page since the web view was created, or if
2334 // the page has no navigation items, as occurs when an App Store link is 2331 // the page has no navigation items, as occurs when an App Store link is
2335 // opened from another application. 2332 // opened from another application.
2336 BOOL rendererInitiatedWithoutInteraction = 2333 BOOL rendererInitiatedWithoutInteraction =
2337 self.sessionController.openedByDOM && !_userInteractedWithWebController; 2334 self.sessionController.openedByDOM && !_userInteractedWithWebController;
2338 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); 2335 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount());
2339 return rendererInitiatedWithoutInteraction || noNavigationItems; 2336 return rendererInitiatedWithoutInteraction || noNavigationItems;
2340 } 2337 }
2341 2338
2342 - (BOOL)useDesktopUserAgent {
2343 web::NavigationItem* item = [self currentNavItem];
2344 return item && item->IsOverridingUserAgent();
2345 }
2346
2347 - (web::MojoFacade*)mojoFacade { 2339 - (web::MojoFacade*)mojoFacade {
2348 if (!_mojoFacade) { 2340 if (!_mojoFacade) {
2349 service_manager::mojom::InterfaceProvider* interfaceProvider = 2341 service_manager::mojom::InterfaceProvider* interfaceProvider =
2350 _webStateImpl->GetMojoInterfaceRegistry(); 2342 _webStateImpl->GetMojoInterfaceRegistry();
2351 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); 2343 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self));
2352 } 2344 }
2353 return _mojoFacade.get(); 2345 return _mojoFacade.get();
2354 } 2346 }
2355 2347
2356 - (CRWPassKitDownloader*)passKitDownloader { 2348 - (CRWPassKitDownloader*)passKitDownloader {
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after
4203 [_containerView addToolbars:_webViewToolbars]; 4195 [_containerView addToolbars:_webViewToolbars];
4204 4196
4205 base::scoped_nsobject<CRWWebViewContentView> webViewContentView( 4197 base::scoped_nsobject<CRWWebViewContentView> webViewContentView(
4206 [[CRWWebViewContentView alloc] initWithWebView:_webView 4198 [[CRWWebViewContentView alloc] initWithWebView:_webView
4207 scrollView:self.webScrollView]); 4199 scrollView:self.webScrollView]);
4208 [_containerView displayWebViewContentView:webViewContentView]; 4200 [_containerView displayWebViewContentView:webViewContentView];
4209 } 4201 }
4210 } 4202 }
4211 4203
4212 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { 4204 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config {
4205 web::NavigationItem* visibleItem =
Eugene But (OOO till 7-30) 2017/02/23 00:54:24 Is there a reason for removing |useDesktopUserAgen
liaoyuke 2017/02/23 01:10:14 Done.
kkhorimoto 2017/02/23 01:16:25 I suggested removing the old property because of t
4206 self.navigationManagerImpl ? self.navigationManagerImpl->GetVisibleItem()
4207 : nil;
4208 BOOL isUsingDesktopUseragent =
Eugene But (OOO till 7-30) 2017/02/23 00:54:24 shouldUseDesktopUserAgent Agent capitalized, |is|
liaoyuke 2017/02/23 01:10:14 Acknowledged.
4209 visibleItem && visibleItem->IsOverridingUserAgent();
4210
4213 // Do not attach the context menu controller immediately as the JavaScript 4211 // Do not attach the context menu controller immediately as the JavaScript
4214 // delegate must be specified. 4212 // delegate must be specified.
4215 return web::BuildWKWebView(CGRectZero, config, 4213 return web::BuildWKWebView(CGRectZero, config,
4216 self.webStateImpl->GetBrowserState(), 4214 self.webStateImpl->GetBrowserState(),
4217 [self useDesktopUserAgent]); 4215 isUsingDesktopUseragent);
4218 } 4216 }
4219 4217
4220 - (void)setWebView:(WKWebView*)webView { 4218 - (void)setWebView:(WKWebView*)webView {
4221 DCHECK_NE(_webView.get(), webView); 4219 DCHECK_NE(_webView.get(), webView);
4222 4220
4223 // Unwind the old web view. 4221 // Unwind the old web view.
4224 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is 4222 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is
4225 // fixed. 4223 // fixed.
4226 CRWWKScriptMessageRouter* messageRouter = 4224 CRWWKScriptMessageRouter* messageRouter =
4227 [self webViewConfigurationProvider].GetScriptMessageRouter(); 4225 [self webViewConfigurationProvider].GetScriptMessageRouter();
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5237 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5240 _lastRegisteredRequestURL = URL; 5238 _lastRegisteredRequestURL = URL;
5241 _loadPhase = web::LOAD_REQUESTED; 5239 _loadPhase = web::LOAD_REQUESTED;
5242 } 5240 }
5243 5241
5244 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5242 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5245 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5243 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5246 } 5244 }
5247 5245
5248 @end 5246 @end
OLDNEW
« ios/chrome/browser/tabs/tab.h ('K') | « ios/web/navigation/crw_session_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698