diff options
-rw-r--r-- | ios/web/web_state/ui/crw_web_controller.h | 15 | ||||
-rw-r--r-- | ios/web/web_state/ui/crw_web_controller.mm | 12 | ||||
-rw-r--r-- | ios/web/web_state/ui/crw_web_controller_unittest.mm | 18 |
3 files changed, 9 insertions, 36 deletions
diff --git a/ios/web/web_state/ui/crw_web_controller.h b/ios/web/web_state/ui/crw_web_controller.h index 5eef87f..fd9bf7a 100644 --- a/ios/web/web_state/ui/crw_web_controller.h +++ b/ios/web/web_state/ui/crw_web_controller.h @@ -30,15 +30,6 @@ enum LoadPhase { PAGE_LOADED = 2 }; -// Policy for web page dialog handling. -enum PageDialogOpenPolicy { - // Default policy. Dialogs are allowed, clients are not notified on display. - DIALOG_POLICY_ALLOW = 0, - // Dialogs are not allowed, client are notified when dialog did block with - // -[WebDelegate webControllerDidSuppressDialog:] delegate method call. - DIALOG_POLICY_SUPPRESS -}; - // The accessibility identifier of the top-level container view. extern NSString* const kContainerViewID; @@ -240,12 +231,6 @@ class WebStateImpl; // visible only briefly (e.g., tablet side swipe). - (void)setOverlayPreviewMode:(BOOL)overlayPreviewMode; -// Sets policy for web page dialog handling. Controls dialog suppression and -// notifying the WebDelegate. -// TODO(crbug.com/595463): remove this method, once embedder uses -// |setSuppressDialogs|. -- (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy; - // Records the state (scroll position, form values, whatever can be harvested) // from the current page into the current session entry. - (void)recordStateInHistory; diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm index 12bf6cc..43caea72 100644 --- a/ios/web/web_state/ui/crw_web_controller.mm +++ b/ios/web/web_state/ui/crw_web_controller.mm @@ -3188,18 +3188,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; } } -- (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy { - switch (policy) { - case web::DIALOG_POLICY_ALLOW: - self.shouldSuppressDialogs = NO; - return; - case web::DIALOG_POLICY_SUPPRESS: - self.shouldSuppressDialogs = YES; - return; - } - NOTREACHED(); -} - #pragma mark - #pragma mark Session Information diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm index 31c33f7..dc9e823 100644 --- a/ios/web/web_state/ui/crw_web_controller_unittest.mm +++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm @@ -521,7 +521,7 @@ class CRWWebControllerPageDialogOpenPolicyTest // Tests that window.alert dialog is suppressed for DIALOG_POLICY_SUPPRESS. TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressAlert) { [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_SUPPRESS]; + [webController_ setShouldSuppressDialogs:YES]; EvaluateJavaScriptAsString(@"alert('test')"); }; @@ -542,14 +542,14 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowAlert) { completion_handler(); }]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_ALLOW]; + [webController_ setShouldSuppressDialogs:NO]; EvaluateJavaScriptAsString(@"alert('test')"); }; // Tests that window.confirm dialog is suppressed for DIALOG_POLICY_SUPPRESS. TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressConfirm) { [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_SUPPRESS]; + [webController_ setShouldSuppressDialogs:YES]; EXPECT_NSEQ(@"false", EvaluateJavaScriptAsString(@"confirm('test')")); }; @@ -572,7 +572,7 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithTrue) { callable_block(YES); }]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_ALLOW]; + [webController_ setShouldSuppressDialogs:NO]; EXPECT_NSEQ(@"true", EvaluateJavaScriptAsString(@"confirm('test')")); } @@ -595,14 +595,14 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithFalse) { callable_block(NO); }]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_ALLOW]; + [webController_ setShouldSuppressDialogs:NO]; EXPECT_NSEQ(@"false", EvaluateJavaScriptAsString(@"confirm('test')")); } // Tests that window.prompt dialog is suppressed for DIALOG_POLICY_SUPPRESS. TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressPrompt) { [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_SUPPRESS]; + [webController_ setShouldSuppressDialogs:YES]; EXPECT_NSEQ(@"", EvaluateJavaScriptAsString(@"prompt('Yes?', 'No')")); } @@ -626,21 +626,21 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowPrompt) { callable_block(@"Maybe"); }]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_ALLOW]; + [webController_ setShouldSuppressDialogs:NO]; EXPECT_NSEQ(@"Maybe", EvaluateJavaScriptAsString(@"prompt('Yes?', 'No')")); } // Tests that geolocation dialog is suppressed for DIALOG_POLICY_SUPPRESS. TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressGeolocation) { [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_SUPPRESS]; + [webController_ setShouldSuppressDialogs:YES]; EvaluateJavaScriptAsString(@"navigator.geolocation.getCurrentPosition()"); } // Tests that window.open is suppressed for DIALOG_POLICY_SUPPRESS. TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressWindowOpen) { [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_]; - [webController_ setPageDialogOpenPolicy:web::DIALOG_POLICY_SUPPRESS]; + [webController_ setShouldSuppressDialogs:YES]; EvaluateJavaScriptAsString(@"window.open('')"); } |