Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2894883004: Removed IsNativeAppLauncherEnabled() experiment (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/public/web_state/ui/crw_web_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item; 748 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item;
749 // Finds all the scrollviews in the view hierarchy and makes sure they do not 749 // Finds all the scrollviews in the view hierarchy and makes sure they do not
750 // interfere with scroll to top when tapping the statusbar. 750 // interfere with scroll to top when tapping the statusbar.
751 - (void)optOutScrollsToTopForSubviews; 751 - (void)optOutScrollsToTopForSubviews;
752 // Tears down the old native controller, and then replaces it with the new one. 752 // Tears down the old native controller, and then replaces it with the new one.
753 - (void)setNativeController:(id<CRWNativeContent>)nativeController; 753 - (void)setNativeController:(id<CRWNativeContent>)nativeController;
754 // Returns whether |url| should be opened. 754 // Returns whether |url| should be opened.
755 - (BOOL)shouldOpenURL:(const GURL&)url 755 - (BOOL)shouldOpenURL:(const GURL&)url
756 mainDocumentURL:(const GURL&)mainDocumentURL 756 mainDocumentURL:(const GURL&)mainDocumentURL
757 linkClicked:(BOOL)linkClicked; 757 linkClicked:(BOOL)linkClicked;
758 // Called when |URL| needs to be opened in a matching native app.
759 // Returns YES if the url was succesfully opened in the native app.
760 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)URL
761 sourceURL:(const GURL&)sourceURL
762 linkActivatedNavigation:(BOOL)linkActivatedNavigation;
763 // Returns YES if the navigation action is associated with a main frame request. 758 // Returns YES if the navigation action is associated with a main frame request.
764 - (BOOL)isMainFrameNavigationAction:(WKNavigationAction*)action; 759 - (BOOL)isMainFrameNavigationAction:(WKNavigationAction*)action;
765 // Returns whether external URL navigation action should be opened. 760 // Returns whether external URL navigation action should be opened.
766 - (BOOL)shouldOpenExternalURLForNavigationAction:(WKNavigationAction*)action; 761 - (BOOL)shouldOpenExternalURLForNavigationAction:(WKNavigationAction*)action;
767 // Returns the header height. 762 // Returns the header height.
768 - (CGFloat)headerHeight; 763 - (CGFloat)headerHeight;
769 // Updates SSL status for the current navigation item based on the information 764 // Updates SSL status for the current navigation item based on the information
770 // provided by web view. 765 // provided by web view.
771 - (void)updateSSLStatusForCurrentNavigationItem; 766 - (void)updateSSLStatusForCurrentNavigationItem;
772 // Called when a load ends in an SSL error and certificate chain. 767 // Called when a load ends in an SSL error and certificate chain.
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 DCHECK_EQ(1u, [cookieKeys count]); 2935 DCHECK_EQ(1u, [cookieKeys count]);
2941 item->RemoveHttpRequestHeaderForKey([cookieKeys anyObject]); 2936 item->RemoveHttpRequestHeaderForKey([cookieKeys anyObject]);
2942 } 2937 }
2943 } 2938 }
2944 } 2939 }
2945 2940
2946 // TODO(stuartmorgan): This is mostly logic from the original UIWebView delegate 2941 // TODO(stuartmorgan): This is mostly logic from the original UIWebView delegate
2947 // method, which provides less information than the WKWebView version. Audit 2942 // method, which provides less information than the WKWebView version. Audit
2948 // this for things that should be handled in the subclass instead. 2943 // this for things that should be handled in the subclass instead.
2949 - (BOOL)shouldAllowLoadWithNavigationAction:(WKNavigationAction*)action { 2944 - (BOOL)shouldAllowLoadWithNavigationAction:(WKNavigationAction*)action {
2950 NSURLRequest* request = action.request;
2951 GURL requestURL = net::GURLWithNSURL(request.URL);
2952
2953 // External application launcher needs |isNavigationTypeLinkActivated| to 2945 // External application launcher needs |isNavigationTypeLinkActivated| to
2954 // decide if the user intended to open the application by clicking on a link. 2946 // decide if the user intended to open the application by clicking on a link.
2955 BOOL isNavigationTypeLinkActivated = 2947 BOOL isNavigationTypeLinkActivated =
2956 action.navigationType == WKNavigationTypeLinkActivated; 2948 action.navigationType == WKNavigationTypeLinkActivated;
2957 2949
2958 // Checks if the link navigation leads to a launch of an external app.
2959 // TODO(crbug.com/704417): External apps will not be launched from clicking
2960 // a Bookmarked URL or a Recently Closed URL.
2961 // TODO(crbug.com/607780): Revise the logic of allowing external app launch
2962 // and move it to externalAppLauncher.
2963 BOOL isOpenInNewTabNavigation = !(self.navigationManagerImpl->GetItemCount());
2964 BOOL isPossibleLinkClick = [self isLinkNavigation:action.navigationType];
2965 if (isPossibleLinkClick || isOpenInNewTabNavigation) {
2966 web::NavigationItem* item = self.currentNavItem;
2967 const GURL currentNavigationURL =
2968 item ? item->GetVirtualURL() : GURL::EmptyGURL();
2969 // Check If the URL is handled by a native app.
2970 if ([self urlTriggersNativeAppLaunch:requestURL
2971 sourceURL:currentNavigationURL
2972 linkActivatedNavigation:isNavigationTypeLinkActivated]) {
2973 // External app has been launched successfully. Stop the current page
2974 // load operation (e.g. notifying all observers) and record the URL so
2975 // that errors reported following the 'NO' reply can be safely ignored.
2976 if ([self shouldClosePageOnNativeApplicationLoad])
2977 _webStateImpl->CloseWebState();
2978 [self stopLoading];
2979 [_openedApplicationURL addObject:request.URL];
2980 return NO;
2981 }
2982 }
2983
2984 // The WebDelegate may instruct the CRWWebController to stop loading, and 2950 // The WebDelegate may instruct the CRWWebController to stop loading, and
2985 // instead instruct the next page to be loaded in an animation. 2951 // instead instruct the next page to be loaded in an animation.
2952 NSURLRequest* request = action.request;
2953 GURL requestURL = net::GURLWithNSURL(request.URL);
2986 GURL mainDocumentURL = net::GURLWithNSURL(request.mainDocumentURL); 2954 GURL mainDocumentURL = net::GURLWithNSURL(request.mainDocumentURL);
2955 BOOL isPossibleLinkClick = [self isLinkNavigation:action.navigationType];
2987 DCHECK(_webView); 2956 DCHECK(_webView);
2988 if (![self shouldOpenURL:requestURL 2957 if (![self shouldOpenURL:requestURL
2989 mainDocumentURL:mainDocumentURL 2958 mainDocumentURL:mainDocumentURL
2990 linkClicked:isPossibleLinkClick]) { 2959 linkClicked:isPossibleLinkClick]) {
2991 return NO; 2960 return NO;
2992 } 2961 }
2993 2962
2994 // If the URL doesn't look like one we can show, try to open the link with an 2963 // If the URL doesn't look like one we can show, try to open the link with an
2995 // external application. 2964 // external application.
2996 // TODO(droger): Check transition type before opening an external 2965 // TODO(droger): Check transition type before opening an external
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
3814 if (requestStatus == SUBFRAME_BLOCKED) { 3783 if (requestStatus == SUBFRAME_BLOCKED) {
3815 return NO; 3784 return NO;
3816 } 3785 }
3817 3786
3818 GURL requestURL = net::GURLWithNSURL(action.request.URL); 3787 GURL requestURL = net::GURLWithNSURL(action.request.URL);
3819 return [_delegate respondsToSelector:@selector(webController: 3788 return [_delegate respondsToSelector:@selector(webController:
3820 shouldOpenExternalURL:)] && 3789 shouldOpenExternalURL:)] &&
3821 [_delegate webController:self shouldOpenExternalURL:requestURL]; 3790 [_delegate webController:self shouldOpenExternalURL:requestURL];
3822 } 3791 }
3823 3792
3824 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)URL
3825 sourceURL:(const GURL&)sourceURL
3826 linkActivatedNavigation:(BOOL)linkActivatedNavigation {
3827 if (![_delegate respondsToSelector:@selector(urlTriggersNativeAppLaunch:
3828 sourceURL:
3829 linkClicked:)]) {
3830 return NO;
3831 }
3832 return [_delegate urlTriggersNativeAppLaunch:URL
3833 sourceURL:sourceURL
3834 linkClicked:linkActivatedNavigation];
3835 }
3836
3837 - (CGFloat)headerHeight { 3793 - (CGFloat)headerHeight {
3838 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) 3794 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)])
3839 return 0.0f; 3795 return 0.0f;
3840 return [_delegate headerHeightForWebController:self]; 3796 return [_delegate headerHeightForWebController:self];
3841 } 3797 }
3842 3798
3843 - (void)updateSSLStatusForCurrentNavigationItem { 3799 - (void)updateSSLStatusForCurrentNavigationItem {
3844 if (_isBeingDestroyed) { 3800 if (_isBeingDestroyed) {
3845 return; 3801 return;
3846 } 3802 }
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
5219 - (NSUInteger)observerCount { 5175 - (NSUInteger)observerCount {
5220 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5176 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5221 return [_observers count]; 5177 return [_observers count];
5222 } 5178 }
5223 5179
5224 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5180 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5225 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5181 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5226 } 5182 }
5227 5183
5228 @end 5184 @end
OLDNEW
« no previous file with comments | « ios/web/public/web_state/ui/crw_web_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698