Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2751793002: Cleaned up old navigation code that did not use pending navigation item. (Closed)
Patch Set: Moar DCHECKs Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // Returns the navigation item for the current page. 469 // Returns the navigation item for the current page.
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.
480 // Called before finishing a history navigation from a page with the given
481 // UserAgentType.
482 - (void)webWillFinishHistoryNavigationWithPreviousUserAgentType:
483 (web::UserAgentType)userAgentType;
484 // Requires page reconstruction if |item| has a non-NONE UserAgentType and it 479 // Requires page reconstruction if |item| has a non-NONE UserAgentType and it
485 // differs from that of |fromItem|. 480 // differs from that of |fromItem|.
486 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item 481 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item
487 previousUserAgentType:(web::UserAgentType)userAgentType; 482 previousUserAgentType:(web::UserAgentType)userAgentType;
488 483
489 // Removes the container view from the hierarchy and resets the ivar. 484 // Removes the container view from the hierarchy and resets the ivar.
490 - (void)resetContainerView; 485 - (void)resetContainerView;
491 // Called when the web page has changed document and/or URL, and so the page 486 // Called when the web page has changed document and/or URL, and so the page
492 // navigation should be reported to the delegate, and internal state updated to 487 // navigation should be reported to the delegate, and internal state updated to
493 // reflect the fact that the navigation has occurred. 488 // reflect the fact that the navigation has occurred.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 - (void)didFinishNavigation; 591 - (void)didFinishNavigation;
597 // Update the appropriate parts of the model and broadcast to the embedder. This 592 // Update the appropriate parts of the model and broadcast to the embedder. This
598 // may be called multiple times and thus must be idempotent. 593 // may be called multiple times and thus must be idempotent.
599 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess; 594 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess;
600 // Called after URL is finished loading and _loadPhase is set to PAGE_LOADED. 595 // Called after URL is finished loading and _loadPhase is set to PAGE_LOADED.
601 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess; 596 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess;
602 // Navigates forwards or backwards by |delta| pages. No-op if delta is out of 597 // Navigates forwards or backwards by |delta| pages. No-op if delta is out of
603 // bounds. Reloads if delta is 0. 598 // bounds. Reloads if delta is 0.
604 // TODO(crbug.com/661316): Move this method to NavigationManager. 599 // TODO(crbug.com/661316): Move this method to NavigationManager.
605 - (void)goDelta:(int)delta; 600 - (void)goDelta:(int)delta;
606 // Loads a new URL if the current entry is not from a pushState() navigation.
607 // |fromURL| is the URL of the previous NavigationItem, |fromUserAgentType| is
608 // that item's UserAgentType, and |sameDocument| is YES if the navigation is
609 // between two pages with the same document.
610 - (void)finishHistoryNavigationFromURL:(const GURL&)fromURL
611 userAgentType:(web::UserAgentType)fromUserAgentType
612 sameDocument:(BOOL)sameDocument;
613 // Informs the native controller if web usage is allowed or not. 601 // Informs the native controller if web usage is allowed or not.
614 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled; 602 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled;
615 // Called when web controller receives a new message from the web page. 603 // Called when web controller receives a new message from the web page.
616 - (void)didReceiveScriptMessage:(WKScriptMessage*)message; 604 - (void)didReceiveScriptMessage:(WKScriptMessage*)message;
617 // Returns a new script which wraps |script| with windowID check so |script| is 605 // Returns a new script which wraps |script| with windowID check so |script| is
618 // not evaluated on windowID mismatch. 606 // not evaluated on windowID mismatch.
619 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script; 607 - (NSString*)scriptByAddingWindowIDCheckForScript:(NSString*)script;
620 // Attempts to handle a script message. Returns YES on success, NO otherwise. 608 // Attempts to handle a script message. Returns YES on success, NO otherwise.
621 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; 609 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage;
622 // Registers load request with empty referrer and link or client redirect 610 // Registers load request with empty referrer and link or client redirect
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 - (BOOL)isCurrentNavigationBackForward; 699 - (BOOL)isCurrentNavigationBackForward;
712 // Returns whether the given navigation is triggered by a user link click. 700 // Returns whether the given navigation is triggered by a user link click.
713 - (BOOL)isLinkNavigation:(WKNavigationType)navigationType; 701 - (BOOL)isLinkNavigation:(WKNavigationType)navigationType;
714 702
715 // Inject windowID if not yet injected. 703 // Inject windowID if not yet injected.
716 - (void)injectWindowID; 704 - (void)injectWindowID;
717 705
718 // Returns YES if the given WKBackForwardListItem is valid to use for 706 // Returns YES if the given WKBackForwardListItem is valid to use for
719 // navigation. 707 // navigation.
720 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item; 708 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item;
721 // Compares the two URLs being navigated between during a history navigation to
722 // determine if a # needs to be appended to the URL of |toItem| to trigger a
723 // hashchange event. If so, also saves the modified URL into |toItem|.
724 - (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem
725 previousURL:(const GURL&)previousURL;
726 // Finds all the scrollviews in the view hierarchy and makes sure they do not 709 // Finds all the scrollviews in the view hierarchy and makes sure they do not
727 // interfere with scroll to top when tapping the statusbar. 710 // interfere with scroll to top when tapping the statusbar.
728 - (void)optOutScrollsToTopForSubviews; 711 - (void)optOutScrollsToTopForSubviews;
729 // Tears down the old native controller, and then replaces it with the new one. 712 // Tears down the old native controller, and then replaces it with the new one.
730 - (void)setNativeController:(id<CRWNativeContent>)nativeController; 713 - (void)setNativeController:(id<CRWNativeContent>)nativeController;
731 // Returns whether |url| should be opened. 714 // Returns whether |url| should be opened.
732 - (BOOL)shouldOpenURL:(const GURL&)url 715 - (BOOL)shouldOpenURL:(const GURL&)url
733 mainDocumentURL:(const GURL&)mainDocumentURL 716 mainDocumentURL:(const GURL&)mainDocumentURL
734 linkClicked:(BOOL)linkClicked; 717 linkClicked:(BOOL)linkClicked;
735 // Called when |URL| needs to be opened in a matching native app. 718 // Called when |URL| needs to be opened in a matching native app.
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 1383
1401 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item { 1384 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item {
1402 // The current back-forward list item MUST be in the WKWebView's back-forward 1385 // The current back-forward list item MUST be in the WKWebView's back-forward
1403 // list to be valid. 1386 // list to be valid.
1404 WKBackForwardList* list = [_webView backForwardList]; 1387 WKBackForwardList* list = [_webView backForwardList];
1405 return list.currentItem == item || 1388 return list.currentItem == item ||
1406 [list.forwardList indexOfObject:item] != NSNotFound || 1389 [list.forwardList indexOfObject:item] != NSNotFound ||
1407 [list.backList indexOfObject:item] != NSNotFound; 1390 [list.backList indexOfObject:item] != NSNotFound;
1408 } 1391 }
1409 1392
1410 - (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem
1411 previousURL:(const GURL&)previousURL {
1412 // If navigating with native API, i.e. using a back forward list item,
1413 // hashchange events will be triggered automatically, so no URL tampering is
1414 // required.
1415 web::WKBackForwardListItemHolder* holder =
1416 web::WKBackForwardListItemHolder::FromNavigationItem(toItem);
1417 if (holder->back_forward_list_item()) {
1418 return toItem->GetURL();
1419 }
1420
1421 const GURL& URL = toItem->GetURL();
1422
1423 // Check the state of the fragments on both URLs (aka, is there a '#' in the
1424 // url or not).
1425 if (!previousURL.has_ref() || URL.has_ref()) {
1426 return URL;
1427 }
1428
1429 // startURL contains a fragment and endURL doesn't. Remove the fragment from
1430 // startURL and compare the resulting string to endURL. If they are equal, add
1431 // # to endURL to cause a hashchange event.
1432 GURL hashless = web::GURLByRemovingRefFromGURL(previousURL);
1433
1434 if (hashless != URL)
1435 return URL;
1436
1437 url::StringPieceReplacements<std::string> emptyRef;
1438 emptyRef.SetRefStr("");
1439 GURL newEndURL = URL.ReplaceComponents(emptyRef);
1440 toItem->SetURL(newEndURL);
1441 return newEndURL;
1442 }
1443
1444 - (void)injectWindowID { 1393 - (void)injectWindowID {
1445 // Default value for shouldSuppressDialogs is NO, so updating them only 1394 // Default value for shouldSuppressDialogs is NO, so updating them only
1446 // when necessary is a good optimization. 1395 // when necessary is a good optimization.
1447 if (_shouldSuppressDialogsOnWindowIDInjection) { 1396 if (_shouldSuppressDialogsOnWindowIDInjection) {
1448 self.shouldSuppressDialogs = YES; 1397 self.shouldSuppressDialogs = YES;
1449 _shouldSuppressDialogsOnWindowIDInjection = NO; 1398 _shouldSuppressDialogsOnWindowIDInjection = NO;
1450 } 1399 }
1451 1400
1452 [_windowIDJSManager inject]; 1401 [_windowIDJSManager inject];
1453 } 1402 }
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 referrer:referrer 1788 referrer:referrer
1840 transition:self.currentTransition]; 1789 transition:self.currentTransition];
1841 [self loadNativeViewWithSuccess:YES]; 1790 [self loadNativeViewWithSuccess:YES];
1842 } 1791 }
1843 1792
1844 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams { 1793 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams {
1845 // Make a copy of |params|, as some of the delegate methods may modify it. 1794 // Make a copy of |params|, as some of the delegate methods may modify it.
1846 NavigationManager::WebLoadParams params(originalParams); 1795 NavigationManager::WebLoadParams params(originalParams);
1847 1796
1848 // Initiating a navigation from the UI, record the current page state before 1797 // Initiating a navigation from the UI, record the current page state before
1849 // the new page loads. Don't record for back/forward, as the current entry 1798 // the new page loads.
1850 // has already been moved to the next entry in the history. Do, however,
1851 // record it for general reload.
1852 // TODO(jimblackler): consider a single unified call to record state whenever
1853 // the page is about to be changed. This cannot currently be done after
1854 // addPendingItem is called.
1855 1799
1856 [_delegate webWillInitiateLoadWithParams:params]; 1800 [_delegate webWillInitiateLoadWithParams:params];
1857 1801
1858 GURL navUrl = params.url; 1802 GURL navUrl = params.url;
1859 ui::PageTransition transition = params.transition_type; 1803 ui::PageTransition transition = params.transition_type;
1804 DCHECK(!(transition & ui::PAGE_TRANSITION_FORWARD_BACK));
1805 DCHECK(!(transition & ui::PAGE_TRANSITION_RELOAD));
rohitrao (ping after 24h) 2017/03/16 19:36:54 Looks like this DCHECK is firing during an interna
1860 1806
1861 BOOL initialNavigation = NO; 1807 BOOL initialNavigation = NO;
1862 BOOL forwardBack = 1808 // Clear transient view before making any changes to history and navigation
1863 PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && 1809 // manager. TODO(stuartmorgan): Drive Transient Item clearing from
1864 (transition & ui::PAGE_TRANSITION_FORWARD_BACK); 1810 // navigation system, rather than from WebController.
1865 if (forwardBack) { 1811 [self clearTransientContentView];
1866 // Setting these for back/forward is not supported.
1867 DCHECK(!params.extra_headers);
1868 DCHECK(!params.post_data);
1869 } else {
1870 // Clear transient view before making any changes to history and navigation
1871 // manager. TODO(stuartmorgan): Drive Transient Item clearing from
1872 // navigation system, rather than from WebController.
1873 [self clearTransientContentView];
1874 1812
1875 // TODO(stuartmorgan): Why doesn't recordStateInHistory get called for 1813 [self recordStateInHistory];
1876 // forward/back transitions?
1877 [self recordStateInHistory];
1878 1814
1879 if (!self.currentNavItem) 1815 if (!self.currentNavItem)
1880 initialNavigation = YES; 1816 initialNavigation = YES;
1881 1817
1882 web::NavigationInitiationType navigationInitiationType = 1818 web::NavigationInitiationType navigationInitiationType =
1883 params.is_renderer_initiated 1819 params.is_renderer_initiated
1884 ? web::NavigationInitiationType::RENDERER_INITIATED 1820 ? web::NavigationInitiationType::RENDERER_INITIATED
1885 : web::NavigationInitiationType::USER_INITIATED; 1821 : web::NavigationInitiationType::USER_INITIATED;
1886 self.navigationManagerImpl->AddPendingItem( 1822 self.navigationManagerImpl->AddPendingItem(
1887 navUrl, params.referrer, transition, navigationInitiationType); 1823 navUrl, params.referrer, transition, navigationInitiationType);
1888 1824
1889 web::NavigationItemImpl* addedItem = self.currentNavItem; 1825 web::NavigationItemImpl* addedItem = self.currentNavItem;
1890 DCHECK(addedItem); 1826 DCHECK(addedItem);
1891 if (params.extra_headers) 1827 if (params.extra_headers)
1892 addedItem->AddHttpRequestHeaders(params.extra_headers); 1828 addedItem->AddHttpRequestHeaders(params.extra_headers);
1893 if (params.post_data) { 1829 if (params.post_data) {
1894 DCHECK([addedItem->GetHttpRequestHeaders() objectForKey:@"Content-Type"]) 1830 DCHECK([addedItem->GetHttpRequestHeaders() objectForKey:@"Content-Type"])
1895 << "Post data should have an associated content type"; 1831 << "Post data should have an associated content type";
1896 addedItem->SetPostData(params.post_data); 1832 addedItem->SetPostData(params.post_data);
1897 addedItem->SetShouldSkipRepostFormConfirmation(true); 1833 addedItem->SetShouldSkipRepostFormConfirmation(true);
1898 }
1899 } 1834 }
1900 1835
1901 [_delegate webDidUpdateSessionForLoadWithParams:params 1836 [_delegate webDidUpdateSessionForLoadWithParams:params
1902 wasInitialNavigation:initialNavigation]; 1837 wasInitialNavigation:initialNavigation];
1903 1838
1904 [self loadCurrentURL]; 1839 [self loadCurrentURL];
1905 } 1840 }
1906 1841
1907 - (void)loadCurrentURL { 1842 - (void)loadCurrentURL {
1908 // If the content view doesn't exist, the tab has either been evicted, or 1843 // If the content view doesn't exist, the tab has either been evicted, or
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 CRWSessionController* sessionController = self.sessionController; 2027 CRWSessionController* sessionController = self.sessionController;
2093 const web::ScopedNavigationItemImplList& items = sessionController.items; 2028 const web::ScopedNavigationItemImplList& items = sessionController.items;
2094 if (index < 0 || index >= static_cast<int>(items.size())) { 2029 if (index < 0 || index >= static_cast<int>(items.size())) {
2095 NOTREACHED(); 2030 NOTREACHED();
2096 return; 2031 return;
2097 } 2032 }
2098 2033
2099 if (!_webStateImpl->IsShowingWebInterstitial()) 2034 if (!_webStateImpl->IsShowingWebInterstitial())
2100 [self recordStateInHistory]; 2035 [self recordStateInHistory];
2101 2036
2037 [self clearTransientContentView];
2038
2039 // Update the user agent before attempting the navigation.
2040 web::NavigationItem* toItem = items[index].get();
2102 web::NavigationItem* previousItem = sessionController.currentItem; 2041 web::NavigationItem* previousItem = sessionController.currentItem;
2103 GURL previousURL = previousItem ? previousItem->GetURL() : GURL::EmptyGURL();
2104 web::UserAgentType previousUserAgentType = 2042 web::UserAgentType previousUserAgentType =
2105 previousItem ? previousItem->GetUserAgentType() 2043 previousItem ? previousItem->GetUserAgentType()
2106 : web::UserAgentType::NONE; 2044 : web::UserAgentType::NONE;
2107 web::NavigationItem* toItem = items[index].get(); 2045 [self updateDesktopUserAgentForItem:toItem
2046 previousUserAgentType:previousUserAgentType];
2047
2108 BOOL sameDocumentNavigation = 2048 BOOL sameDocumentNavigation =
2109 [sessionController isSameDocumentNavigationBetweenItem:previousItem 2049 [sessionController isSameDocumentNavigationBetweenItem:previousItem
2110 andItem:toItem]; 2050 andItem:toItem];
2051 if (sameDocumentNavigation) {
2052 [sessionController goToItemAtIndex:index];
2053 [self updateHTML5HistoryState];
2054 } else {
2055 [sessionController discardNonCommittedItems];
2056 [sessionController setPendingItemIndex:index];
2111 2057
2112 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; 2058 web::NavigationItemImpl* pendingItem = sessionController.pendingItem;
2113 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { 2059 pendingItem->SetTransitionType(ui::PageTransitionFromInt(
2114 [self clearTransientContentView]; 2060 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK));
2115 2061
2116 // Update the user agent before attempting the navigation. 2062 [self loadCurrentURL];
2117 [self updateDesktopUserAgentForItem:toItem
2118 previousUserAgentType:previousUserAgentType];
2119
2120 if (sameDocumentNavigation) {
2121 [sessionController goToItemAtIndex:index];
2122 [self updateHTML5HistoryState];
2123 } else {
2124 [sessionController discardNonCommittedItems];
2125 [sessionController setPendingItemIndex:index];
2126
2127 web::NavigationItemImpl* pendingItem = sessionController.pendingItem;
2128 pendingItem->SetTransitionType(ui::PageTransitionFromInt(
2129 pendingItem->GetTransitionType() | ui::PAGE_TRANSITION_FORWARD_BACK));
2130
2131 [self loadCurrentURL];
2132 }
2133 } else {
2134 [sessionController goToItemAtIndex:index];
2135 if (previousURL.is_valid()) {
2136 [self finishHistoryNavigationFromURL:previousURL
2137 userAgentType:previousUserAgentType
2138 sameDocument:sameDocumentNavigation];
2139 }
2140 } 2063 }
2141 } 2064 }
2142 2065
2143 - (BOOL)isLoaded { 2066 - (BOOL)isLoaded {
2144 return _loadPhase == web::PAGE_LOADED; 2067 return _loadPhase == web::PAGE_LOADED;
2145 } 2068 }
2146 2069
2147 - (void)didFinishNavigation { 2070 - (void)didFinishNavigation {
2148 // This can be called at multiple times after the document has loaded. Do 2071 // This can be called at multiple times after the document has loaded. Do
2149 // nothing if the document has already loaded. 2072 // nothing if the document has already loaded.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 [self reload]; 2146 [self reload];
2224 return; 2147 return;
2225 } 2148 }
2226 2149
2227 if (self.navigationManagerImpl->CanGoToOffset(delta)) { 2150 if (self.navigationManagerImpl->CanGoToOffset(delta)) {
2228 NSInteger index = self.navigationManagerImpl->GetIndexForOffset(delta); 2151 NSInteger index = self.navigationManagerImpl->GetIndexForOffset(delta);
2229 [self goToItemAtIndex:index]; 2152 [self goToItemAtIndex:index];
2230 } 2153 }
2231 } 2154 }
2232 2155
2233 - (void)finishHistoryNavigationFromURL:(const GURL&)fromURL
2234 userAgentType:(web::UserAgentType)fromUserAgentType
2235 sameDocument:(BOOL)sameDocument {
2236 [self webWillFinishHistoryNavigationWithPreviousUserAgentType:
2237 fromUserAgentType];
2238
2239 // Only load the new URL if it has a different document than |fromEntry| to
2240 // prevent extra page loads from NavigationItems created by hash changes or
2241 // calls to window.history.pushState().
2242 web::NavigationItem* currentItem = self.currentNavItem;
2243 GURL endURL =
2244 [self URLForHistoryNavigationToItem:currentItem previousURL:fromURL];
2245 if (!sameDocument) {
2246 ui::PageTransition transition = ui::PageTransitionFromInt(
2247 ui::PAGE_TRANSITION_RELOAD | ui::PAGE_TRANSITION_FORWARD_BACK);
2248
2249 NavigationManager::WebLoadParams params(endURL);
2250 if (currentItem) {
2251 params.referrer = currentItem->GetReferrer();
2252 }
2253 params.transition_type = transition;
2254 [self loadWithParams:params];
2255 }
2256 // If this is a same-document navigation, update the HTML5 history state
2257 // immediately. For cross-document navigations, the history state will be
2258 // updated after the navigation is committed, as attempting to replace the URL
2259 // here will result in a JavaScript SecurityError due to the URLs having
2260 // different origins.
2261 if (sameDocument)
2262 [self updateHTML5HistoryState];
2263 }
2264
2265 - (void)addGestureRecognizerToWebView:(UIGestureRecognizer*)recognizer { 2156 - (void)addGestureRecognizerToWebView:(UIGestureRecognizer*)recognizer {
2266 if ([_gestureRecognizers containsObject:recognizer]) 2157 if ([_gestureRecognizers containsObject:recognizer])
2267 return; 2158 return;
2268 2159
2269 [_webView addGestureRecognizer:recognizer]; 2160 [_webView addGestureRecognizer:recognizer];
2270 [_gestureRecognizers addObject:recognizer]; 2161 [_gestureRecognizers addObject:recognizer];
2271 } 2162 }
2272 2163
2273 - (void)removeGestureRecognizerFromWebView:(UIGestureRecognizer*)recognizer { 2164 - (void)removeGestureRecognizerFromWebView:(UIGestureRecognizer*)recognizer {
2274 if (![_gestureRecognizers containsObject:recognizer]) 2165 if (![_gestureRecognizers containsObject:recognizer])
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 [delegate webController:strongSelf didLoadPassKitObject:data]; 2235 [delegate webController:strongSelf didLoadPassKitObject:data];
2345 } 2236 }
2346 }; 2237 };
2347 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); 2238 web::BrowserState* browserState = self.webStateImpl->GetBrowserState();
2348 _passKitDownloader.reset([[CRWPassKitDownloader alloc] 2239 _passKitDownloader.reset([[CRWPassKitDownloader alloc]
2349 initWithContextGetter:browserState->GetRequestContext() 2240 initWithContextGetter:browserState->GetRequestContext()
2350 completionHandler:passKitCompletion]); 2241 completionHandler:passKitCompletion]);
2351 return _passKitDownloader.get(); 2242 return _passKitDownloader.get();
2352 } 2243 }
2353 2244
2354 - (void)webWillFinishHistoryNavigationWithPreviousUserAgentType:
2355 (web::UserAgentType)userAgentType {
2356 [self updateDesktopUserAgentForItem:self.currentNavItem
2357 previousUserAgentType:userAgentType];
2358 [_delegate webWillFinishHistoryNavigation];
2359 }
2360
2361 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item 2245 - (void)updateDesktopUserAgentForItem:(web::NavigationItem*)item
2362 previousUserAgentType:(web::UserAgentType)userAgentType { 2246 previousUserAgentType:(web::UserAgentType)userAgentType {
2363 if (!item) 2247 if (!item)
2364 return; 2248 return;
2365 web::UserAgentType itemUserAgentType = item->GetUserAgentType(); 2249 web::UserAgentType itemUserAgentType = item->GetUserAgentType();
2366 if (itemUserAgentType == web::UserAgentType::NONE) 2250 if (itemUserAgentType == web::UserAgentType::NONE)
2367 return; 2251 return;
2368 if (itemUserAgentType != userAgentType) 2252 if (itemUserAgentType != userAgentType)
2369 [self requirePageReconstruction]; 2253 [self requirePageReconstruction];
2370 } 2254 }
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after
5190 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5074 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5191 _lastRegisteredRequestURL = URL; 5075 _lastRegisteredRequestURL = URL;
5192 _loadPhase = web::LOAD_REQUESTED; 5076 _loadPhase = web::LOAD_REQUESTED;
5193 } 5077 }
5194 5078
5195 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5079 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5196 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5080 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5197 } 5081 }
5198 5082
5199 @end 5083 @end
OLDNEW
« no previous file with comments | « ios/web/public/web_state/ui/crw_web_delegate.h ('k') | ios/web/web_state/ui/crw_web_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698