OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ui_web_view_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_ui_web_view_web_controller.h" |
6 | 6 |
| 7 #import "base/ios/ns_error_util.h" |
7 #import "base/ios/weak_nsobject.h" | 8 #import "base/ios/weak_nsobject.h" |
8 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
9 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
10 #include "base/mac/bind_objc_block.h" | 11 #include "base/mac/bind_objc_block.h" |
11 #import "base/mac/scoped_nsobject.h" | 12 #import "base/mac/scoped_nsobject.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
(...skipping 11 matching lines...) Expand all Loading... |
28 #import "ios/web/ui_web_view_util.h" | 29 #import "ios/web/ui_web_view_util.h" |
29 #include "ios/web/web_state/frame_info.h" | 30 #include "ios/web/web_state/frame_info.h" |
30 #import "ios/web/web_state/js/crw_js_invoke_parameter_queue.h" | 31 #import "ios/web/web_state/js/crw_js_invoke_parameter_queue.h" |
31 #import "ios/web/web_state/ui/crw_context_menu_provider.h" | 32 #import "ios/web/web_state/ui/crw_context_menu_provider.h" |
32 #import "ios/web/web_state/ui/crw_web_controller+protected.h" | 33 #import "ios/web/web_state/ui/crw_web_controller+protected.h" |
33 #import "ios/web/web_state/ui/crw_web_controller.h" | 34 #import "ios/web/web_state/ui/crw_web_controller.h" |
34 #import "ios/web/web_state/ui/web_view_js_utils.h" | 35 #import "ios/web/web_state/ui/web_view_js_utils.h" |
35 #import "ios/web/web_state/web_state_impl.h" | 36 #import "ios/web/web_state/web_state_impl.h" |
36 #import "ios/web/web_state/web_view_internal_creation_util.h" | 37 #import "ios/web/web_state/web_view_internal_creation_util.h" |
37 #import "net/base/mac/url_conversions.h" | 38 #import "net/base/mac/url_conversions.h" |
| 39 #include "net/base/net_errors.h" |
38 #include "url/url_constants.h" | 40 #include "url/url_constants.h" |
39 | 41 |
40 namespace web { | 42 namespace web { |
41 | 43 |
42 // The following continuous check timer frequency constants are externally | 44 // The following continuous check timer frequency constants are externally |
43 // available for the purpose of performance tests. | 45 // available for the purpose of performance tests. |
44 // Frequency for the continuous checks when a reset in the page object is | 46 // Frequency for the continuous checks when a reset in the page object is |
45 // anticipated shortly. In milliseconds. | 47 // anticipated shortly. In milliseconds. |
46 const int64 kContinuousCheckIntervalMSHigh = 100; | 48 const int64 kContinuousCheckIntervalMSHigh = 100; |
47 | 49 |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 ? zoomState.zoom_scale() | 799 ? zoomState.zoom_scale() |
798 : self.webScrollView.minimumZoomScale / | 800 : self.webScrollView.minimumZoomScale / |
799 zoomState.minimum_zoom_scale(); | 801 zoomState.minimum_zoom_scale(); |
800 if (zoomScale < self.webScrollView.minimumZoomScale) | 802 if (zoomScale < self.webScrollView.minimumZoomScale) |
801 zoomScale = self.webScrollView.minimumZoomScale; | 803 zoomScale = self.webScrollView.minimumZoomScale; |
802 if (zoomScale > self.webScrollView.maximumZoomScale) | 804 if (zoomScale > self.webScrollView.maximumZoomScale) |
803 zoomScale = self.webScrollView.maximumZoomScale; | 805 zoomScale = self.webScrollView.maximumZoomScale; |
804 self.webScrollView.zoomScale = zoomScale; | 806 self.webScrollView.zoomScale = zoomScale; |
805 } | 807 } |
806 | 808 |
807 -(BOOL)shouldAbortLoadForCancelledURL:(const GURL&)cancelledURL { | 809 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)cancelledError { |
808 return YES; | 810 // NSURLErrorCancelled errors generated by the Chrome net stack should be |
| 811 // aborted. If the error was generated by the UIWebView, it will not have |
| 812 // an underlying net error and will be automatically retried by the web view. |
| 813 DCHECK_EQ(cancelledError.code, NSURLErrorCancelled); |
| 814 NSError* underlyingError = |
| 815 base::ios::GetFinalUnderlyingErrorFromError(cancelledError); |
| 816 NSString* netDomain = base::SysUTF8ToNSString(net::kErrorDomain); |
| 817 return [underlyingError.domain isEqualToString:netDomain]; |
809 } | 818 } |
810 | 819 |
811 #pragma mark - JS to ObjC messaging | 820 #pragma mark - JS to ObjC messaging |
812 | 821 |
813 - (void)respondToJSInvoke { | 822 - (void)respondToJSInvoke { |
814 // This call is asynchronous. If the web view has been removed, there is | 823 // This call is asynchronous. If the web view has been removed, there is |
815 // nothing left to do, so just discard the queued messages and return. | 824 // nothing left to do, so just discard the queued messages and return. |
816 if (!self.webView) { | 825 if (!self.webView) { |
817 _jsInvokeParameterQueue.reset([[CRWJSInvokeParameterQueue alloc] init]); | 826 _jsInvokeParameterQueue.reset([[CRWJSInvokeParameterQueue alloc] init]); |
818 return; | 827 return; |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 } | 1490 } |
1482 | 1491 |
1483 #pragma mark - | 1492 #pragma mark - |
1484 #pragma mark Testing methods | 1493 #pragma mark Testing methods |
1485 | 1494 |
1486 -(id<CRWRecurringTaskDelegate>)recurringTaskDelegate { | 1495 -(id<CRWRecurringTaskDelegate>)recurringTaskDelegate { |
1487 return _recurringTaskDelegate; | 1496 return _recurringTaskDelegate; |
1488 } | 1497 } |
1489 | 1498 |
1490 @end | 1499 @end |
OLD | NEW |