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 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1194 | 1194 |
1195 // WKWebView autoreleases its WKProcessPool on removal from superview. | 1195 // WKWebView autoreleases its WKProcessPool on removal from superview. |
1196 // Deferring WKProcessPool deallocation may lead to issues with cookie | 1196 // Deferring WKProcessPool deallocation may lead to issues with cookie |
1197 // clearing and and Browsing Data Partitioning implementation. | 1197 // clearing and and Browsing Data Partitioning implementation. |
1198 @autoreleasepool { | 1198 @autoreleasepool { |
1199 [self setNativeControllerWebUsageEnabled:_webUsageEnabled]; | 1199 [self setNativeControllerWebUsageEnabled:_webUsageEnabled]; |
1200 if (enabled) { | 1200 if (enabled) { |
1201 // Don't create the web view; let it be lazy created as needed. | 1201 // Don't create the web view; let it be lazy created as needed. |
1202 } else { | 1202 } else { |
1203 [self clearTransientContentView]; | 1203 [self clearTransientContentView]; |
1204 if ([self.nativeController respondsToSelector:@selector(willBeDismissed)]) | |
1205 [self.nativeController willBeDismissed]; | |
1204 [self removeWebViewAllowingCachedReconstruction:YES]; | 1206 [self removeWebViewAllowingCachedReconstruction:YES]; |
1205 _touchTrackingRecognizer.get().touchTrackingDelegate = nil; | 1207 _touchTrackingRecognizer.get().touchTrackingDelegate = nil; |
1206 _touchTrackingRecognizer.reset(); | 1208 _touchTrackingRecognizer.reset(); |
1207 [self resetContainerView]; | 1209 [self resetContainerView]; |
1208 } | 1210 } |
1209 } | 1211 } |
1210 } | 1212 } |
1211 | 1213 |
1212 - (void)requirePageReconstruction { | 1214 - (void)requirePageReconstruction { |
1213 [self removeWebViewAllowingCachedReconstruction:NO]; | 1215 [self removeWebViewAllowingCachedReconstruction:NO]; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1271 } | 1273 } |
1272 | 1274 |
1273 // Caller must reset the delegate before calling. | 1275 // Caller must reset the delegate before calling. |
1274 - (void)close { | 1276 - (void)close { |
1275 _webStateImpl->CancelDialogs(); | 1277 _webStateImpl->CancelDialogs(); |
1276 | 1278 |
1277 _SSLStatusUpdater.reset(); | 1279 _SSLStatusUpdater.reset(); |
1278 | 1280 |
1279 self.nativeProvider = nil; | 1281 self.nativeProvider = nil; |
1280 self.swipeRecognizerProvider = nil; | 1282 self.swipeRecognizerProvider = nil; |
1283 if ([self.nativeController respondsToSelector:@selector(willBeDismissed)]) | |
1284 [self.nativeController willBeDismissed]; | |
1281 if ([self.nativeController respondsToSelector:@selector(close)]) | 1285 if ([self.nativeController respondsToSelector:@selector(close)]) |
1282 [self.nativeController close]; | 1286 [self.nativeController close]; |
1283 | 1287 |
1284 base::scoped_nsobject<NSSet> observers([_observers copy]); | 1288 base::scoped_nsobject<NSSet> observers([_observers copy]); |
1285 for (id it in observers.get()) { | 1289 for (id it in observers.get()) { |
1286 if ([it respondsToSelector:@selector(webControllerWillClose:)]) | 1290 if ([it respondsToSelector:@selector(webControllerWillClose:)]) |
1287 [it webControllerWillClose:self]; | 1291 [it webControllerWillClose:self]; |
1288 } | 1292 } |
1289 | 1293 |
1290 if (!_isHalted) { | 1294 if (!_isHalted) { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2011 | 2015 |
2012 // Initiating a navigation from the UI, record the current page state before | 2016 // Initiating a navigation from the UI, record the current page state before |
2013 // the new page loads. Don't record for back/forward, as the current entry | 2017 // the new page loads. Don't record for back/forward, as the current entry |
2014 // has already been moved to the next entry in the history. Do, however, | 2018 // has already been moved to the next entry in the history. Do, however, |
2015 // record it for general reload. | 2019 // record it for general reload. |
2016 // TODO(jimblackler): consider a single unified call to record state whenever | 2020 // TODO(jimblackler): consider a single unified call to record state whenever |
2017 // the page is about to be changed. This cannot currently be done after | 2021 // the page is about to be changed. This cannot currently be done after |
2018 // addPendingEntry is called. | 2022 // addPendingEntry is called. |
2019 | 2023 |
2020 [_delegate webWillInitiateLoadWithParams:params]; | 2024 [_delegate webWillInitiateLoadWithParams:params]; |
2025 if ([self.nativeController respondsToSelector:@selector(willBeDismissed)]) { | |
2026 [self.nativeController willBeDismissed]; | |
2027 } | |
2021 | 2028 |
2022 GURL navUrl = params.url; | 2029 GURL navUrl = params.url; |
2023 ui::PageTransition transition = params.transition_type; | 2030 ui::PageTransition transition = params.transition_type; |
2024 | 2031 |
2025 BOOL initialNavigation = NO; | 2032 BOOL initialNavigation = NO; |
2026 BOOL forwardBack = | 2033 BOOL forwardBack = |
2027 PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && | 2034 PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && |
2028 (transition & ui::PAGE_TRANSITION_FORWARD_BACK); | 2035 (transition & ui::PAGE_TRANSITION_FORWARD_BACK); |
2029 if (forwardBack) { | 2036 if (forwardBack) { |
2030 // Setting these for back/forward is not supported. | 2037 // Setting these for back/forward is not supported. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2069 | 2076 |
2070 - (void)loadCurrentURL { | 2077 - (void)loadCurrentURL { |
2071 // If the content view doesn't exist, the tab has either been evicted, or | 2078 // If the content view doesn't exist, the tab has either been evicted, or |
2072 // never displayed. Bail, and let the URL be loaded when the tab is shown. | 2079 // never displayed. Bail, and let the URL be loaded when the tab is shown. |
2073 if (!_containerView) | 2080 if (!_containerView) |
2074 return; | 2081 return; |
2075 | 2082 |
2076 // Reset current WebUI if one exists. | 2083 // Reset current WebUI if one exists. |
2077 [self clearWebUI]; | 2084 [self clearWebUI]; |
2078 | 2085 |
2086 if ([self.nativeController respondsToSelector:@selector(willBeDismissed)]) | |
2087 [self.nativeController willBeDismissed]; | |
Eugene But (OOO till 7-30)
2016/12/19 18:47:05
It looks like |willBeDismissed| should be called o
Olivier
2016/12/20 12:29:47
Done.
| |
2088 | |
2079 // Abort any outstanding page load. This ensures the delegate gets informed | 2089 // Abort any outstanding page load. This ensures the delegate gets informed |
2080 // about the outgoing page, and further messages from the page are suppressed. | 2090 // about the outgoing page, and further messages from the page are suppressed. |
2081 if (_loadPhase != web::PAGE_LOADED) | 2091 if (_loadPhase != web::PAGE_LOADED) |
2082 [self abortLoad]; | 2092 [self abortLoad]; |
2083 | 2093 |
2084 DCHECK(!_isHalted); | 2094 DCHECK(!_isHalted); |
2085 // Remove the transient content view. | 2095 // Remove the transient content view. |
2086 [self clearTransientContentView]; | 2096 [self clearTransientContentView]; |
2087 | 2097 |
2088 web::NavigationItem* item = [self currentNavItem]; | 2098 web::NavigationItem* item = [self currentNavItem]; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2272 } | 2282 } |
2273 | 2283 |
2274 - (void)goToItemAtIndex:(int)index { | 2284 - (void)goToItemAtIndex:(int)index { |
2275 CRWSessionController* sessionController = self.sessionController; | 2285 CRWSessionController* sessionController = self.sessionController; |
2276 NSArray* entries = sessionController.entries; | 2286 NSArray* entries = sessionController.entries; |
2277 DCHECK_LT(static_cast<NSUInteger>(index), entries.count); | 2287 DCHECK_LT(static_cast<NSUInteger>(index), entries.count); |
2278 DCHECK_GE(index, 0); | 2288 DCHECK_GE(index, 0); |
2279 | 2289 |
2280 if (!_webStateImpl->IsShowingWebInterstitial()) | 2290 if (!_webStateImpl->IsShowingWebInterstitial()) |
2281 [self recordStateInHistory]; | 2291 [self recordStateInHistory]; |
2292 if ([self.nativeController respondsToSelector:@selector(willBeDismissed)]) | |
Eugene But (OOO till 7-30)
2016/12/19 18:47:05
|goToItemAtIndex:| calls |loadCurrentURL| or |load
Olivier
2016/12/20 12:29:47
Done.
| |
2293 [self.nativeController willBeDismissed]; | |
2294 | |
2282 CRWSessionEntry* fromEntry = self.sessionController.currentEntry; | 2295 CRWSessionEntry* fromEntry = self.sessionController.currentEntry; |
2283 | 2296 |
2284 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; | 2297 NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; |
2285 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { | 2298 if (![userDefaults boolForKey:@"PendingIndexNavigationDisabled"]) { |
2286 BOOL sameDocumentNavigation = | 2299 BOOL sameDocumentNavigation = |
2287 [sessionController isSameDocumentNavigationBetweenEntry:fromEntry | 2300 [sessionController isSameDocumentNavigationBetweenEntry:fromEntry |
2288 andEntry:entries[index]]; | 2301 andEntry:entries[index]]; |
2289 if (sameDocumentNavigation) { | 2302 if (sameDocumentNavigation) { |
2290 [self.sessionController goToEntryAtIndex:index]; | 2303 [self.sessionController goToEntryAtIndex:index]; |
2291 | 2304 |
(...skipping 2564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4856 if (loadError) | 4869 if (loadError) |
4857 [self handleLoadError:loadError inMainFrame:YES]; | 4870 [self handleLoadError:loadError inMainFrame:YES]; |
4858 else | 4871 else |
4859 self.webStateImpl->SetContentsMimeType("text/html"); | 4872 self.webStateImpl->SetContentsMimeType("text/html"); |
4860 }]; | 4873 }]; |
4861 } | 4874 } |
4862 | 4875 |
4863 - (void)loadHTML:(NSString*)HTML forURL:(const GURL&)URL { | 4876 - (void)loadHTML:(NSString*)HTML forURL:(const GURL&)URL { |
4864 // Remove the transient content view. | 4877 // Remove the transient content view. |
4865 [self clearTransientContentView]; | 4878 [self clearTransientContentView]; |
4879 if ([self.nativeController respondsToSelector:@selector(willBeDismissed)]) | |
4880 [self.nativeController willBeDismissed]; | |
4866 | 4881 |
4867 _loadPhase = web::LOAD_REQUESTED; | 4882 _loadPhase = web::LOAD_REQUESTED; |
4868 | 4883 |
4869 // Web View should not be created for App Specific URLs. | 4884 // Web View should not be created for App Specific URLs. |
4870 if (!web::GetWebClient()->IsAppSpecificURL(URL)) { | 4885 if (!web::GetWebClient()->IsAppSpecificURL(URL)) { |
4871 [self ensureWebViewCreated]; | 4886 [self ensureWebViewCreated]; |
4872 DCHECK(_webView) << "_webView null while trying to load HTML"; | 4887 DCHECK(_webView) << "_webView null while trying to load HTML"; |
4873 } | 4888 } |
4874 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)]; | 4889 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)]; |
4875 } | 4890 } |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5783 } | 5798 } |
5784 | 5799 |
5785 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5800 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
5786 } | 5801 } |
5787 | 5802 |
5788 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5803 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
5789 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5804 return [action.request valueForHTTPHeaderField:@"Referer"]; |
5790 } | 5805 } |
5791 | 5806 |
5792 @end | 5807 @end |
OLD | NEW |