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

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

Issue 2616843004: [ios] Removed deprecated methods from CRWWebUserInterfaceDelegate. (Closed)
Patch Set: Created 3 years, 11 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/crw_web_user_interface_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 3854 matching lines...) Expand 10 before | Expand all | Expand 10 after
3865 } 3865 }
3866 3866
3867 #pragma mark - 3867 #pragma mark -
3868 #pragma mark JavaScript Dialog 3868 #pragma mark JavaScript Dialog
3869 3869
3870 - (void)runJavaScriptDialogOfType:(web::JavaScriptDialogType)type 3870 - (void)runJavaScriptDialogOfType:(web::JavaScriptDialogType)type
3871 initiatedByFrame:(WKFrameInfo*)frame 3871 initiatedByFrame:(WKFrameInfo*)frame
3872 message:(NSString*)message 3872 message:(NSString*)message
3873 defaultText:(NSString*)defaultText 3873 defaultText:(NSString*)defaultText
3874 completion:(void (^)(BOOL, NSString*))completionHandler { 3874 completion:(void (^)(BOOL, NSString*))completionHandler {
3875 DCHECK(completionHandler);
3876 if (self.shouldSuppressDialogs) {
3877 [self didSuppressDialog];
3878 completionHandler(NO, nil);
3879 return;
3880 }
3881
3875 self.webStateImpl->RunJavaScriptDialog( 3882 self.webStateImpl->RunJavaScriptDialog(
3876 net::GURLWithNSURL(frame.request.URL), type, message, defaultText, 3883 net::GURLWithNSURL(frame.request.URL), type, message, defaultText,
3877 base::BindBlock(^(bool success, NSString* input) { 3884 base::BindBlock(^(bool success, NSString* input) {
3878 completionHandler(success, input); 3885 completionHandler(success, input);
3879 })); 3886 }));
3880 } 3887 }
3881 3888
3882 #pragma mark - 3889 #pragma mark -
3883 #pragma mark TouchTracking 3890 #pragma mark TouchTracking
3884 3891
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
4940 - (void)webViewDidClose:(WKWebView*)webView { 4947 - (void)webViewDidClose:(WKWebView*)webView {
4941 if (self.sessionController.openedByDOM) { 4948 if (self.sessionController.openedByDOM) {
4942 [self.delegate webPageOrderedClose]; 4949 [self.delegate webPageOrderedClose];
4943 } 4950 }
4944 } 4951 }
4945 4952
4946 - (void)webView:(WKWebView*)webView 4953 - (void)webView:(WKWebView*)webView
4947 runJavaScriptAlertPanelWithMessage:(NSString*)message 4954 runJavaScriptAlertPanelWithMessage:(NSString*)message
4948 initiatedByFrame:(WKFrameInfo*)frame 4955 initiatedByFrame:(WKFrameInfo*)frame
4949 completionHandler:(void (^)())completionHandler { 4956 completionHandler:(void (^)())completionHandler {
4950 if (self.shouldSuppressDialogs) { 4957 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT
4951 [self didSuppressDialog]; 4958 initiatedByFrame:frame
4952 completionHandler(); 4959 message:message
4953 return; 4960 defaultText:nil
4954 } 4961 completion:^(BOOL, NSString*) {
4955 4962 completionHandler();
4956 SEL alertSelector = @selector(webController: 4963 }];
4957 runJavaScriptAlertPanelWithMessage:
4958 requestURL:
4959 completionHandler:);
4960 if ([self.UIDelegate respondsToSelector:alertSelector]) {
4961 [self.UIDelegate webController:self
4962 runJavaScriptAlertPanelWithMessage:message
4963 requestURL:net::GURLWithNSURL(frame.request.URL)
4964 completionHandler:completionHandler];
4965 } else {
4966 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT
4967 initiatedByFrame:frame
4968 message:message
4969 defaultText:nil
4970 completion:^(BOOL, NSString*) {
4971 completionHandler();
4972 }];
4973 }
4974 } 4964 }
4975 4965
4976 - (void)webView:(WKWebView*)webView 4966 - (void)webView:(WKWebView*)webView
4977 runJavaScriptConfirmPanelWithMessage:(NSString*)message 4967 runJavaScriptConfirmPanelWithMessage:(NSString*)message
4978 initiatedByFrame:(WKFrameInfo*)frame 4968 initiatedByFrame:(WKFrameInfo*)frame
4979 completionHandler: 4969 completionHandler:
4980 (void (^)(BOOL result))completionHandler { 4970 (void (^)(BOOL result))completionHandler {
4981 if (self.shouldSuppressDialogs) { 4971 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_CONFIRM
4982 [self didSuppressDialog]; 4972 initiatedByFrame:frame
4983 completionHandler(NO); 4973 message:message
4984 return; 4974 defaultText:nil
4985 } 4975 completion:^(BOOL success, NSString*) {
4986 4976 if (completionHandler) {
4987 SEL confirmationSelector = @selector(webController: 4977 completionHandler(success);
4988 runJavaScriptConfirmPanelWithMessage: 4978 }
4989 requestURL: 4979 }];
4990 completionHandler:);
4991 if ([self.UIDelegate respondsToSelector:confirmationSelector]) {
4992 [self.UIDelegate webController:self
4993 runJavaScriptConfirmPanelWithMessage:message
4994 requestURL:net::GURLWithNSURL(
4995 frame.request.URL)
4996 completionHandler:completionHandler];
4997 } else {
4998 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_CONFIRM
4999 initiatedByFrame:frame
5000 message:message
5001 defaultText:nil
5002 completion:^(BOOL success, NSString*) {
5003 if (completionHandler) {
5004 completionHandler(success);
5005 }
5006 }];
5007 }
5008 } 4980 }
5009 4981
5010 - (void)webView:(WKWebView*)webView 4982 - (void)webView:(WKWebView*)webView
5011 runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt 4983 runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt
5012 defaultText:(NSString*)defaultText 4984 defaultText:(NSString*)defaultText
5013 initiatedByFrame:(WKFrameInfo*)frame 4985 initiatedByFrame:(WKFrameInfo*)frame
5014 completionHandler: 4986 completionHandler:
5015 (void (^)(NSString* result))completionHandler { 4987 (void (^)(NSString* result))completionHandler {
5016 GURL origin(web::GURLOriginWithWKSecurityOrigin(frame.securityOrigin)); 4988 GURL origin(web::GURLOriginWithWKSecurityOrigin(frame.securityOrigin));
5017 if (web::GetWebClient()->IsAppSpecificURL(origin) && _webUIManager) { 4989 if (web::GetWebClient()->IsAppSpecificURL(origin) && _webUIManager) {
5018 std::string mojoResponse = 4990 std::string mojoResponse =
5019 self.mojoFacade->HandleMojoMessage(base::SysNSStringToUTF8(prompt)); 4991 self.mojoFacade->HandleMojoMessage(base::SysNSStringToUTF8(prompt));
5020 completionHandler(base::SysUTF8ToNSString(mojoResponse)); 4992 completionHandler(base::SysUTF8ToNSString(mojoResponse));
5021 return; 4993 return;
5022 } 4994 }
5023 4995
5024 if (self.shouldSuppressDialogs) { 4996 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_PROMPT
5025 [self didSuppressDialog]; 4997 initiatedByFrame:frame
5026 completionHandler(nil); 4998 message:prompt
5027 return; 4999 defaultText:defaultText
5028 } 5000 completion:^(BOOL, NSString* input) {
5029 5001 if (completionHandler) {
5030 SEL textInputSelector = @selector(webController: 5002 completionHandler(input);
5031 runJavaScriptTextInputPanelWithPrompt: 5003 }
5032 defaultText: 5004 }];
5033 requestURL:
5034 completionHandler:);
5035 if ([self.UIDelegate respondsToSelector:textInputSelector]) {
5036 GURL requestURL = net::GURLWithNSURL(frame.request.URL);
5037 [self.UIDelegate webController:self
5038 runJavaScriptTextInputPanelWithPrompt:prompt
5039 defaultText:defaultText
5040 requestURL:requestURL
5041 completionHandler:completionHandler];
5042 } else {
5043 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_PROMPT
5044 initiatedByFrame:frame
5045 message:prompt
5046 defaultText:defaultText
5047 completion:^(BOOL, NSString* input) {
5048 if (completionHandler) {
5049 completionHandler(input);
5050 }
5051 }];
5052 }
5053 } 5005 }
5054 5006
5055 #pragma mark - 5007 #pragma mark -
5056 #pragma mark WKNavigationDelegate Methods 5008 #pragma mark WKNavigationDelegate Methods
5057 5009
5058 - (void)webView:(WKWebView*)webView 5010 - (void)webView:(WKWebView*)webView
5059 decidePolicyForNavigationAction:(WKNavigationAction*)action 5011 decidePolicyForNavigationAction:(WKNavigationAction*)action
5060 decisionHandler: 5012 decisionHandler:
5061 (void (^)(WKNavigationActionPolicy))decisionHandler { 5013 (void (^)(WKNavigationActionPolicy))decisionHandler {
5062 _webProcessIsDead = NO; 5014 _webProcessIsDead = NO;
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
5805 } 5757 }
5806 5758
5807 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5759 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5808 } 5760 }
5809 5761
5810 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5762 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5811 return [action.request valueForHTTPHeaderField:@"Referer"]; 5763 return [action.request valueForHTTPHeaderField:@"Referer"];
5812 } 5764 }
5813 5765
5814 @end 5766 @end
OLDNEW
« no previous file with comments | « ios/web/public/web_state/crw_web_user_interface_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698