Chromium Code Reviews| 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 // 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 currentItem. |
| 463 @property(nonatomic, readonly) BOOL useDesktopUserAgent; | 463 @property(nonatomic, readonly) BOOL usesDesktopUserAgent; |
|
kkhorimoto
2017/02/24 19:21:27
Again, I think that it would be better to fold thi
Eugene But (OOO till 7-30)
2017/02/24 19:49:18
This is existing property which will be fully remo
| |
| 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 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2342 // The page should be closed if it was initiated by the DOM and there has been | 2342 // The page should be closed if it was initiated by the DOM and there has been |
| 2343 // no user interaction with the page since the web view was created, or if | 2343 // no user interaction with the page since the web view was created, or if |
| 2344 // the page has no navigation items, as occurs when an App Store link is | 2344 // the page has no navigation items, as occurs when an App Store link is |
| 2345 // opened from another application. | 2345 // opened from another application. |
| 2346 BOOL rendererInitiatedWithoutInteraction = | 2346 BOOL rendererInitiatedWithoutInteraction = |
| 2347 self.sessionController.openedByDOM && !_userInteractedWithWebController; | 2347 self.sessionController.openedByDOM && !_userInteractedWithWebController; |
| 2348 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); | 2348 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); |
| 2349 return rendererInitiatedWithoutInteraction || noNavigationItems; | 2349 return rendererInitiatedWithoutInteraction || noNavigationItems; |
| 2350 } | 2350 } |
| 2351 | 2351 |
| 2352 - (BOOL)useDesktopUserAgent { | 2352 - (BOOL)usesDesktopUserAgent { |
| 2353 web::NavigationItem* item = [self currentNavItem]; | 2353 web::NavigationItem* item = [self currentNavItem]; |
| 2354 return item && item->IsOverridingUserAgent(); | 2354 return item && item->IsOverridingUserAgent(); |
| 2355 } | 2355 } |
| 2356 | 2356 |
| 2357 - (web::MojoFacade*)mojoFacade { | 2357 - (web::MojoFacade*)mojoFacade { |
| 2358 if (!_mojoFacade) { | 2358 if (!_mojoFacade) { |
| 2359 service_manager::mojom::InterfaceProvider* interfaceProvider = | 2359 service_manager::mojom::InterfaceProvider* interfaceProvider = |
| 2360 _webStateImpl->GetMojoInterfaceRegistry(); | 2360 _webStateImpl->GetMojoInterfaceRegistry(); |
| 2361 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); | 2361 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); |
| 2362 } | 2362 } |
| (...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4218 scrollView:self.webScrollView]); | 4218 scrollView:self.webScrollView]); |
| 4219 [_containerView displayWebViewContentView:webViewContentView]; | 4219 [_containerView displayWebViewContentView:webViewContentView]; |
| 4220 } | 4220 } |
| 4221 } | 4221 } |
| 4222 | 4222 |
| 4223 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { | 4223 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { |
| 4224 // Do not attach the context menu controller immediately as the JavaScript | 4224 // Do not attach the context menu controller immediately as the JavaScript |
| 4225 // delegate must be specified. | 4225 // delegate must be specified. |
| 4226 return web::BuildWKWebView(CGRectZero, config, | 4226 return web::BuildWKWebView(CGRectZero, config, |
| 4227 self.webStateImpl->GetBrowserState(), | 4227 self.webStateImpl->GetBrowserState(), |
| 4228 [self useDesktopUserAgent]); | 4228 self.usesDesktopUserAgent); |
| 4229 } | 4229 } |
| 4230 | 4230 |
| 4231 - (void)setWebView:(WKWebView*)webView { | 4231 - (void)setWebView:(WKWebView*)webView { |
| 4232 DCHECK_NE(_webView.get(), webView); | 4232 DCHECK_NE(_webView.get(), webView); |
| 4233 | 4233 |
| 4234 // Unwind the old web view. | 4234 // Unwind the old web view. |
| 4235 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is | 4235 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is |
| 4236 // fixed. | 4236 // fixed. |
| 4237 CRWWKScriptMessageRouter* messageRouter = | 4237 CRWWKScriptMessageRouter* messageRouter = |
| 4238 [self webViewConfigurationProvider].GetScriptMessageRouter(); | 4238 [self webViewConfigurationProvider].GetScriptMessageRouter(); |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5248 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5248 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5249 _lastRegisteredRequestURL = URL; | 5249 _lastRegisteredRequestURL = URL; |
| 5250 _loadPhase = web::LOAD_REQUESTED; | 5250 _loadPhase = web::LOAD_REQUESTED; |
| 5251 } | 5251 } |
| 5252 | 5252 |
| 5253 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5253 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5254 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5254 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5255 } | 5255 } |
| 5256 | 5256 |
| 5257 @end | 5257 @end |
| OLD | NEW |