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

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: Update function name Created 3 years, 9 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 461
462 // agent. 462 // Whether or not desktop user agent is used for the currently visible page.
463 @property(nonatomic, readonly) BOOL useDesktopUserAgent; 463 @property(nonatomic, readonly, getter=isUsingDesktopUserAgent)
Eugene But (OOO till 7-30) 2017/02/23 02:36:59 Same comment here.
liaoyuke 2017/02/23 17:50:42 Done.
464 BOOL usesDesktopUserAgent;
464 465
465 // Facade for Mojo API. 466 // Facade for Mojo API.
466 @property(nonatomic, readonly) web::MojoFacade* mojoFacade; 467 @property(nonatomic, readonly) web::MojoFacade* mojoFacade;
467 468
468 // Updates Desktop User Agent and calls webWillFinishHistoryNavigationFromEntry: 469 // Updates Desktop User Agent and calls webWillFinishHistoryNavigationFromEntry:
469 // on CRWWebDelegate. TODO(crbug.com/684098): Remove this method and inline its 470 // on CRWWebDelegate. TODO(crbug.com/684098): Remove this method and inline its
470 // content. 471 // content.
471 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry; 472 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry;
472 // Recreates web view if |entry| and |fromEntry| have different value for 473 // Recreates web view if |entry| and |fromEntry| have different value for
473 // IsOverridingUserAgent() flag. 474 // 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 2333 // 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 2334 // 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 2335 // the page has no navigation items, as occurs when an App Store link is
2335 // opened from another application. 2336 // opened from another application.
2336 BOOL rendererInitiatedWithoutInteraction = 2337 BOOL rendererInitiatedWithoutInteraction =
2337 self.sessionController.openedByDOM && !_userInteractedWithWebController; 2338 self.sessionController.openedByDOM && !_userInteractedWithWebController;
2338 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); 2339 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount());
2339 return rendererInitiatedWithoutInteraction || noNavigationItems; 2340 return rendererInitiatedWithoutInteraction || noNavigationItems;
2340 } 2341 }
2341 2342
2342 - (BOOL)useDesktopUserAgent { 2343 - (BOOL)isUsingDesktopUserAgent {
2343 web::NavigationItem* item = [self currentNavItem]; 2344 web::NavigationItem* visibleItem =
Eugene But (OOO till 7-30) 2017/02/23 02:36:59 nit: How about this?: if (!self.navigationManager
liaoyuke 2017/02/23 17:50:42 Done.
2344 return item && item->IsOverridingUserAgent(); 2345 self.navigationManagerImpl ? self.navigationManagerImpl->GetVisibleItem()
2346 : nil;
2347 return visibleItem && visibleItem->IsOverridingUserAgent();
2345 } 2348 }
2346 2349
2347 - (web::MojoFacade*)mojoFacade { 2350 - (web::MojoFacade*)mojoFacade {
2348 if (!_mojoFacade) { 2351 if (!_mojoFacade) {
2349 service_manager::mojom::InterfaceProvider* interfaceProvider = 2352 service_manager::mojom::InterfaceProvider* interfaceProvider =
2350 _webStateImpl->GetMojoInterfaceRegistry(); 2353 _webStateImpl->GetMojoInterfaceRegistry();
2351 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); 2354 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self));
2352 } 2355 }
2353 return _mojoFacade.get(); 2356 return _mojoFacade.get();
2354 } 2357 }
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after
4207 scrollView:self.webScrollView]); 4210 scrollView:self.webScrollView]);
4208 [_containerView displayWebViewContentView:webViewContentView]; 4211 [_containerView displayWebViewContentView:webViewContentView];
4209 } 4212 }
4210 } 4213 }
4211 4214
4212 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { 4215 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config {
4213 // Do not attach the context menu controller immediately as the JavaScript 4216 // Do not attach the context menu controller immediately as the JavaScript
4214 // delegate must be specified. 4217 // delegate must be specified.
4215 return web::BuildWKWebView(CGRectZero, config, 4218 return web::BuildWKWebView(CGRectZero, config,
4216 self.webStateImpl->GetBrowserState(), 4219 self.webStateImpl->GetBrowserState(),
4217 [self useDesktopUserAgent]); 4220 self.usesDesktopUserAgent);
4218 } 4221 }
4219 4222
4220 - (void)setWebView:(WKWebView*)webView { 4223 - (void)setWebView:(WKWebView*)webView {
4221 DCHECK_NE(_webView.get(), webView); 4224 DCHECK_NE(_webView.get(), webView);
4222 4225
4223 // Unwind the old web view. 4226 // Unwind the old web view.
4224 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is 4227 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is
4225 // fixed. 4228 // fixed.
4226 CRWWKScriptMessageRouter* messageRouter = 4229 CRWWKScriptMessageRouter* messageRouter =
4227 [self webViewConfigurationProvider].GetScriptMessageRouter(); 4230 [self webViewConfigurationProvider].GetScriptMessageRouter();
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5242 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5240 _lastRegisteredRequestURL = URL; 5243 _lastRegisteredRequestURL = URL;
5241 _loadPhase = web::LOAD_REQUESTED; 5244 _loadPhase = web::LOAD_REQUESTED;
5242 } 5245 }
5243 5246
5244 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5247 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5245 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5248 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5246 } 5249 }
5247 5250
5248 @end 5251 @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