| 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 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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)usesDesktopUserAgent { | 2352 - (BOOL)usesDesktopUserAgent { |
| 2353 web::NavigationItem* item = [self currentNavItem]; | 2353 web::NavigationItem* item = [self currentNavItem]; |
| 2354 return item && item->IsOverridingUserAgent(); | 2354 return item && item->GetUserAgentType() == web::UserAgentType::DESKTOP; |
| 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 } |
| 2363 return _mojoFacade.get(); | 2363 return _mojoFacade.get(); |
| 2364 } | 2364 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2394 DCHECK(fromEntry); | 2394 DCHECK(fromEntry); |
| 2395 [self updateDesktopUserAgentForEntry:self.currentSessionEntry | 2395 [self updateDesktopUserAgentForEntry:self.currentSessionEntry |
| 2396 fromEntry:fromEntry]; | 2396 fromEntry:fromEntry]; |
| 2397 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; | 2397 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; |
| 2398 } | 2398 } |
| 2399 | 2399 |
| 2400 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry | 2400 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry |
| 2401 fromEntry:(CRWSessionEntry*)fromEntry { | 2401 fromEntry:(CRWSessionEntry*)fromEntry { |
| 2402 web::NavigationItemImpl* item = entry.navigationItemImpl; | 2402 web::NavigationItemImpl* item = entry.navigationItemImpl; |
| 2403 web::NavigationItemImpl* fromItem = fromEntry.navigationItemImpl; | 2403 web::NavigationItemImpl* fromItem = fromEntry.navigationItemImpl; |
| 2404 if (!item || !fromItem) | 2404 web::UserAgentType itemUserAgentType = item->GetUserAgentType(); |
| 2405 if (!item || !fromItem || itemUserAgentType == web::UserAgentType::NONE) |
| 2405 return; | 2406 return; |
| 2406 bool useDesktopUserAgent = item->IsOverridingUserAgent(); | 2407 if (itemUserAgentType != fromItem->GetUserAgentType()) |
| 2407 if (useDesktopUserAgent != fromItem->IsOverridingUserAgent()) { | |
| 2408 [self requirePageReconstruction]; | 2408 [self requirePageReconstruction]; |
| 2409 } | |
| 2410 } | 2409 } |
| 2411 | 2410 |
| 2412 #pragma mark - | 2411 #pragma mark - |
| 2413 #pragma mark CRWWebControllerContainerViewDelegate | 2412 #pragma mark CRWWebControllerContainerViewDelegate |
| 2414 | 2413 |
| 2415 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: | 2414 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: |
| 2416 (CRWWebControllerContainerView*)containerView { | 2415 (CRWWebControllerContainerView*)containerView { |
| 2417 return _webViewProxy.get(); | 2416 return _webViewProxy.get(); |
| 2418 } | 2417 } |
| 2419 | 2418 |
| (...skipping 2828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5248 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5247 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5249 _lastRegisteredRequestURL = URL; | 5248 _lastRegisteredRequestURL = URL; |
| 5250 _loadPhase = web::LOAD_REQUESTED; | 5249 _loadPhase = web::LOAD_REQUESTED; |
| 5251 } | 5250 } |
| 5252 | 5251 |
| 5253 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5252 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5254 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5253 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5255 } | 5254 } |
| 5256 | 5255 |
| 5257 @end | 5256 @end |
| OLD | NEW |