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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 @property(nonatomic, readonly) web::NavigationItemImpl* currentNavItem; | 470 @property(nonatomic, readonly) web::NavigationItemImpl* currentNavItem; |
471 // Returns the current transition type. | 471 // Returns the current transition type. |
472 @property(nonatomic, readonly) ui::PageTransition currentTransition; | 472 @property(nonatomic, readonly) ui::PageTransition currentTransition; |
473 // Returns the referrer for current navigation item. May be empty. | 473 // Returns the referrer for current navigation item. May be empty. |
474 @property(nonatomic, readonly) web::Referrer currentNavItemReferrer; | 474 @property(nonatomic, readonly) web::Referrer currentNavItemReferrer; |
475 // The HTTP headers associated with the current navigation item. These are nil | 475 // The HTTP headers associated with the current navigation item. These are nil |
476 // unless the request was a POST. | 476 // unless the request was a POST. |
477 @property(nonatomic, readonly) NSDictionary* currentHTTPHeaders; | 477 @property(nonatomic, readonly) NSDictionary* currentHTTPHeaders; |
478 | 478 |
479 // TODO(crbug.com/684098): Remove these methods and inline their content. | 479 // TODO(crbug.com/684098): Remove these methods and inline their content. |
480 // Called before finishing a history navigation from |item|. | 480 // Called before finishing a history navigation from a page with the given |
481 - (void)webWillFinishHistoryNavigationFromItem:(web::NavigationItem*)item; | 481 // UserAgentType. |
| 482 - (void)webWillFinishHistoryNavigationWithPreviousUserAgentType: |
| 483 (web::UserAgentType)userAgentType; |
482 // Requires page reconstruction if |item| has a non-NONE UserAgentType and it | 484 // Requires page reconstruction if |item| has a non-NONE UserAgentType and it |
483 // differs from that of |fromItem|. | 485 // differs from that of |fromItem|. |
484 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item | 486 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item |
485 fromItem:(web::NavigationItem*)fromItem; | 487 previousUserAgentType:(web::UserAgentType)userAgentType; |
486 | 488 |
487 // Removes the container view from the hierarchy and resets the ivar. | 489 // Removes the container view from the hierarchy and resets the ivar. |
488 - (void)resetContainerView; | 490 - (void)resetContainerView; |
489 // Called when the web page has changed document and/or URL, and so the page | 491 // Called when the web page has changed document and/or URL, and so the page |
490 // navigation should be reported to the delegate, and internal state updated to | 492 // navigation should be reported to the delegate, and internal state updated to |
491 // reflect the fact that the navigation has occurred. | 493 // reflect the fact that the navigation has occurred. |
492 // TODO(stuartmorgan): The code conflates URL changes and document object | 494 // TODO(stuartmorgan): The code conflates URL changes and document object |
493 // changes; the two need to be separated and handled differently. | 495 // changes; the two need to be separated and handled differently. |
494 - (void)webPageChanged; | 496 - (void)webPageChanged; |
495 // Resets any state that is associated with a specific document object (e.g., | 497 // Resets any state that is associated with a specific document object (e.g., |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // Update the appropriate parts of the model and broadcast to the embedder. This | 597 // Update the appropriate parts of the model and broadcast to the embedder. This |
596 // may be called multiple times and thus must be idempotent. | 598 // may be called multiple times and thus must be idempotent. |
597 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess; | 599 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess; |
598 // Called after URL is finished loading and _loadPhase is set to PAGE_LOADED. | 600 // Called after URL is finished loading and _loadPhase is set to PAGE_LOADED. |
599 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess; | 601 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess; |
600 // Navigates forwards or backwards by |delta| pages. No-op if delta is out of | 602 // Navigates forwards or backwards by |delta| pages. No-op if delta is out of |
601 // bounds. Reloads if delta is 0. | 603 // bounds. Reloads if delta is 0. |
602 // TODO(crbug.com/661316): Move this method to NavigationManager. | 604 // TODO(crbug.com/661316): Move this method to NavigationManager. |
603 - (void)goDelta:(int)delta; | 605 - (void)goDelta:(int)delta; |
604 // Loads a new URL if the current entry is not from a pushState() navigation. | 606 // Loads a new URL if the current entry is not from a pushState() navigation. |
605 // |item| is the NavigationItem that was the current entry prior to the | 607 // |fromURL| is the URL of the previous NavigationItem, |fromUserAgentType| is |
606 // navigation. | 608 // that item's UserAgentType, and |sameDocument| is YES if the navigation is |
607 - (void)finishHistoryNavigationFromItem:(web::NavigationItem*)item; | 609 // between two pages with the same document. |
| 610 - (void)finishHistoryNavigationFromURL:(const GURL&)fromURL |
| 611 userAgentType:(web::UserAgentType)fromUserAgentType |
| 612 sameDocument:(BOOL)sameDocument; |
608 // Informs the native controller if web usage is allowed or not. | 613 // Informs the native controller if web usage is allowed or not. |
609 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled; | 614 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled; |
610 // Called when web controller receives a new message from the web page. | 615 // Called when web controller receives a new message from the web page. |
611 - (void)didReceiveScriptMessage:(WKScriptMessage*)message; | 616 - (void)didReceiveScriptMessage:(WKScriptMessage*)message; |
612 // Returns a new script which wraps |script| with windowID check so |script| is | 617 // Returns a new script which wraps |script| with windowID check so |script| is |
613 // not evaluated on windowID mismatch. | 618 // not evaluated on windowID mismatch. |
614 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script; | 619 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script; |
615 // Attempts to handle a script message. Returns YES on success, NO otherwise. | 620 // Attempts to handle a script message. Returns YES on success, NO otherwise. |
616 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; | 621 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; |
617 // Registers load request with empty referrer and link or client redirect | 622 // Registers load request with empty referrer and link or client redirect |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 714 |
710 // Inject windowID if not yet injected. | 715 // Inject windowID if not yet injected. |
711 - (void)injectWindowID; | 716 - (void)injectWindowID; |
712 | 717 |
713 // Returns YES if the given WKBackForwardListItem is valid to use for | 718 // Returns YES if the given WKBackForwardListItem is valid to use for |
714 // navigation. | 719 // navigation. |
715 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item; | 720 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item; |
716 // Compares the two URLs being navigated between during a history navigation to | 721 // Compares the two URLs being navigated between during a history navigation to |
717 // determine if a # needs to be appended to the URL of |toItem| to trigger a | 722 // determine if a # needs to be appended to the URL of |toItem| to trigger a |
718 // hashchange event. If so, also saves the modified URL into |toItem|. | 723 // hashchange event. If so, also saves the modified URL into |toItem|. |
719 - (GURL)URLForHistoryNavigationFromItem:(web::NavigationItem*)fromItem | 724 - (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem |
720 toItem:(web::NavigationItem*)toItem; | 725 previousURL:(const GURL&)previousURL; |
721 | |
722 // Finds all the scrollviews in the view hierarchy and makes sure they do not | 726 // Finds all the scrollviews in the view hierarchy and makes sure they do not |
723 // interfere with scroll to top when tapping the statusbar. | 727 // interfere with scroll to top when tapping the statusbar. |
724 - (void)optOutScrollsToTopForSubviews; | 728 - (void)optOutScrollsToTopForSubviews; |
725 // Tears down the old native controller, and then replaces it with the new one. | 729 // Tears down the old native controller, and then replaces it with the new one. |
726 - (void)setNativeController:(id<CRWNativeContent>)nativeController; | 730 - (void)setNativeController:(id<CRWNativeContent>)nativeController; |
727 // Returns whether |url| should be opened. | 731 // Returns whether |url| should be opened. |
728 - (BOOL)shouldOpenURL:(const GURL&)url | 732 - (BOOL)shouldOpenURL:(const GURL&)url |
729 mainDocumentURL:(const GURL&)mainDocumentURL | 733 mainDocumentURL:(const GURL&)mainDocumentURL |
730 linkClicked:(BOOL)linkClicked; | 734 linkClicked:(BOOL)linkClicked; |
731 // Called when |URL| needs to be opened in a matching native app. | 735 // Called when |URL| needs to be opened in a matching native app. |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 | 1402 |
1399 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item { | 1403 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item { |
1400 // The current back-forward list item MUST be in the WKWebView's back-forward | 1404 // The current back-forward list item MUST be in the WKWebView's back-forward |
1401 // list to be valid. | 1405 // list to be valid. |
1402 WKBackForwardList* list = [_webView backForwardList]; | 1406 WKBackForwardList* list = [_webView backForwardList]; |
1403 return list.currentItem == item || | 1407 return list.currentItem == item || |
1404 [list.forwardList indexOfObject:item] != NSNotFound || | 1408 [list.forwardList indexOfObject:item] != NSNotFound || |
1405 [list.backList indexOfObject:item] != NSNotFound; | 1409 [list.backList indexOfObject:item] != NSNotFound; |
1406 } | 1410 } |
1407 | 1411 |
1408 - (GURL)URLForHistoryNavigationFromItem:(web::NavigationItem*)fromItem | 1412 - (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem |
1409 toItem:(web::NavigationItem*)toItem { | 1413 previousURL:(const GURL&)previousURL { |
1410 // If navigating with native API, i.e. using a back forward list item, | 1414 // If navigating with native API, i.e. using a back forward list item, |
1411 // hashchange events will be triggered automatically, so no URL tampering is | 1415 // hashchange events will be triggered automatically, so no URL tampering is |
1412 // required. | 1416 // required. |
1413 web::WKBackForwardListItemHolder* holder = | 1417 web::WKBackForwardListItemHolder* holder = |
1414 web::WKBackForwardListItemHolder::FromNavigationItem(toItem); | 1418 web::WKBackForwardListItemHolder::FromNavigationItem(toItem); |
1415 if (holder->back_forward_list_item()) { | 1419 if (holder->back_forward_list_item()) { |
1416 return toItem->GetURL(); | 1420 return toItem->GetURL(); |
1417 } | 1421 } |
1418 | 1422 |
1419 const GURL& startURL = fromItem->GetURL(); | 1423 const GURL& URL = toItem->GetURL(); |
1420 const GURL& endURL = toItem->GetURL(); | |
1421 | 1424 |
1422 // Check the state of the fragments on both URLs (aka, is there a '#' in the | 1425 // Check the state of the fragments on both URLs (aka, is there a '#' in the |
1423 // url or not). | 1426 // url or not). |
1424 if (!startURL.has_ref() || endURL.has_ref()) { | 1427 if (!previousURL.has_ref() || URL.has_ref()) { |
1425 return endURL; | 1428 return URL; |
1426 } | 1429 } |
1427 | 1430 |
1428 // startURL contains a fragment and endURL doesn't. Remove the fragment from | 1431 // startURL contains a fragment and endURL doesn't. Remove the fragment from |
1429 // startURL and compare the resulting string to endURL. If they are equal, add | 1432 // startURL and compare the resulting string to endURL. If they are equal, add |
1430 // # to endURL to cause a hashchange event. | 1433 // # to endURL to cause a hashchange event. |
1431 GURL hashless = web::GURLByRemovingRefFromGURL(startURL); | 1434 GURL hashless = web::GURLByRemovingRefFromGURL(previousURL); |
1432 | 1435 |
1433 if (hashless != endURL) | 1436 if (hashless != URL) |
1434 return endURL; | 1437 return URL; |
1435 | 1438 |
1436 url::StringPieceReplacements<std::string> emptyRef; | 1439 url::StringPieceReplacements<std::string> emptyRef; |
1437 emptyRef.SetRefStr(""); | 1440 emptyRef.SetRefStr(""); |
1438 GURL newEndURL = endURL.ReplaceComponents(emptyRef); | 1441 GURL newEndURL = URL.ReplaceComponents(emptyRef); |
1439 toItem->SetURL(newEndURL); | 1442 toItem->SetURL(newEndURL); |
1440 return newEndURL; | 1443 return newEndURL; |
1441 } | 1444 } |
1442 | 1445 |
1443 - (void)injectWindowID { | 1446 - (void)injectWindowID { |
1444 // Default value for shouldSuppressDialogs is NO, so updating them only | 1447 // Default value for shouldSuppressDialogs is NO, so updating them only |
1445 // when necessary is a good optimization. | 1448 // when necessary is a good optimization. |
1446 if (_shouldSuppressDialogsOnWindowIDInjection) { | 1449 if (_shouldSuppressDialogsOnWindowIDInjection) { |
1447 self.shouldSuppressDialogs = YES; | 1450 self.shouldSuppressDialogs = YES; |
1448 _shouldSuppressDialogsOnWindowIDInjection = NO; | 1451 _shouldSuppressDialogsOnWindowIDInjection = NO; |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 - (void)goToItemAtIndex:(int)index { | 2112 - (void)goToItemAtIndex:(int)index { |
2110 CRWSessionController* sessionController = self.sessionController; | 2113 CRWSessionController* sessionController = self.sessionController; |
2111 const web::ScopedNavigationItemImplList& items = sessionController.items; | 2114 const web::ScopedNavigationItemImplList& items = sessionController.items; |
2112 if (index < 0 || index >= static_cast<int>(items.size())) { | 2115 if (index < 0 || index >= static_cast<int>(items.size())) { |
2113 NOTREACHED(); | 2116 NOTREACHED(); |
2114 return; | 2117 return; |
2115 } | 2118 } |
2116 | 2119 |
2117 if (!_webStateImpl->IsShowingWebInterstitial()) | 2120 if (!_webStateImpl->IsShowingWebInterstitial()) |
2118 [self recordStateInHistory]; | 2121 [self recordStateInHistory]; |
2119 web::NavigationItem* fromItem = sessionController.currentItem; | 2122 |
| 2123 web::NavigationItem* previousItem = sessionController.currentItem; |
| 2124 GURL previousURL = previousItem ? previousItem->GetURL() : GURL::EmptyGURL(); |
| 2125 web::UserAgentType previousUserAgentType = |
| 2126 previousItem ? previousItem->GetUserAgentType() |
| 2127 : web::UserAgentType::NONE; |
2120 web::NavigationItem* toItem = items[index].get(); | 2128 web::NavigationItem* toItem = items[index].get(); |
| 2129 BOOL sameDocumentNavigation = |
| 2130 [sessionController isSameDocumentNavigationBetweenItem:previousItem |
| 2131 andItem:toItem]; |
2121 | 2132 |
2122 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; | 2133 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; |
2123 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { | 2134 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { |
2124 [self clearTransientContentView]; | 2135 [self clearTransientContentView]; |
2125 | 2136 |
2126 // Update the user agent before attempting the navigation. | 2137 // Update the user agent before attempting the navigation. |
2127 [self updateDesktopUserAgentForItem:toItem fromItem:fromItem]; | 2138 [self updateDesktopUserAgentForItem:toItem |
| 2139 previousUserAgentType:previousUserAgentType]; |
2128 | 2140 |
2129 BOOL sameDocumentNavigation = | |
2130 [sessionController isSameDocumentNavigationBetweenItem:fromItem | |
2131 andItem:toItem]; | |
2132 if (sameDocumentNavigation) { | 2141 if (sameDocumentNavigation) { |
2133 [sessionController goToItemAtIndex:index]; | 2142 [sessionController goToItemAtIndex:index]; |
2134 [self updateHTML5HistoryState]; | 2143 [self updateHTML5HistoryState]; |
2135 } else { | 2144 } else { |
2136 [sessionController discardNonCommittedItems]; | 2145 [sessionController discardNonCommittedItems]; |
2137 [sessionController setPendingItemIndex:index]; | 2146 [sessionController setPendingItemIndex:index]; |
2138 | 2147 |
2139 web::NavigationItemImpl* pendingItem = sessionController.pendingItem; | 2148 web::NavigationItemImpl* pendingItem = sessionController.pendingItem; |
2140 pendingItem->SetTransitionType(ui::PageTransitionFromInt( | 2149 pendingItem->SetTransitionType(ui::PageTransitionFromInt( |
2141 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK)); | 2150 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK)); |
2142 | 2151 |
2143 [self loadCurrentURL]; | 2152 [self loadCurrentURL]; |
2144 } | 2153 } |
2145 } else { | 2154 } else { |
2146 [sessionController goToItemAtIndex:index]; | 2155 [sessionController goToItemAtIndex:index]; |
2147 if (fromItem) | 2156 if (previousURL.is_valid()) { |
2148 [self finishHistoryNavigationFromItem:fromItem]; | 2157 [self finishHistoryNavigationFromURL:previousURL |
| 2158 userAgentType:previousUserAgentType |
| 2159 sameDocument:sameDocumentNavigation]; |
| 2160 } |
2149 } | 2161 } |
2150 } | 2162 } |
2151 | 2163 |
2152 - (BOOL)isLoaded { | 2164 - (BOOL)isLoaded { |
2153 return _loadPhase == web::PAGE_LOADED; | 2165 return _loadPhase == web::PAGE_LOADED; |
2154 } | 2166 } |
2155 | 2167 |
2156 - (void)didFinishNavigation { | 2168 - (void)didFinishNavigation { |
2157 // This can be called at multiple times after the document has loaded. Do | 2169 // This can be called at multiple times after the document has loaded. Do |
2158 // nothing if the document has already loaded. | 2170 // nothing if the document has already loaded. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 [self reload]; | 2244 [self reload]; |
2233 return; | 2245 return; |
2234 } | 2246 } |
2235 | 2247 |
2236 if (self.navigationManagerImpl->CanGoToOffset(delta)) { | 2248 if (self.navigationManagerImpl->CanGoToOffset(delta)) { |
2237 NSInteger index = self.navigationManagerImpl->GetIndexForOffset(delta); | 2249 NSInteger index = self.navigationManagerImpl->GetIndexForOffset(delta); |
2238 [self goToItemAtIndex:index]; | 2250 [self goToItemAtIndex:index]; |
2239 } | 2251 } |
2240 } | 2252 } |
2241 | 2253 |
2242 - (void)finishHistoryNavigationFromItem:(web::NavigationItem*)item { | 2254 - (void)finishHistoryNavigationFromURL:(const GURL&)fromURL |
2243 [self webWillFinishHistoryNavigationFromItem:item]; | 2255 userAgentType:(web::UserAgentType)fromUserAgentType |
| 2256 sameDocument:(BOOL)sameDocument { |
| 2257 [self webWillFinishHistoryNavigationWithPreviousUserAgentType: |
| 2258 fromUserAgentType]; |
2244 | 2259 |
2245 // Only load the new URL if it has a different document than |fromEntry| to | 2260 // Only load the new URL if it has a different document than |fromEntry| to |
2246 // prevent extra page loads from NavigationItems created by hash changes or | 2261 // prevent extra page loads from NavigationItems created by hash changes or |
2247 // calls to window.history.pushState(). | 2262 // calls to window.history.pushState(). |
2248 BOOL shouldLoadURL = ![self.sessionController | |
2249 isSameDocumentNavigationBetweenItem:item | |
2250 andItem:self.currentNavItem]; | |
2251 web::NavigationItem* currentItem = self.currentNavItem; | 2263 web::NavigationItem* currentItem = self.currentNavItem; |
2252 GURL endURL = [self URLForHistoryNavigationFromItem:item toItem:currentItem]; | 2264 GURL endURL = |
2253 if (shouldLoadURL) { | 2265 [self URLForHistoryNavigationToItem:currentItem previousURL:fromURL]; |
| 2266 if (!sameDocument) { |
2254 ui::PageTransition transition = ui::PageTransitionFromInt( | 2267 ui::PageTransition transition = ui::PageTransitionFromInt( |
2255 ui::PAGE_TRANSITION_RELOAD | ui::PAGE_TRANSITION_FORWARD_BACK); | 2268 ui::PAGE_TRANSITION_RELOAD | ui::PAGE_TRANSITION_FORWARD_BACK); |
2256 | 2269 |
2257 NavigationManager::WebLoadParams params(endURL); | 2270 NavigationManager::WebLoadParams params(endURL); |
2258 if (currentItem) { | 2271 if (currentItem) { |
2259 params.referrer = currentItem->GetReferrer(); | 2272 params.referrer = currentItem->GetReferrer(); |
2260 } | 2273 } |
2261 params.transition_type = transition; | 2274 params.transition_type = transition; |
2262 [self loadWithParams:params]; | 2275 [self loadWithParams:params]; |
2263 } | 2276 } |
2264 // If this is a same-document navigation, update the HTML5 history state | 2277 // If this is a same-document navigation, update the HTML5 history state |
2265 // immediately. For cross-document navigations, the history state will be | 2278 // immediately. For cross-document navigations, the history state will be |
2266 // updated after the navigation is committed, as attempting to replace the URL | 2279 // updated after the navigation is committed, as attempting to replace the URL |
2267 // here will result in a JavaScript SecurityError due to the URLs having | 2280 // here will result in a JavaScript SecurityError due to the URLs having |
2268 // different origins. | 2281 // different origins. |
2269 if (!shouldLoadURL) | 2282 if (sameDocument) |
2270 [self updateHTML5HistoryState]; | 2283 [self updateHTML5HistoryState]; |
2271 } | 2284 } |
2272 | 2285 |
2273 - (void)addGestureRecognizerToWebView:(UIGestureRecognizer*)recognizer { | 2286 - (void)addGestureRecognizerToWebView:(UIGestureRecognizer*)recognizer { |
2274 if ([_gestureRecognizers containsObject:recognizer]) | 2287 if ([_gestureRecognizers containsObject:recognizer]) |
2275 return; | 2288 return; |
2276 | 2289 |
2277 [_webView addGestureRecognizer:recognizer]; | 2290 [_webView addGestureRecognizer:recognizer]; |
2278 [_gestureRecognizers addObject:recognizer]; | 2291 [_gestureRecognizers addObject:recognizer]; |
2279 } | 2292 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2352 [delegate webController:strongSelf didLoadPassKitObject:data]; | 2365 [delegate webController:strongSelf didLoadPassKitObject:data]; |
2353 } | 2366 } |
2354 }; | 2367 }; |
2355 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 2368 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
2356 _passKitDownloader.reset([[CRWPassKitDownloader alloc] | 2369 _passKitDownloader.reset([[CRWPassKitDownloader alloc] |
2357 initWithContextGetter:browserState->GetRequestContext() | 2370 initWithContextGetter:browserState->GetRequestContext() |
2358 completionHandler:passKitCompletion]); | 2371 completionHandler:passKitCompletion]); |
2359 return _passKitDownloader.get(); | 2372 return _passKitDownloader.get(); |
2360 } | 2373 } |
2361 | 2374 |
2362 - (void)webWillFinishHistoryNavigationFromItem:(web::NavigationItem*)item { | 2375 - (void)webWillFinishHistoryNavigationWithPreviousUserAgentType: |
2363 DCHECK(item); | 2376 (web::UserAgentType)userAgentType { |
2364 [self updateDesktopUserAgentForItem:self.currentNavItem fromItem:item]; | 2377 [self updateDesktopUserAgentForItem:self.currentNavItem |
| 2378 previousUserAgentType:userAgentType]; |
2365 [_delegate webWillFinishHistoryNavigation]; | 2379 [_delegate webWillFinishHistoryNavigation]; |
2366 } | 2380 } |
2367 | 2381 |
2368 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item | 2382 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item |
2369 fromItem:(web::NavigationItem*)fromItem { | 2383 previousUserAgentType:(web::UserAgentType)userAgentType { |
2370 if (!item || !fromItem) | 2384 if (!item) |
2371 return; | 2385 return; |
2372 web::UserAgentType itemUserAgentType = item->GetUserAgentType(); | 2386 web::UserAgentType itemUserAgentType = item->GetUserAgentType(); |
2373 if (itemUserAgentType == web::UserAgentType::NONE) | 2387 if (itemUserAgentType == web::UserAgentType::NONE) |
2374 return; | 2388 return; |
2375 if (itemUserAgentType != fromItem->GetUserAgentType()) | 2389 if (itemUserAgentType != userAgentType) |
2376 [self requirePageReconstruction]; | 2390 [self requirePageReconstruction]; |
2377 } | 2391 } |
2378 | 2392 |
2379 #pragma mark - | 2393 #pragma mark - |
2380 #pragma mark CRWWebControllerContainerViewDelegate | 2394 #pragma mark CRWWebControllerContainerViewDelegate |
2381 | 2395 |
2382 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: | 2396 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: |
2383 (CRWWebControllerContainerView*)containerView { | 2397 (CRWWebControllerContainerView*)containerView { |
2384 return _webViewProxy.get(); | 2398 return _webViewProxy.get(); |
2385 } | 2399 } |
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5205 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5219 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
5206 _lastRegisteredRequestURL = URL; | 5220 _lastRegisteredRequestURL = URL; |
5207 _loadPhase = web::LOAD_REQUESTED; | 5221 _loadPhase = web::LOAD_REQUESTED; |
5208 } | 5222 } |
5209 | 5223 |
5210 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5224 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5211 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5225 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5212 } | 5226 } |
5213 | 5227 |
5214 @end | 5228 @end |
OLD | NEW |