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_wk_web_view_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; | 82 const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; |
83 | 83 |
84 // Extracts Referer value from WKNavigationAction request header. | 84 // Extracts Referer value from WKNavigationAction request header. |
85 NSString* GetRefererFromNavigationAction(WKNavigationAction* action) { | 85 NSString* GetRefererFromNavigationAction(WKNavigationAction* action) { |
86 return [action.request valueForHTTPHeaderField:@"Referer"]; | 86 return [action.request valueForHTTPHeaderField:@"Referer"]; |
87 } | 87 } |
88 | 88 |
89 NSString* const kScriptMessageName = @"crwebinvoke"; | 89 NSString* const kScriptMessageName = @"crwebinvoke"; |
90 NSString* const kScriptImmediateName = @"crwebinvokeimmediate"; | 90 NSString* const kScriptImmediateName = @"crwebinvokeimmediate"; |
91 | 91 |
92 // Key of the UMA Navigation.IOSWKWebViewSlowFastBackForward histogram. | |
93 const char kUMAWKWebViewSlowFastBackForwardNavigationKey[] = | |
94 "Navigation.IOSWKWebViewSlowFastBackForward"; | |
95 | |
96 // Values for the histogram that counts slow/fast back/forward navigations. | |
97 enum BackForwardNavigationType { | |
98 // Fast back navigation through WKWebView back-forward list. | |
99 FAST_BACK = 0, | |
100 // Slow back navigation when back-forward list navigation is not possible. | |
101 SLOW_BACK, | |
102 // Fast forward navigation through WKWebView back-forward list. | |
103 FAST_FORWARD, | |
104 // Slow forward navigation when back-forward list navigation is not possible. | |
105 SLOW_FORWARD, | |
106 BACK_FORWARD_NAVIGATION_TYPE_COUNT | |
107 }; | |
108 | |
92 // Utility functions for storing the source of NSErrors received by WKWebViews: | 109 // Utility functions for storing the source of NSErrors received by WKWebViews: |
93 // - Errors received by |-webView:didFailProvisionalNavigation:withError:| are | 110 // - Errors received by |-webView:didFailProvisionalNavigation:withError:| are |
94 // recorded using WKWebViewErrorSource::PROVISIONAL_LOAD. These should be | 111 // recorded using WKWebViewErrorSource::PROVISIONAL_LOAD. These should be |
95 // aborted. | 112 // aborted. |
96 // - Errors received by |-webView:didFailNavigation:withError:| are recorded | 113 // - Errors received by |-webView:didFailNavigation:withError:| are recorded |
97 // using WKWebViewsource::NAVIGATION. These errors should not be aborted, as | 114 // using WKWebViewsource::NAVIGATION. These errors should not be aborted, as |
98 // the WKWebView will automatically retry the load. | 115 // the WKWebView will automatically retry the load. |
99 NSString* const kWKWebViewErrorSourceKey = @"ErrorSource"; | 116 NSString* const kWKWebViewErrorSourceKey = @"ErrorSource"; |
100 typedef enum { NONE = 0, PROVISIONAL_LOAD, NAVIGATION } WKWebViewErrorSource; | 117 typedef enum { NONE = 0, PROVISIONAL_LOAD, NAVIGATION } WKWebViewErrorSource; |
101 NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) { | 118 NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 | 482 |
466 - (void)close { | 483 - (void)close { |
467 [_certVerificationController shutDown]; | 484 [_certVerificationController shutDown]; |
468 [super close]; | 485 [super close]; |
469 } | 486 } |
470 | 487 |
471 - (void)stopLoading { | 488 - (void)stopLoading { |
472 _stoppedWKNavigation.reset(_latestWKNavigation); | 489 _stoppedWKNavigation.reset(_latestWKNavigation); |
473 } | 490 } |
474 | 491 |
492 - (void)goDelta:(int)delta { | |
493 [super goDelta:delta]; | |
494 if (delta != 0) { | |
Eugene But (OOO till 7-30)
2016/01/21 15:03:49
NIT: Please use early return to avoid indentations
stkhapugin
2016/02/05 15:40:15
Done.
| |
495 // Report slow/fast navigation metric. | |
496 web::WKBackForwardListItemHolder* holder = | |
497 web::WKBackForwardListItemHolder::FromNavigationItem( | |
498 self.currentSessionEntry.navigationItemImpl); | |
499 BOOL isFast = | |
500 (holder->back_forward_list_item() && | |
501 [self isBackForwardListItemValid:holder->back_forward_list_item()]); | |
stuartmorgan
2016/01/28 23:25:44
The fact that the logic for measuring fast back/fo
stkhapugin
2016/02/05 15:40:15
Keeping the reported metric as is for now. Please
stuartmorgan
2016/02/08 17:12:52
It's not a question of the divisions in the metric
| |
502 | |
503 BOOL isBack = (delta < 0); | |
504 | |
505 BackForwardNavigationType navigationType = | |
506 BackForwardNavigationType::FAST_BACK; | |
507 if (isBack) { | |
508 navigationType = isFast ? BackForwardNavigationType::FAST_BACK | |
509 : BackForwardNavigationType::SLOW_BACK; | |
510 } else { | |
511 navigationType = isFast ? BackForwardNavigationType::FAST_FORWARD | |
512 : BackForwardNavigationType::SLOW_FORWARD; | |
513 } | |
514 | |
515 UMA_HISTOGRAM_ENUMERATION( | |
516 kUMAWKWebViewSlowFastBackForwardNavigationKey, navigationType, | |
517 BackForwardNavigationType::BACK_FORWARD_NAVIGATION_TYPE_COUNT); | |
518 } | |
519 } | |
520 | |
475 #pragma mark - | 521 #pragma mark - |
476 #pragma mark Testing-Only Methods | 522 #pragma mark Testing-Only Methods |
477 | 523 |
478 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView { | 524 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView { |
479 [super injectWebViewContentView:webViewContentView]; | 525 [super injectWebViewContentView:webViewContentView]; |
480 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)]; | 526 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)]; |
481 } | 527 } |
482 | 528 |
483 #pragma mark - Protected property implementations | 529 #pragma mark - Protected property implementations |
484 | 530 |
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2049 runJavaScriptTextInputPanelWithPrompt:prompt | 2095 runJavaScriptTextInputPanelWithPrompt:prompt |
2050 defaultText:defaultText | 2096 defaultText:defaultText |
2051 requestURL:requestURL | 2097 requestURL:requestURL |
2052 completionHandler:completionHandler]; | 2098 completionHandler:completionHandler]; |
2053 } else if (completionHandler) { | 2099 } else if (completionHandler) { |
2054 completionHandler(nil); | 2100 completionHandler(nil); |
2055 } | 2101 } |
2056 } | 2102 } |
2057 | 2103 |
2058 @end | 2104 @end |
OLD | NEW |