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 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2325 // the page has no navigation items, as occurs when an App Store link is | 2325 // the page has no navigation items, as occurs when an App Store link is |
2326 // opened from another application. | 2326 // opened from another application. |
2327 BOOL rendererInitiatedWithoutInteraction = | 2327 BOOL rendererInitiatedWithoutInteraction = |
2328 self.sessionController.openedByDOM && !_userInteractedWithWebController; | 2328 self.sessionController.openedByDOM && !_userInteractedWithWebController; |
2329 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); | 2329 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); |
2330 return rendererInitiatedWithoutInteraction || noNavigationItems; | 2330 return rendererInitiatedWithoutInteraction || noNavigationItems; |
2331 } | 2331 } |
2332 | 2332 |
2333 - (BOOL)usesDesktopUserAgent { | 2333 - (BOOL)usesDesktopUserAgent { |
2334 web::NavigationItem* item = [self currentNavItem]; | 2334 web::NavigationItem* item = [self currentNavItem]; |
2335 return item && item->IsOverridingUserAgent(); | 2335 return item && item->GetUserAgentType() == web::UserAgentType::DESKTOP; |
2336 } | 2336 } |
2337 | 2337 |
2338 - (web::MojoFacade*)mojoFacade { | 2338 - (web::MojoFacade*)mojoFacade { |
2339 if (!_mojoFacade) { | 2339 if (!_mojoFacade) { |
2340 service_manager::mojom::InterfaceProvider* interfaceProvider = | 2340 service_manager::mojom::InterfaceProvider* interfaceProvider = |
2341 _webStateImpl->GetMojoInterfaceRegistry(); | 2341 _webStateImpl->GetMojoInterfaceRegistry(); |
2342 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); | 2342 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); |
2343 } | 2343 } |
2344 return _mojoFacade.get(); | 2344 return _mojoFacade.get(); |
2345 } | 2345 } |
(...skipping 29 matching lines...) Expand all Loading... |
2375 DCHECK(fromEntry); | 2375 DCHECK(fromEntry); |
2376 [self updateDesktopUserAgentForEntry:self.currentSessionEntry | 2376 [self updateDesktopUserAgentForEntry:self.currentSessionEntry |
2377 fromEntry:fromEntry]; | 2377 fromEntry:fromEntry]; |
2378 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; | 2378 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; |
2379 } | 2379 } |
2380 | 2380 |
2381 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry | 2381 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry |
2382 fromEntry:(CRWSessionEntry*)fromEntry { | 2382 fromEntry:(CRWSessionEntry*)fromEntry { |
2383 web::NavigationItemImpl* item = entry.navigationItemImpl; | 2383 web::NavigationItemImpl* item = entry.navigationItemImpl; |
2384 web::NavigationItemImpl* fromItem = fromEntry.navigationItemImpl; | 2384 web::NavigationItemImpl* fromItem = fromEntry.navigationItemImpl; |
2385 if (!item || !fromItem) | 2385 web::UserAgentType itemUserAgentType = item->GetUserAgentType(); |
| 2386 if (!item || !fromItem || itemUserAgentType == web::UserAgentType::NONE) |
2386 return; | 2387 return; |
2387 bool useDesktopUserAgent = item->IsOverridingUserAgent(); | 2388 if (itemUserAgentType != fromItem->GetUserAgentType()) |
2388 if (useDesktopUserAgent != fromItem->IsOverridingUserAgent()) { | |
2389 [self requirePageReconstruction]; | 2389 [self requirePageReconstruction]; |
2390 } | |
2391 } | 2390 } |
2392 | 2391 |
2393 #pragma mark - | 2392 #pragma mark - |
2394 #pragma mark CRWWebControllerContainerViewDelegate | 2393 #pragma mark CRWWebControllerContainerViewDelegate |
2395 | 2394 |
2396 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: | 2395 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: |
2397 (CRWWebControllerContainerView*)containerView { | 2396 (CRWWebControllerContainerView*)containerView { |
2398 return _webViewProxy.get(); | 2397 return _webViewProxy.get(); |
2399 } | 2398 } |
2400 | 2399 |
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5220 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5219 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
5221 _lastRegisteredRequestURL = URL; | 5220 _lastRegisteredRequestURL = URL; |
5222 _loadPhase = web::LOAD_REQUESTED; | 5221 _loadPhase = web::LOAD_REQUESTED; |
5223 } | 5222 } |
5224 | 5223 |
5225 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5224 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5226 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5225 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5227 } | 5226 } |
5228 | 5227 |
5229 @end | 5228 @end |
OLD | NEW |