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

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: Change to call property method using dot 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
« no previous file with comments | « ios/web/navigation/crw_session_controller.mm ('k') | no next file » | 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 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 visibleItem.
463 @property(nonatomic, readonly) BOOL useDesktopUserAgent; 463 @property(nonatomic, readonly) BOOL usesDesktopUserAgent;
464 464
465 // Facade for Mojo API. 465 // Facade for Mojo API.
466 @property(nonatomic, readonly) web::MojoFacade* mojoFacade; 466 @property(nonatomic, readonly) web::MojoFacade* mojoFacade;
467 467
468 // Updates Desktop User Agent and calls webWillFinishHistoryNavigationFromEntry: 468 // Updates Desktop User Agent and calls webWillFinishHistoryNavigationFromEntry:
469 // on CRWWebDelegate. TODO(crbug.com/684098): Remove this method and inline its 469 // on CRWWebDelegate. TODO(crbug.com/684098): Remove this method and inline its
470 // content. 470 // content.
471 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry; 471 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry;
472 // Recreates web view if |entry| and |fromEntry| have different value for 472 // Recreates web view if |entry| and |fromEntry| have different value for
473 // IsOverridingUserAgent() flag. 473 // 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 2332 // 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 2333 // 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 2334 // the page has no navigation items, as occurs when an App Store link is
2335 // opened from another application. 2335 // opened from another application.
2336 BOOL rendererInitiatedWithoutInteraction = 2336 BOOL rendererInitiatedWithoutInteraction =
2337 self.sessionController.openedByDOM && !_userInteractedWithWebController; 2337 self.sessionController.openedByDOM && !_userInteractedWithWebController;
2338 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); 2338 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount());
2339 return rendererInitiatedWithoutInteraction || noNavigationItems; 2339 return rendererInitiatedWithoutInteraction || noNavigationItems;
2340 } 2340 }
2341 2341
2342 - (BOOL)useDesktopUserAgent { 2342 - (BOOL)usesDesktopUserAgent {
2343 web::NavigationItem* item = [self currentNavItem]; 2343 if (!self.navigationManagerImpl)
2344 return item && item->IsOverridingUserAgent(); 2344 return NO;
2345
2346 web::NavigationItem* visibleItem =
2347 self.navigationManagerImpl->GetVisibleItem();
2348 return visibleItem && visibleItem->IsOverridingUserAgent();
2345 } 2349 }
2346 2350
2347 - (web::MojoFacade*)mojoFacade { 2351 - (web::MojoFacade*)mojoFacade {
2348 if (!_mojoFacade) { 2352 if (!_mojoFacade) {
2349 service_manager::mojom::InterfaceProvider* interfaceProvider = 2353 service_manager::mojom::InterfaceProvider* interfaceProvider =
2350 _webStateImpl->GetMojoInterfaceRegistry(); 2354 _webStateImpl->GetMojoInterfaceRegistry();
2351 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); 2355 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self));
2352 } 2356 }
2353 return _mojoFacade.get(); 2357 return _mojoFacade.get();
2354 } 2358 }
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after
4207 scrollView:self.webScrollView]); 4211 scrollView:self.webScrollView]);
4208 [_containerView displayWebViewContentView:webViewContentView]; 4212 [_containerView displayWebViewContentView:webViewContentView];
4209 } 4213 }
4210 } 4214 }
4211 4215
4212 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { 4216 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config {
4213 // Do not attach the context menu controller immediately as the JavaScript 4217 // Do not attach the context menu controller immediately as the JavaScript
4214 // delegate must be specified. 4218 // delegate must be specified.
4215 return web::BuildWKWebView(CGRectZero, config, 4219 return web::BuildWKWebView(CGRectZero, config,
4216 self.webStateImpl->GetBrowserState(), 4220 self.webStateImpl->GetBrowserState(),
4217 [self useDesktopUserAgent]); 4221 self.usesDesktopUserAgent);
4218 } 4222 }
4219 4223
4220 - (void)setWebView:(WKWebView*)webView { 4224 - (void)setWebView:(WKWebView*)webView {
4221 DCHECK_NE(_webView.get(), webView); 4225 DCHECK_NE(_webView.get(), webView);
4222 4226
4223 // Unwind the old web view. 4227 // Unwind the old web view.
4224 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is 4228 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is
4225 // fixed. 4229 // fixed.
4226 CRWWKScriptMessageRouter* messageRouter = 4230 CRWWKScriptMessageRouter* messageRouter =
4227 [self webViewConfigurationProvider].GetScriptMessageRouter(); 4231 [self webViewConfigurationProvider].GetScriptMessageRouter();
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5243 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5240 _lastRegisteredRequestURL = URL; 5244 _lastRegisteredRequestURL = URL;
5241 _loadPhase = web::LOAD_REQUESTED; 5245 _loadPhase = web::LOAD_REQUESTED;
5242 } 5246 }
5243 5247
5244 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5248 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5245 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5249 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5246 } 5250 }
5247 5251
5248 @end 5252 @end
OLDNEW
« no previous file with comments | « 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