Chromium Code Reviews| 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 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2032 // implementation. This will be inaccurate if the reload fails or is | 2032 // implementation. This will be inaccurate if the reload fails or is |
| 2033 // cancelled. | 2033 // cancelled. |
| 2034 _lastUserInteraction.reset(); | 2034 _lastUserInteraction.reset(); |
| 2035 base::RecordAction(UserMetricsAction("Reload")); | 2035 base::RecordAction(UserMetricsAction("Reload")); |
| 2036 GURL url = self.currentNavItem->GetURL(); | 2036 GURL url = self.currentNavItem->GetURL(); |
| 2037 if ([self shouldLoadURLInNativeView:url]) { | 2037 if ([self shouldLoadURLInNativeView:url]) { |
| 2038 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self | 2038 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self |
| 2039 registerLoadRequestForURL:url | 2039 registerLoadRequestForURL:url |
| 2040 referrer:self.currentNavItemReferrer | 2040 referrer:self.currentNavItemReferrer |
| 2041 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; | 2041 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; |
| 2042 [self didStartLoadingURL:url]; | |
| 2042 [self.nativeController reload]; | 2043 [self.nativeController reload]; |
| 2043 _webStateImpl->OnNavigationFinished(navigationContext.get()); | 2044 _webStateImpl->OnNavigationFinished(navigationContext.get()); |
| 2044 [self loadCompleteWithSuccess:YES forNavigation:nil]; | 2045 [self loadCompleteWithSuccess:YES forNavigation:nil]; |
| 2045 } else { | 2046 } else { |
| 2046 web::NavigationItem* transientItem = | 2047 web::NavigationItem* transientItem = |
| 2047 self.navigationManagerImpl->GetTransientItem(); | 2048 self.navigationManagerImpl->GetTransientItem(); |
| 2048 if (transientItem) { | 2049 if (transientItem) { |
| 2049 // If there's a transient item, a reload is considered a new navigation to | 2050 // If there's a transient item, a reload is considered a new navigation to |
| 2050 // the transient item's URL (as on other platforms). | 2051 // the transient item's URL (as on other platforms). |
| 2051 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL()); | 2052 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2132 } | 2133 } |
| 2133 | 2134 |
| 2134 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess | 2135 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess |
| 2135 forNavigation:(WKNavigation*)navigation { | 2136 forNavigation:(WKNavigation*)navigation { |
| 2136 [self removePlaceholderOverlay]; | 2137 [self removePlaceholderOverlay]; |
| 2137 // The webView may have been torn down (or replaced by a native view). Be | 2138 // The webView may have been torn down (or replaced by a native view). Be |
| 2138 // safe and do nothing if that's happened. | 2139 // safe and do nothing if that's happened. |
| 2139 if (_loadPhase != web::PAGE_LOADING) | 2140 if (_loadPhase != web::PAGE_LOADING) |
| 2140 return; | 2141 return; |
| 2141 | 2142 |
| 2142 DCHECK(_webView); | |
|
Eugene But (OOO till 7-30)
2017/05/26 17:36:32
This is now called for native content
| |
| 2143 | |
| 2144 const GURL currentURL([self currentURL]); | 2143 const GURL currentURL([self currentURL]); |
| 2145 | 2144 |
| 2146 _loadPhase = web::PAGE_LOADED; | 2145 _loadPhase = web::PAGE_LOADED; |
| 2147 | 2146 |
| 2148 [self optOutScrollsToTopForSubviews]; | 2147 [self optOutScrollsToTopForSubviews]; |
| 2149 | 2148 |
| 2150 DCHECK((currentURL == _lastRegisteredRequestURL) || // latest navigation | 2149 DCHECK((currentURL == _lastRegisteredRequestURL) || // latest navigation |
| 2151 // previous navigation | 2150 // previous navigation |
| 2152 ![[_navigationStates lastAddedNavigation] isEqual:navigation] || | 2151 ![[_navigationStates lastAddedNavigation] isEqual:navigation] || |
| 2153 // invalid URL load | 2152 // invalid URL load |
| (...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5238 - (NSUInteger)observerCount { | 5237 - (NSUInteger)observerCount { |
| 5239 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5238 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
| 5240 return [_observers count]; | 5239 return [_observers count]; |
| 5241 } | 5240 } |
| 5242 | 5241 |
| 5243 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5242 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5244 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5243 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5245 } | 5244 } |
| 5246 | 5245 |
| 5247 @end | 5246 @end |
| OLD | NEW |