OLD | NEW |
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 Loading... |
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 | 461 // Returns whether the desktop user agent should be used when setting the user |
462 // Whether or not desktop user agent is used for the visibleItem. | 462 // agent. |
463 @property(nonatomic, readonly) BOOL usesDesktopUserAgent; | 463 @property(nonatomic, readonly) BOOL useDesktopUserAgent; |
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 Loading... |
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)usesDesktopUserAgent { | 2342 - (BOOL)useDesktopUserAgent { |
2343 if (!self.navigationManagerImpl) | 2343 web::NavigationItem* item = [self currentNavItem]; |
2344 return NO; | 2344 return item && item->IsOverridingUserAgent(); |
2345 | |
2346 web::NavigationItem* visibleItem = | |
2347 self.navigationManagerImpl->GetVisibleItem(); | |
2348 return visibleItem && visibleItem->IsOverridingUserAgent(); | |
2349 } | 2345 } |
2350 | 2346 |
2351 - (web::MojoFacade*)mojoFacade { | 2347 - (web::MojoFacade*)mojoFacade { |
2352 if (!_mojoFacade) { | 2348 if (!_mojoFacade) { |
2353 service_manager::mojom::InterfaceProvider* interfaceProvider = | 2349 service_manager::mojom::InterfaceProvider* interfaceProvider = |
2354 _webStateImpl->GetMojoInterfaceRegistry(); | 2350 _webStateImpl->GetMojoInterfaceRegistry(); |
2355 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); | 2351 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); |
2356 } | 2352 } |
2357 return _mojoFacade.get(); | 2353 return _mojoFacade.get(); |
2358 } | 2354 } |
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4211 scrollView:self.webScrollView]); | 4207 scrollView:self.webScrollView]); |
4212 [_containerView displayWebViewContentView:webViewContentView]; | 4208 [_containerView displayWebViewContentView:webViewContentView]; |
4213 } | 4209 } |
4214 } | 4210 } |
4215 | 4211 |
4216 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { | 4212 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { |
4217 // Do not attach the context menu controller immediately as the JavaScript | 4213 // Do not attach the context menu controller immediately as the JavaScript |
4218 // delegate must be specified. | 4214 // delegate must be specified. |
4219 return web::BuildWKWebView(CGRectZero, config, | 4215 return web::BuildWKWebView(CGRectZero, config, |
4220 self.webStateImpl->GetBrowserState(), | 4216 self.webStateImpl->GetBrowserState(), |
4221 self.usesDesktopUserAgent); | 4217 [self useDesktopUserAgent]); |
4222 } | 4218 } |
4223 | 4219 |
4224 - (void)setWebView:(WKWebView*)webView { | 4220 - (void)setWebView:(WKWebView*)webView { |
4225 DCHECK_NE(_webView.get(), webView); | 4221 DCHECK_NE(_webView.get(), webView); |
4226 | 4222 |
4227 // Unwind the old web view. | 4223 // Unwind the old web view. |
4228 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is | 4224 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is |
4229 // fixed. | 4225 // fixed. |
4230 CRWWKScriptMessageRouter* messageRouter = | 4226 CRWWKScriptMessageRouter* messageRouter = |
4231 [self webViewConfigurationProvider].GetScriptMessageRouter(); | 4227 [self webViewConfigurationProvider].GetScriptMessageRouter(); |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5243 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5239 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
5244 _lastRegisteredRequestURL = URL; | 5240 _lastRegisteredRequestURL = URL; |
5245 _loadPhase = web::LOAD_REQUESTED; | 5241 _loadPhase = web::LOAD_REQUESTED; |
5246 } | 5242 } |
5247 | 5243 |
5248 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5244 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5249 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5245 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5250 } | 5246 } |
5251 | 5247 |
5252 @end | 5248 @end |
OLD | NEW |