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