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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
462 // Whether or not desktop user agent is used for the currentItem. | 462 // Whether or not desktop user agent is used for the currentItem. |
463 @property(nonatomic, readonly) BOOL usesDesktopUserAgent; | 463 @property(nonatomic, readonly) BOOL usesDesktopUserAgent; |
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 // TODO(crbug.com/684098): Remove these methods and inline their content. | 468 // Updates Desktop User Agent and calls webWillFinishHistoryNavigationFromEntry: |
469 // Called before finishing a history navigation from a page with the given | 469 // on CRWWebDelegate. TODO(crbug.com/684098): Remove this method and inline its |
470 // UserAgentType. | 470 // content. |
471 - (void)webWillFinishHistoryNavigationWithPreviousUserAgentType: | 471 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry; |
472 (web::UserAgentType)userAgentType; | 472 // Recreates web view if |entry| and |fromEntry| have different value for |
473 // Requires page reconstruction if |item| has a non-NONE UserAgentType and it | 473 // IsOverridingUserAgent() flag. |
474 // differs from that of |fromItem|. | 474 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry |
475 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item | 475 fromEntry:(CRWSessionEntry*)fromEntry; |
476 previousUserAgentType:(web::UserAgentType)userAgentType; | |
477 | |
478 // Removes the container view from the hierarchy and resets the ivar. | 476 // Removes the container view from the hierarchy and resets the ivar. |
479 - (void)resetContainerView; | 477 - (void)resetContainerView; |
480 // Called when the web page has changed document and/or URL, and so the page | 478 // Called when the web page has changed document and/or URL, and so the page |
481 // navigation should be reported to the delegate, and internal state updated to | 479 // navigation should be reported to the delegate, and internal state updated to |
482 // reflect the fact that the navigation has occurred. | 480 // reflect the fact that the navigation has occurred. |
483 // TODO(stuartmorgan): The code conflates URL changes and document object | 481 // TODO(stuartmorgan): The code conflates URL changes and document object |
484 // changes; the two need to be separated and handled differently. | 482 // changes; the two need to be separated and handled differently. |
485 - (void)webPageChanged; | 483 - (void)webPageChanged; |
486 // Resets any state that is associated with a specific document object (e.g., | 484 // Resets any state that is associated with a specific document object (e.g., |
487 // page interaction tracking). | 485 // page interaction tracking). |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 // Update the appropriate parts of the model and broadcast to the embedder. This | 601 // Update the appropriate parts of the model and broadcast to the embedder. This |
604 // may be called multiple times and thus must be idempotent. | 602 // may be called multiple times and thus must be idempotent. |
605 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess; | 603 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess; |
606 // Called after URL is finished loading and _loadPhase is set to PAGE_LOADED. | 604 // Called after URL is finished loading and _loadPhase is set to PAGE_LOADED. |
607 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess; | 605 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess; |
608 // Navigates forwards or backwards by |delta| pages. No-op if delta is out of | 606 // Navigates forwards or backwards by |delta| pages. No-op if delta is out of |
609 // bounds. Reloads if delta is 0. | 607 // bounds. Reloads if delta is 0. |
610 // TODO(crbug.com/661316): Move this method to NavigationManager. | 608 // TODO(crbug.com/661316): Move this method to NavigationManager. |
611 - (void)goDelta:(int)delta; | 609 - (void)goDelta:(int)delta; |
612 // Loads a new URL if the current entry is not from a pushState() navigation. | 610 // Loads a new URL if the current entry is not from a pushState() navigation. |
613 // |fromURL| is the URL of the previous NavigationItem, |fromUserAgentType| is | 611 // |fromEntry| is the CRWSessionEntry that was the current entry prior to the |
614 // that item's UserAgentType, and |sameDocument| is YES if the navigation is | 612 // navigation. |
615 // between two pages with the same document. | 613 - (void)finishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry; |
616 - (void)finishHistoryNavigationFromURL:(const GURL&)fromURL | |
617 userAgentType:(web::UserAgentType)fromUserAgentType | |
618 sameDocument:(BOOL)sameDocument; | |
619 // Informs the native controller if web usage is allowed or not. | 614 // Informs the native controller if web usage is allowed or not. |
620 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled; | 615 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled; |
621 // Called when web controller receives a new message from the web page. | 616 // Called when web controller receives a new message from the web page. |
622 - (void)didReceiveScriptMessage:(WKScriptMessage*)message; | 617 - (void)didReceiveScriptMessage:(WKScriptMessage*)message; |
623 // Returns a new script which wraps |script| with windowID check so |script| is | 618 // Returns a new script which wraps |script| with windowID check so |script| is |
624 // not evaluated on windowID mismatch. | 619 // not evaluated on windowID mismatch. |
625 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script; | 620 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script; |
626 // Attempts to handle a script message. Returns YES on success, NO otherwise. | 621 // Attempts to handle a script message. Returns YES on success, NO otherwise. |
627 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; | 622 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; |
628 // Registers load request with empty referrer and link or client redirect | 623 // Registers load request with empty referrer and link or client redirect |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 715 |
721 // Inject windowID if not yet injected. | 716 // Inject windowID if not yet injected. |
722 - (void)injectWindowID; | 717 - (void)injectWindowID; |
723 | 718 |
724 // Returns YES if the given WKBackForwardListItem is valid to use for | 719 // Returns YES if the given WKBackForwardListItem is valid to use for |
725 // navigation. | 720 // navigation. |
726 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item; | 721 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item; |
727 // Compares the two URLs being navigated between during a history navigation to | 722 // Compares the two URLs being navigated between during a history navigation to |
728 // determine if a # needs to be appended to the URL of |toItem| to trigger a | 723 // determine if a # needs to be appended to the URL of |toItem| to trigger a |
729 // hashchange event. If so, also saves the modified URL into |toItem|. | 724 // hashchange event. If so, also saves the modified URL into |toItem|. |
730 - (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem | 725 - (GURL)URLForHistoryNavigationFromItem:(web::NavigationItem*)fromItem |
731 previousURL:(const GURL&)previousURL; | 726 toItem:(web::NavigationItem*)toItem; |
| 727 |
732 // Finds all the scrollviews in the view hierarchy and makes sure they do not | 728 // Finds all the scrollviews in the view hierarchy and makes sure they do not |
733 // interfere with scroll to top when tapping the statusbar. | 729 // interfere with scroll to top when tapping the statusbar. |
734 - (void)optOutScrollsToTopForSubviews; | 730 - (void)optOutScrollsToTopForSubviews; |
735 // Tears down the old native controller, and then replaces it with the new one. | 731 // Tears down the old native controller, and then replaces it with the new one. |
736 - (void)setNativeController:(id<CRWNativeContent>)nativeController; | 732 - (void)setNativeController:(id<CRWNativeContent>)nativeController; |
737 // Returns whether |url| should be opened. | 733 // Returns whether |url| should be opened. |
738 - (BOOL)shouldOpenURL:(const GURL&)url | 734 - (BOOL)shouldOpenURL:(const GURL&)url |
739 mainDocumentURL:(const GURL&)mainDocumentURL | 735 mainDocumentURL:(const GURL&)mainDocumentURL |
740 linkClicked:(BOOL)linkClicked; | 736 linkClicked:(BOOL)linkClicked; |
741 // Called when |URL| needs to be opened in a matching native app. | 737 // 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... |
1408 | 1404 |
1409 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item { | 1405 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item { |
1410 // The current back-forward list item MUST be in the WKWebView's back-forward | 1406 // The current back-forward list item MUST be in the WKWebView's back-forward |
1411 // list to be valid. | 1407 // list to be valid. |
1412 WKBackForwardList* list = [_webView backForwardList]; | 1408 WKBackForwardList* list = [_webView backForwardList]; |
1413 return list.currentItem == item || | 1409 return list.currentItem == item || |
1414 [list.forwardList indexOfObject:item] != NSNotFound || | 1410 [list.forwardList indexOfObject:item] != NSNotFound || |
1415 [list.backList indexOfObject:item] != NSNotFound; | 1411 [list.backList indexOfObject:item] != NSNotFound; |
1416 } | 1412 } |
1417 | 1413 |
1418 - (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem | 1414 - (GURL)URLForHistoryNavigationFromItem:(web::NavigationItem*)fromItem |
1419 previousURL:(const GURL&)previousURL { | 1415 toItem:(web::NavigationItem*)toItem { |
1420 // If navigating with native API, i.e. using a back forward list item, | 1416 // If navigating with native API, i.e. using a back forward list item, |
1421 // hashchange events will be triggered automatically, so no URL tampering is | 1417 // hashchange events will be triggered automatically, so no URL tampering is |
1422 // required. | 1418 // required. |
1423 web::WKBackForwardListItemHolder* holder = | 1419 web::WKBackForwardListItemHolder* holder = |
1424 web::WKBackForwardListItemHolder::FromNavigationItem(toItem); | 1420 web::WKBackForwardListItemHolder::FromNavigationItem(toItem); |
1425 if (holder->back_forward_list_item()) { | 1421 if (holder->back_forward_list_item()) { |
1426 return toItem->GetURL(); | 1422 return toItem->GetURL(); |
1427 } | 1423 } |
1428 | 1424 |
1429 const GURL& URL = toItem->GetURL(); | 1425 const GURL& startURL = fromItem->GetURL(); |
| 1426 const GURL& endURL = toItem->GetURL(); |
1430 | 1427 |
1431 // Check the state of the fragments on both URLs (aka, is there a '#' in the | 1428 // Check the state of the fragments on both URLs (aka, is there a '#' in the |
1432 // url or not). | 1429 // url or not). |
1433 if (!previousURL.has_ref() || URL.has_ref()) { | 1430 if (!startURL.has_ref() || endURL.has_ref()) { |
1434 return URL; | 1431 return endURL; |
1435 } | 1432 } |
1436 | 1433 |
1437 // startURL contains a fragment and endURL doesn't. Remove the fragment from | 1434 // startURL contains a fragment and endURL doesn't. Remove the fragment from |
1438 // startURL and compare the resulting string to endURL. If they are equal, add | 1435 // startURL and compare the resulting string to endURL. If they are equal, add |
1439 // # to endURL to cause a hashchange event. | 1436 // # to endURL to cause a hashchange event. |
1440 GURL hashless = web::GURLByRemovingRefFromGURL(previousURL); | 1437 GURL hashless = web::GURLByRemovingRefFromGURL(startURL); |
1441 | 1438 |
1442 if (hashless != URL) | 1439 if (hashless != endURL) |
1443 return URL; | 1440 return endURL; |
1444 | 1441 |
1445 url::StringPieceReplacements<std::string> emptyRef; | 1442 url::StringPieceReplacements<std::string> emptyRef; |
1446 emptyRef.SetRefStr(""); | 1443 emptyRef.SetRefStr(""); |
1447 GURL newEndURL = URL.ReplaceComponents(emptyRef); | 1444 GURL newEndURL = endURL.ReplaceComponents(emptyRef); |
1448 toItem->SetURL(newEndURL); | 1445 toItem->SetURL(newEndURL); |
1449 return newEndURL; | 1446 return newEndURL; |
1450 } | 1447 } |
1451 | 1448 |
1452 - (void)injectWindowID { | 1449 - (void)injectWindowID { |
1453 // Default value for shouldSuppressDialogs is NO, so updating them only | 1450 // Default value for shouldSuppressDialogs is NO, so updating them only |
1454 // when necessary is a good optimization. | 1451 // when necessary is a good optimization. |
1455 if (_shouldSuppressDialogsOnWindowIDInjection) { | 1452 if (_shouldSuppressDialogsOnWindowIDInjection) { |
1456 self.shouldSuppressDialogs = YES; | 1453 self.shouldSuppressDialogs = YES; |
1457 _shouldSuppressDialogsOnWindowIDInjection = NO; | 1454 _shouldSuppressDialogsOnWindowIDInjection = NO; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 - (void)goToItemAtIndex:(int)index { | 2120 - (void)goToItemAtIndex:(int)index { |
2124 CRWSessionController* sessionController = self.sessionController; | 2121 CRWSessionController* sessionController = self.sessionController; |
2125 NSArray* entries = sessionController.entries; | 2122 NSArray* entries = sessionController.entries; |
2126 if (index < 0 || index >= static_cast<int>(entries.count)) { | 2123 if (index < 0 || index >= static_cast<int>(entries.count)) { |
2127 NOTREACHED(); | 2124 NOTREACHED(); |
2128 return; | 2125 return; |
2129 } | 2126 } |
2130 | 2127 |
2131 if (!_webStateImpl->IsShowingWebInterstitial()) | 2128 if (!_webStateImpl->IsShowingWebInterstitial()) |
2132 [self recordStateInHistory]; | 2129 [self recordStateInHistory]; |
2133 | 2130 CRWSessionEntry* fromEntry = sessionController.currentEntry; |
2134 web::NavigationItem* previousItem = sessionController.currentItem; | 2131 CRWSessionEntry* toEntry = entries[index]; |
2135 GURL previousURL = previousItem ? previousItem->GetURL() : GURL::EmptyGURL(); | |
2136 web::UserAgentType previousUserAgentType = | |
2137 previousItem ? previousItem->GetUserAgentType() | |
2138 : web::UserAgentType::NONE; | |
2139 web::NavigationItem* toItem = items[index].get(); | |
2140 BOOL sameDocumentNavigation = | |
2141 [sessionController isSameDocumentNavigationBetweenItem:previousItem | |
2142 andItem:toItem]; | |
2143 | 2132 |
2144 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; | 2133 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; |
2145 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { | 2134 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { |
2146 [self clearTransientContentView]; | 2135 [self clearTransientContentView]; |
2147 [self updateDesktopUserAgentForEntry:toEntry fromEntry:fromEntry]; | 2136 [self updateDesktopUserAgentForEntry:toEntry fromEntry:fromEntry]; |
2148 | 2137 |
2149 // Update the user agent before attempting the navigation. | 2138 BOOL sameDocumentNavigation = [sessionController |
2150 [self updateDesktopUserAgentForItem:toItem | 2139 isSameDocumentNavigationBetweenItem:fromEntry.navigationItem |
2151 previousUserAgentType:previousUserAgentType]; | 2140 andItem:toEntry.navigationItem]; |
2152 | |
2153 if (sameDocumentNavigation) { | 2141 if (sameDocumentNavigation) { |
2154 [sessionController goToItemAtIndex:index]; | 2142 [sessionController goToItemAtIndex:index]; |
2155 [self updateHTML5HistoryState]; | 2143 [self updateHTML5HistoryState]; |
2156 } else { | 2144 } else { |
2157 [sessionController discardNonCommittedItems]; | 2145 [sessionController discardNonCommittedItems]; |
2158 [sessionController setPendingItemIndex:index]; | 2146 [sessionController setPendingItemIndex:index]; |
2159 | 2147 |
2160 web::NavigationItemImpl* pendingItem = | 2148 web::NavigationItemImpl* pendingItem = |
2161 sessionController.pendingEntry.navigationItemImpl; | 2149 sessionController.pendingEntry.navigationItemImpl; |
2162 pendingItem->SetTransitionType(ui::PageTransitionFromInt( | 2150 pendingItem->SetTransitionType(ui::PageTransitionFromInt( |
2163 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK)); | 2151 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK)); |
2164 | 2152 |
2165 [self loadCurrentURL]; | 2153 [self loadCurrentURL]; |
2166 } | 2154 } |
2167 } else { | 2155 } else { |
2168 [sessionController goToItemAtIndex:index]; | 2156 [sessionController goToItemAtIndex:index]; |
2169 if (previousURL.is_valid()) { | 2157 if (fromEntry) |
2170 [self finishHistoryNavigationFromURL:previousURL | 2158 [self finishHistoryNavigationFromEntry:fromEntry]; |
2171 userAgentType:previousUserAgentType | |
2172 sameDocument:sameDocumentNavigation]; | |
2173 } | |
2174 } | 2159 } |
2175 } | 2160 } |
2176 | 2161 |
2177 - (BOOL)isLoaded { | 2162 - (BOOL)isLoaded { |
2178 return _loadPhase == web::PAGE_LOADED; | 2163 return _loadPhase == web::PAGE_LOADED; |
2179 } | 2164 } |
2180 | 2165 |
2181 - (void)didFinishNavigation { | 2166 - (void)didFinishNavigation { |
2182 // This can be called at multiple times after the document has loaded. Do | 2167 // This can be called at multiple times after the document has loaded. Do |
2183 // nothing if the document has already loaded. | 2168 // nothing if the document has already loaded. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 [self reload]; | 2242 [self reload]; |
2258 return; | 2243 return; |
2259 } | 2244 } |
2260 | 2245 |
2261 if (self.navigationManagerImpl->CanGoToOffset(delta)) { | 2246 if (self.navigationManagerImpl->CanGoToOffset(delta)) { |
2262 NSInteger index = self.navigationManagerImpl->GetIndexForOffset(delta); | 2247 NSInteger index = self.navigationManagerImpl->GetIndexForOffset(delta); |
2263 [self goToItemAtIndex:index]; | 2248 [self goToItemAtIndex:index]; |
2264 } | 2249 } |
2265 } | 2250 } |
2266 | 2251 |
2267 - (void)finishHistoryNavigationFromURL:(const GURL&)fromURL | 2252 - (void)finishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
2268 userAgentType:(web::UserAgentType)fromUserAgentType | 2253 [self webWillFinishHistoryNavigationFromEntry:fromEntry]; |
2269 sameDocument:(BOOL)sameDocument { | |
2270 [self webWillFinishHistoryNavigationWithPreviousUserAgentType: | |
2271 fromUserAgentType]; | |
2272 | 2254 |
2273 // Only load the new URL if it has a different document than |fromEntry| to | 2255 // Only load the new URL if it has a different document than |fromEntry| to |
2274 // prevent extra page loads from NavigationItems created by hash changes or | 2256 // prevent extra page loads from NavigationItems created by hash changes or |
2275 // calls to window.history.pushState(). | 2257 // calls to window.history.pushState(). |
2276 web::NavigationItem* currentItem = self.currentNavItem; | 2258 BOOL shouldLoadURL = ![self.sessionController |
2277 GURL endURL = | 2259 isSameDocumentNavigationBetweenItem:fromEntry.navigationItem |
2278 [self URLForHistoryNavigationToItem:currentItem previousURL:fromURL]; | 2260 andItem:self.currentNavItem]; |
2279 if (!sameDocument) { | 2261 web::NavigationItemImpl* currentItem = |
| 2262 self.currentSessionEntry.navigationItemImpl; |
| 2263 GURL endURL = [self URLForHistoryNavigationFromItem:fromEntry.navigationItem |
| 2264 toItem:currentItem]; |
| 2265 if (shouldLoadURL) { |
2280 ui::PageTransition transition = ui::PageTransitionFromInt( | 2266 ui::PageTransition transition = ui::PageTransitionFromInt( |
2281 ui::PAGE_TRANSITION_RELOAD | ui::PAGE_TRANSITION_FORWARD_BACK); | 2267 ui::PAGE_TRANSITION_RELOAD | ui::PAGE_TRANSITION_FORWARD_BACK); |
2282 | 2268 |
2283 NavigationManager::WebLoadParams params(endURL); | 2269 NavigationManager::WebLoadParams params(endURL); |
2284 if (currentItem) { | 2270 if (currentItem) { |
2285 params.referrer = currentItem->GetReferrer(); | 2271 params.referrer = currentItem->GetReferrer(); |
2286 } | 2272 } |
2287 params.transition_type = transition; | 2273 params.transition_type = transition; |
2288 [self loadWithParams:params]; | 2274 [self loadWithParams:params]; |
2289 } | 2275 } |
2290 // If this is a same-document navigation, update the HTML5 history state | 2276 // If this is a same-document navigation, update the HTML5 history state |
2291 // immediately. For cross-document navigations, the history state will be | 2277 // immediately. For cross-document navigations, the history state will be |
2292 // updated after the navigation is committed, as attempting to replace the URL | 2278 // updated after the navigation is committed, as attempting to replace the URL |
2293 // here will result in a JavaScript SecurityError due to the URLs having | 2279 // here will result in a JavaScript SecurityError due to the URLs having |
2294 // different origins. | 2280 // different origins. |
2295 if (sameDocument) | 2281 if (!shouldLoadURL) |
2296 [self updateHTML5HistoryState]; | 2282 [self updateHTML5HistoryState]; |
2297 } | 2283 } |
2298 | 2284 |
2299 - (void)addGestureRecognizerToWebView:(UIGestureRecognizer*)recognizer { | 2285 - (void)addGestureRecognizerToWebView:(UIGestureRecognizer*)recognizer { |
2300 if ([_gestureRecognizers containsObject:recognizer]) | 2286 if ([_gestureRecognizers containsObject:recognizer]) |
2301 return; | 2287 return; |
2302 | 2288 |
2303 [_webView addGestureRecognizer:recognizer]; | 2289 [_webView addGestureRecognizer:recognizer]; |
2304 [_gestureRecognizers addObject:recognizer]; | 2290 [_gestureRecognizers addObject:recognizer]; |
2305 } | 2291 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 [delegate webController:strongSelf didLoadPassKitObject:data]; | 2364 [delegate webController:strongSelf didLoadPassKitObject:data]; |
2379 } | 2365 } |
2380 }; | 2366 }; |
2381 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 2367 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
2382 _passKitDownloader.reset([[CRWPassKitDownloader alloc] | 2368 _passKitDownloader.reset([[CRWPassKitDownloader alloc] |
2383 initWithContextGetter:browserState->GetRequestContext() | 2369 initWithContextGetter:browserState->GetRequestContext() |
2384 completionHandler:passKitCompletion]); | 2370 completionHandler:passKitCompletion]); |
2385 return _passKitDownloader.get(); | 2371 return _passKitDownloader.get(); |
2386 } | 2372 } |
2387 | 2373 |
2388 - (void)webWillFinishHistoryNavigationWithPreviousUserAgentType: | 2374 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
2389 (web::UserAgentType)userAgentType { | 2375 DCHECK(fromEntry); |
2390 [self updateDesktopUserAgentForItem:self.currentNavItem | 2376 [self updateDesktopUserAgentForEntry:self.currentSessionEntry |
2391 previousUserAgentType:userAgentType]; | 2377 fromEntry:fromEntry]; |
2392 [_delegate webWillFinishHistoryNavigation]; | 2378 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; |
2393 } | 2379 } |
2394 | 2380 |
2395 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item | 2381 - (void)updateDesktopUserAgentForEntry:(CRWSessionEntry*)entry |
2396 previousUserAgentType:(web::UserAgentType)userAgentType { | 2382 fromEntry:(CRWSessionEntry*)fromEntry { |
2397 if (!item) | 2383 web::NavigationItemImpl* item = entry.navigationItemImpl; |
2398 return; | 2384 web::NavigationItemImpl* fromItem = fromEntry.navigationItemImpl; |
2399 web::UserAgentType itemUserAgentType = item->GetUserAgentType(); | 2385 web::UserAgentType itemUserAgentType = item->GetUserAgentType(); |
2400 if (!item || !fromItem || itemUserAgentType == web::UserAgentType::NONE) | 2386 if (!item || !fromItem || itemUserAgentType == web::UserAgentType::NONE) |
2401 return; | 2387 return; |
2402 if (itemUserAgentType != userAgentType) | 2388 if (itemUserAgentType != fromItem->GetUserAgentType()) |
2403 [self requirePageReconstruction]; | 2389 [self requirePageReconstruction]; |
2404 } | 2390 } |
2405 | 2391 |
2406 #pragma mark - | 2392 #pragma mark - |
2407 #pragma mark CRWWebControllerContainerViewDelegate | 2393 #pragma mark CRWWebControllerContainerViewDelegate |
2408 | 2394 |
2409 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: | 2395 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: |
2410 (CRWWebControllerContainerView*)containerView { | 2396 (CRWWebControllerContainerView*)containerView { |
2411 return _webViewProxy.get(); | 2397 return _webViewProxy.get(); |
2412 } | 2398 } |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5233 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5219 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
5234 _lastRegisteredRequestURL = URL; | 5220 _lastRegisteredRequestURL = URL; |
5235 _loadPhase = web::LOAD_REQUESTED; | 5221 _loadPhase = web::LOAD_REQUESTED; |
5236 } | 5222 } |
5237 | 5223 |
5238 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5224 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5239 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5225 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5240 } | 5226 } |
5241 | 5227 |
5242 @end | 5228 @end |
OLD | NEW |