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

Unified Diff: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm

Issue 1806043004: [ios] Refactored dialogs suppression. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
index 0d481bbf7272a6abd8d98425dabfbaafa0e9dedc..8d79c34c30f7c26fe1b05c46fcc8defb014ff13b 100644
--- a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
+++ b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
@@ -457,12 +457,6 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
[super terminateNetworkActivity];
}
-- (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy {
- // TODO(eugenebut): implement dialogs/windows suppression using
- // WKNavigationDelegate methods where possible.
- [super setPageDialogOpenPolicy:policy];
-}
-
- (void)close {
[_certVerificationController shutDown];
[super close];
@@ -697,10 +691,6 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
// Nothing to do.
}
-- (void)setSuppressDialogsWithHelperScript:(NSString*)script {
- [self evaluateJavaScript:script stringResultHandler:nil];
-}
-
- (void)applyWebViewScrollZoomScaleFromZoomState:
(const web::PageZoomState&)zoomState {
// After rendering a web page, WKWebView keeps the |minimumZoomScale| and
@@ -1215,6 +1205,12 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
[space.authenticationMethod isEqual:NSURLAuthenticationMethodNTLM] ||
[space.authenticationMethod isEqual:NSURLAuthenticationMethodHTTPDigest]);
+ if (self.suppressDialogs) {
+ [self didSuppressDialog];
+ completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil);
+ return;
+ }
+
SEL selector = @selector(webController:
runAuthDialogForProtectionSpace:
proposedCredential:
@@ -1981,6 +1977,11 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration
forNavigationAction:(WKNavigationAction*)navigationAction
windowFeatures:(WKWindowFeatures*)windowFeatures {
+ if (self.suppressDialogs) {
+ [self didSuppressDialog];
+ return nil;
+ }
+
GURL requestURL = net::GURLWithNSURL(navigationAction.request.URL);
if (![self userIsInteracting]) {
@@ -2016,6 +2017,12 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
runJavaScriptAlertPanelWithMessage:(NSString*)message
initiatedByFrame:(WKFrameInfo*)frame
completionHandler:(void(^)())completionHandler {
+ if (self.suppressDialogs) {
+ [self didSuppressDialog];
+ completionHandler();
+ return;
+ }
+
SEL alertSelector = @selector(webController:
runJavaScriptAlertPanelWithMessage:
requestURL:
@@ -2035,6 +2042,12 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
initiatedByFrame:(WKFrameInfo*)frame
completionHandler:
(void (^)(BOOL result))completionHandler {
+ if (self.suppressDialogs) {
+ [self didSuppressDialog];
+ completionHandler(NO);
+ return;
+ }
+
SEL confirmationSelector = @selector(webController:
runJavaScriptConfirmPanelWithMessage:
requestURL:
@@ -2056,6 +2069,12 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
initiatedByFrame:(WKFrameInfo*)frame
completionHandler:
(void (^)(NSString *result))completionHandler {
+ if (self.suppressDialogs) {
+ [self didSuppressDialog];
+ completionHandler(nil);
+ return;
+ }
+
SEL textInputSelector = @selector(webController:
runJavaScriptTextInputPanelWithPrompt:
defaultText:

Powered by Google App Engine
This is Rietveld 408576698