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 <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 | 159 |
| 160 // All user gestures are handled by a subview of web view scroll view | 160 // All user gestures are handled by a subview of web view scroll view |
| 161 // (UIWebBrowserView for UIWebView and WKContentView for WKWebView). | 161 // (UIWebBrowserView for UIWebView and WKContentView for WKWebView). |
| 162 for (UIView* subview in web_scroll_view.subviews) { | 162 for (UIView* subview in web_scroll_view.subviews) { |
| 163 for (UIGestureRecognizer* recognizer in subview.gestureRecognizers) { | 163 for (UIGestureRecognizer* recognizer in subview.gestureRecognizers) { |
| 164 CancelTouches(recognizer); | 164 CancelTouches(recognizer); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Key of the UMA Navigation.IOSWKWebViewSlowFastBackForward histogram. | |
| 170 const char kUMAWKWebViewSlowFastBackForwardNavigationKey[] = | |
| 171 "Navigation.IOSWKWebViewSlowFastBackForward"; | |
| 172 | |
| 173 // Values for the histogram that counts slow/fast back/forward navigations. | |
| 174 enum BackForwardNavigationType { | |
| 175 // Fast back navigation through WKWebView back-forward list. | |
| 176 FAST_BACK = 0, | |
|
Eugene But (OOO till 7-30)
2016/01/20 16:45:04
Back usually means previous (not negative delta),
stkhapugin
2016/01/21 10:39:36
Stuart mentioned that he'd like to have a distinct
Eugene But (OOO till 7-30)
2016/01/21 15:03:49
The problem here is that FAST_BACK is misleading,
stuartmorgan
2016/01/28 23:25:44
By "negative delta" do you mean going back N>1 pag
| |
| 177 // Slow back navigation when back-forward list navigation is not possible. | |
| 178 SLOW_BACK, | |
| 179 // Fast forward navigation through WKWebView back-forward list. | |
| 180 FAST_FORWARD, | |
| 181 // Slow forward navigation when back-forward list navigation is not possible. | |
| 182 SLOW_FORWARD, | |
| 183 BACK_FORWARD_NAVIGATION_TYPE_COUNT | |
| 184 }; | |
| 185 | |
| 169 } // namespace | 186 } // namespace |
| 170 | 187 |
| 171 @interface CRWWebController () <CRWNativeContentDelegate, | 188 @interface CRWWebController () <CRWNativeContentDelegate, |
| 172 CRWWebControllerContainerViewDelegate, | 189 CRWWebControllerContainerViewDelegate, |
| 173 CRWWebViewScrollViewProxyObserver> { | 190 CRWWebViewScrollViewProxyObserver> { |
| 174 base::WeakNSProtocol<id<CRWWebDelegate>> _delegate; | 191 base::WeakNSProtocol<id<CRWWebDelegate>> _delegate; |
| 175 base::WeakNSProtocol<id<CRWWebUserInterfaceDelegate>> _UIDelegate; | 192 base::WeakNSProtocol<id<CRWWebUserInterfaceDelegate>> _UIDelegate; |
| 176 base::WeakNSProtocol<id<CRWNativeContentProvider>> _nativeProvider; | 193 base::WeakNSProtocol<id<CRWNativeContentProvider>> _nativeProvider; |
| 177 base::WeakNSProtocol<id<CRWSwipeRecognizerProvider>> _swipeRecognizerProvider; | 194 base::WeakNSProtocol<id<CRWSwipeRecognizerProvider>> _swipeRecognizerProvider; |
| 178 // The CRWWebViewProxy is the wrapper to give components access to the | 195 // The CRWWebViewProxy is the wrapper to give components access to the |
| (...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1679 self.webStateImpl->GetRequestTracker()->FinishPageLoad( | 1696 self.webStateImpl->GetRequestTracker()->FinishPageLoad( |
| 1680 _URLOnStartLoading, false); | 1697 _URLOnStartLoading, false); |
| 1681 } | 1698 } |
| 1682 [_delegate webLoadCancelled:_URLOnStartLoading]; | 1699 [_delegate webLoadCancelled:_URLOnStartLoading]; |
| 1683 break; | 1700 break; |
| 1684 case web::PAGE_LOADED: | 1701 case web::PAGE_LOADED: |
| 1685 break; | 1702 break; |
| 1686 } | 1703 } |
| 1687 } | 1704 } |
| 1688 | 1705 |
| 1706 - (BOOL)canPerformFastNavigationForSessionEntry:(CRWSessionEntry*)sessionEntry { | |
| 1707 // Should be overriden by subclasses if they support fast navigation. | |
| 1708 return NO; | |
| 1709 } | |
| 1710 | |
| 1689 - (void)abortLoad { | 1711 - (void)abortLoad { |
| 1690 [self abortWebLoad]; | 1712 [self abortWebLoad]; |
| 1691 [self loadCancelled]; | 1713 [self loadCancelled]; |
| 1692 } | 1714 } |
| 1693 | 1715 |
| 1694 - (void)prepareForGoBack { | 1716 - (void)prepareForGoBack { |
| 1695 // Make sure any transitions that may have occurred have been seen and acted | 1717 // Make sure any transitions that may have occurred have been seen and acted |
| 1696 // on by the CRWWebController, so the history stack and state of the | 1718 // on by the CRWWebController, so the history stack and state of the |
| 1697 // CRWWebController is 100% up to date before the stack navigation starts. | 1719 // CRWWebController is 100% up to date before the stack navigation starts. |
| 1698 if (self.webView) { | 1720 if (self.webView) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1746 // fromEntry is retained because it has the potential to be released | 1768 // fromEntry is retained because it has the potential to be released |
| 1747 // by goDelta: if it has not been committed. | 1769 // by goDelta: if it has not been committed. |
| 1748 base::scoped_nsobject<CRWSessionEntry> fromEntry( | 1770 base::scoped_nsobject<CRWSessionEntry> fromEntry( |
| 1749 [[sessionController currentEntry] retain]); | 1771 [[sessionController currentEntry] retain]); |
| 1750 [sessionController goDelta:delta]; | 1772 [sessionController goDelta:delta]; |
| 1751 if (fromEntry) { | 1773 if (fromEntry) { |
| 1752 _webStateImpl->SetCacheMode(net::RequestTracker::CACHE_HISTORY); | 1774 _webStateImpl->SetCacheMode(net::RequestTracker::CACHE_HISTORY); |
| 1753 [self finishHistoryNavigationFromEntry:fromEntry]; | 1775 [self finishHistoryNavigationFromEntry:fromEntry]; |
| 1754 _webStateImpl->SetCacheMode(net::RequestTracker::CACHE_NORMAL); | 1776 _webStateImpl->SetCacheMode(net::RequestTracker::CACHE_NORMAL); |
| 1755 } | 1777 } |
| 1778 | |
| 1779 // If using WKWebView, report slow/fast navigation metric. | |
| 1780 if ([self isKindOfClass:[CRWWKWebViewWebController class]]) { | |
|
Eugene But (OOO till 7-30)
2016/01/20 16:45:04
I think you should move this code to subclass' goD
stkhapugin
2016/01/21 10:39:36
Done.
| |
| 1781 BOOL isFast = | |
| 1782 [self canPerformFastNavigationForSessionEntry:self.currentSessionEntry]; | |
| 1783 BOOL isBack = (delta < 0); | |
| 1784 | |
| 1785 BackForwardNavigationType navigationType; | |
|
Eugene But (OOO till 7-30)
2016/01/20 16:45:04
Please always initialize local variables.
stkhapugin
2016/01/21 10:39:36
Done.
| |
| 1786 if (isBack) { | |
| 1787 navigationType = isFast ? BackForwardNavigationType::FAST_BACK | |
| 1788 : BackForwardNavigationType::SLOW_BACK; | |
| 1789 } else { | |
| 1790 navigationType = isFast ? BackForwardNavigationType::FAST_FORWARD | |
| 1791 : BackForwardNavigationType::SLOW_FORWARD; | |
| 1792 } | |
| 1793 | |
| 1794 UMA_HISTOGRAM_ENUMERATION( | |
| 1795 kUMAWKWebViewSlowFastBackForwardNavigationKey, navigationType, | |
| 1796 BackForwardNavigationType::BACK_FORWARD_NAVIGATION_TYPE_COUNT); | |
| 1797 } | |
| 1756 } | 1798 } |
| 1757 | 1799 |
| 1758 - (BOOL)isLoaded { | 1800 - (BOOL)isLoaded { |
| 1759 return _loadPhase == web::PAGE_LOADED; | 1801 return _loadPhase == web::PAGE_LOADED; |
| 1760 } | 1802 } |
| 1761 | 1803 |
| 1762 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess { | 1804 - (void)loadCompleteWithSuccess:(BOOL)loadSuccess { |
| 1763 [self removePlaceholderOverlay]; | 1805 [self removePlaceholderOverlay]; |
| 1764 // The webView may have been torn down (or replaced by a native view). Be | 1806 // The webView may have been torn down (or replaced by a native view). Be |
| 1765 // safe and do nothing if that's happened. | 1807 // safe and do nothing if that's happened. |
| (...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3909 if ([MIMEType isEqualToString:@"text/html"] || | 3951 if ([MIMEType isEqualToString:@"text/html"] || |
| 3910 [MIMEType isEqualToString:@"application/xhtml+xml"] || | 3952 [MIMEType isEqualToString:@"application/xhtml+xml"] || |
| 3911 [MIMEType isEqualToString:@"application/xml"]) { | 3953 [MIMEType isEqualToString:@"application/xml"]) { |
| 3912 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; | 3954 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; |
| 3913 } | 3955 } |
| 3914 | 3956 |
| 3915 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 3957 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 3916 } | 3958 } |
| 3917 | 3959 |
| 3918 @end | 3960 @end |
| OLD | NEW |