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

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

Issue 2912993002: Call WebStateObserver::DidStopLoading for native content reloads. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « ios/web/web_state/navigation_callbacks_inttest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 // implementation. This will be inaccurate if the reload fails or is 2031 // implementation. This will be inaccurate if the reload fails or is
2032 // cancelled. 2032 // cancelled.
2033 _lastUserInteraction.reset(); 2033 _lastUserInteraction.reset();
2034 base::RecordAction(UserMetricsAction("Reload")); 2034 base::RecordAction(UserMetricsAction("Reload"));
2035 GURL url = self.currentNavItem->GetURL(); 2035 GURL url = self.currentNavItem->GetURL();
2036 if ([self shouldLoadURLInNativeView:url]) { 2036 if ([self shouldLoadURLInNativeView:url]) {
2037 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self 2037 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self
2038 registerLoadRequestForURL:url 2038 registerLoadRequestForURL:url
2039 referrer:self.currentNavItemReferrer 2039 referrer:self.currentNavItemReferrer
2040 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; 2040 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD];
2041 [self didStartLoadingURL:url];
2041 [self.nativeController reload]; 2042 [self.nativeController reload];
2042 _webStateImpl->OnNavigationFinished(navigationContext.get()); 2043 _webStateImpl->OnNavigationFinished(navigationContext.get());
2043 [self loadCompleteWithSuccess:YES forNavigation:nil]; 2044 [self loadCompleteWithSuccess:YES forNavigation:nil];
2044 } else { 2045 } else {
2045 web::NavigationItem* transientItem = 2046 web::NavigationItem* transientItem =
2046 self.navigationManagerImpl->GetTransientItem(); 2047 self.navigationManagerImpl->GetTransientItem();
2047 if (transientItem) { 2048 if (transientItem) {
2048 // If there's a transient item, a reload is considered a new navigation to 2049 // If there's a transient item, a reload is considered a new navigation to
2049 // the transient item's URL (as on other platforms). 2050 // the transient item's URL (as on other platforms).
2050 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL()); 2051 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 } 2134 }
2134 2135
2135 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess 2136 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess
2136 forNavigation:(WKNavigation*)navigation { 2137 forNavigation:(WKNavigation*)navigation {
2137 [self removePlaceholderOverlay]; 2138 [self removePlaceholderOverlay];
2138 // The webView may have been torn down (or replaced by a native view). Be 2139 // The webView may have been torn down (or replaced by a native view). Be
2139 // safe and do nothing if that's happened. 2140 // safe and do nothing if that's happened.
2140 if (_loadPhase != web::PAGE_LOADING) 2141 if (_loadPhase != web::PAGE_LOADING)
2141 return; 2142 return;
2142 2143
2143 DCHECK(_webView);
2144
2145 const GURL currentURL([self currentURL]); 2144 const GURL currentURL([self currentURL]);
2146 2145
2147 _loadPhase = web::PAGE_LOADED; 2146 _loadPhase = web::PAGE_LOADED;
2148 2147
2149 [self optOutScrollsToTopForSubviews]; 2148 [self optOutScrollsToTopForSubviews];
2150 2149
2151 DCHECK((currentURL == _lastRegisteredRequestURL) || // latest navigation 2150 DCHECK((currentURL == _lastRegisteredRequestURL) || // latest navigation
2152 // previous navigation 2151 // previous navigation
2153 ![[_navigationStates lastAddedNavigation] isEqual:navigation] || 2152 ![[_navigationStates lastAddedNavigation] isEqual:navigation] ||
2154 // invalid URL load 2153 // invalid URL load
(...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 - (NSUInteger)observerCount { 5238 - (NSUInteger)observerCount {
5240 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5239 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5241 return [_observers count]; 5240 return [_observers count];
5242 } 5241 }
5243 5242
5244 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5243 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5245 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5244 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5246 } 5245 }
5247 5246
5248 @end 5247 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/navigation_callbacks_inttest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698