| 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 11 matching lines...) Expand all Loading... |
| 22 #include "base/json/json_writer.h" | 22 #include "base/json/json_writer.h" |
| 23 #include "base/json/string_escape.h" | 23 #include "base/json/string_escape.h" |
| 24 #include "base/logging.h" | 24 #include "base/logging.h" |
| 25 #include "base/mac/bind_objc_block.h" | 25 #include "base/mac/bind_objc_block.h" |
| 26 #include "base/mac/bundle_locations.h" | 26 #include "base/mac/bundle_locations.h" |
| 27 #include "base/mac/foundation_util.h" | 27 #include "base/mac/foundation_util.h" |
| 28 #include "base/mac/objc_property_releaser.h" | 28 #include "base/mac/objc_property_releaser.h" |
| 29 #include "base/mac/scoped_cftyperef.h" | 29 #include "base/mac/scoped_cftyperef.h" |
| 30 #include "base/mac/scoped_nsobject.h" | 30 #include "base/mac/scoped_nsobject.h" |
| 31 #include "base/metrics/histogram.h" | 31 #include "base/metrics/histogram.h" |
| 32 #include "base/metrics/user_metrics.h" |
| 32 #include "base/metrics/user_metrics_action.h" | 33 #include "base/metrics/user_metrics_action.h" |
| 33 #include "base/strings/string_util.h" | 34 #include "base/strings/string_util.h" |
| 34 #include "base/strings/sys_string_conversions.h" | 35 #include "base/strings/sys_string_conversions.h" |
| 35 #include "base/strings/utf_string_conversions.h" | 36 #include "base/strings/utf_string_conversions.h" |
| 36 #include "base/time/time.h" | 37 #include "base/time/time.h" |
| 37 #include "base/values.h" | 38 #include "base/values.h" |
| 38 #include "components/url_formatter/url_formatter.h" | 39 #include "components/url_formatter/url_formatter.h" |
| 39 #import "ios/net/http_response_headers_util.h" | 40 #import "ios/net/http_response_headers_util.h" |
| 40 #import "ios/net/nsurlrequest_util.h" | 41 #import "ios/net/nsurlrequest_util.h" |
| 41 #include "ios/public/provider/web/web_ui_ios.h" | 42 #include "ios/public/provider/web/web_ui_ios.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 55 #include "ios/web/public/cert_store.h" | 56 #include "ios/web/public/cert_store.h" |
| 56 #include "ios/web/public/favicon_url.h" | 57 #include "ios/web/public/favicon_url.h" |
| 57 #include "ios/web/public/navigation_item.h" | 58 #include "ios/web/public/navigation_item.h" |
| 58 #import "ios/web/public/navigation_manager.h" | 59 #import "ios/web/public/navigation_manager.h" |
| 59 #import "ios/web/public/origin_util.h" | 60 #import "ios/web/public/origin_util.h" |
| 60 #include "ios/web/public/referrer.h" | 61 #include "ios/web/public/referrer.h" |
| 61 #include "ios/web/public/referrer_util.h" | 62 #include "ios/web/public/referrer_util.h" |
| 62 #include "ios/web/public/ssl_status.h" | 63 #include "ios/web/public/ssl_status.h" |
| 63 #import "ios/web/public/url_scheme_util.h" | 64 #import "ios/web/public/url_scheme_util.h" |
| 64 #include "ios/web/public/url_util.h" | 65 #include "ios/web/public/url_util.h" |
| 65 #include "ios/web/public/user_metrics.h" | |
| 66 #include "ios/web/public/web_client.h" | 66 #include "ios/web/public/web_client.h" |
| 67 #include "ios/web/public/web_kit_constants.h" | 67 #include "ios/web/public/web_kit_constants.h" |
| 68 #import "ios/web/public/web_state/context_menu_params.h" | 68 #import "ios/web/public/web_state/context_menu_params.h" |
| 69 #include "ios/web/public/web_state/credential.h" | 69 #include "ios/web/public/web_state/credential.h" |
| 70 #import "ios/web/public/web_state/crw_web_controller_observer.h" | 70 #import "ios/web/public/web_state/crw_web_controller_observer.h" |
| 71 #import "ios/web/public/web_state/crw_web_view_scroll_view_proxy.h" | 71 #import "ios/web/public/web_state/crw_web_view_scroll_view_proxy.h" |
| 72 #import "ios/web/public/web_state/js/credential_util.h" | 72 #import "ios/web/public/web_state/js/credential_util.h" |
| 73 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" | 73 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" |
| 74 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" | 74 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" |
| 75 #include "ios/web/public/web_state/page_display_state.h" | 75 #include "ios/web/public/web_state/page_display_state.h" |
| (...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 } | 2128 } |
| 2129 | 2129 |
| 2130 // Reload either the web view or the native content depending on which is | 2130 // Reload either the web view or the native content depending on which is |
| 2131 // displayed. | 2131 // displayed. |
| 2132 - (void)reloadInternal { | 2132 - (void)reloadInternal { |
| 2133 // Clear last user interaction. | 2133 // Clear last user interaction. |
| 2134 // TODO(crbug.com/546337): Move to after the load commits, in the subclass | 2134 // TODO(crbug.com/546337): Move to after the load commits, in the subclass |
| 2135 // implementation. This will be inaccurate if the reload fails or is | 2135 // implementation. This will be inaccurate if the reload fails or is |
| 2136 // cancelled. | 2136 // cancelled. |
| 2137 _lastUserInteraction.reset(); | 2137 _lastUserInteraction.reset(); |
| 2138 web::RecordAction(UserMetricsAction("Reload")); | 2138 base::RecordAction(UserMetricsAction("Reload")); |
| 2139 if (_webView) { | 2139 if (_webView) { |
| 2140 web::NavigationItem* transientItem = | 2140 web::NavigationItem* transientItem = |
| 2141 _webStateImpl->GetNavigationManagerImpl().GetTransientItem(); | 2141 _webStateImpl->GetNavigationManagerImpl().GetTransientItem(); |
| 2142 if (transientItem) { | 2142 if (transientItem) { |
| 2143 // If there's a transient item, a reload is considered a new navigation to | 2143 // If there's a transient item, a reload is considered a new navigation to |
| 2144 // the transient item's URL (as on other platforms). | 2144 // the transient item's URL (as on other platforms). |
| 2145 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL()); | 2145 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL()); |
| 2146 reloadParams.transition_type = ui::PAGE_TRANSITION_RELOAD; | 2146 reloadParams.transition_type = ui::PAGE_TRANSITION_RELOAD; |
| 2147 reloadParams.extra_headers.reset( | 2147 reloadParams.extra_headers.reset( |
| 2148 [transientItem->GetHttpRequestHeaders() copy]); | 2148 [transientItem->GetHttpRequestHeaders() copy]); |
| (...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4760 [self loadHTML:HTML forURL:URL]; | 4760 [self loadHTML:HTML forURL:URL]; |
| 4761 } | 4761 } |
| 4762 | 4762 |
| 4763 - (void)loadHTMLForCurrentURL:(NSString*)HTML { | 4763 - (void)loadHTMLForCurrentURL:(NSString*)HTML { |
| 4764 [self loadHTML:HTML forURL:self.currentURL]; | 4764 [self loadHTML:HTML forURL:self.currentURL]; |
| 4765 } | 4765 } |
| 4766 | 4766 |
| 4767 - (void)stopLoading { | 4767 - (void)stopLoading { |
| 4768 _stoppedWKNavigation.reset(_latestWKNavigation); | 4768 _stoppedWKNavigation.reset(_latestWKNavigation); |
| 4769 | 4769 |
| 4770 web::RecordAction(UserMetricsAction("Stop")); | 4770 base::RecordAction(UserMetricsAction("Stop")); |
| 4771 // Discard the pending and transient entried before notifying the tab model | 4771 // Discard the pending and transient entried before notifying the tab model |
| 4772 // observers of the change via |-abortLoad|. | 4772 // observers of the change via |-abortLoad|. |
| 4773 [[self sessionController] discardNonCommittedEntries]; | 4773 [[self sessionController] discardNonCommittedEntries]; |
| 4774 [self abortLoad]; | 4774 [self abortLoad]; |
| 4775 // If discarding the non-committed entries results in an app-specific URL, | 4775 // If discarding the non-committed entries results in an app-specific URL, |
| 4776 // reload it in its native view. | 4776 // reload it in its native view. |
| 4777 if (!self.nativeController && | 4777 if (!self.nativeController && |
| 4778 [self shouldLoadURLInNativeView:[self currentNavigationURL]]) { | 4778 [self shouldLoadURLInNativeView:[self currentNavigationURL]]) { |
| 4779 [self loadCurrentURLInNativeView]; | 4779 [self loadCurrentURLInNativeView]; |
| 4780 } | 4780 } |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5587 } | 5587 } |
| 5588 | 5588 |
| 5589 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5589 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5590 } | 5590 } |
| 5591 | 5591 |
| 5592 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5592 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5593 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5593 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5594 } | 5594 } |
| 5595 | 5595 |
| 5596 @end | 5596 @end |
| OLD | NEW |