From f16be8da70a1ef247a9e2a8a4c063b58f419a498 Mon Sep 17 00:00:00 2001
From: "wittman@chromium.org"
 <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Fri, 25 Oct 2013 01:15:52 +0000
Subject: Close Views web contents modal dialogs on interstitial pages by
 default

All Views web contents modal dialogs have been configured to close on
interstitial pages (e.g. SSL errors) for a while now without issue. This
changes the default to close the dialogs so that each dialog doesn't
have to explicitly specify.

Also change the name of the function, since the interstitial pages are
not technically WebUI, but a blink-generated interstitial page.

BUG=295897

Review URL: https://codereview.chromium.org/35153011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230893 0039d316-1c4b-4281-b951-d872f2087c98
---
 components/web_modal/web_contents_modal_dialog_manager.cc | 11 +++++++++--
 components/web_modal/web_contents_modal_dialog_manager.h  |  4 ++--
 .../web_contents_modal_dialog_manager_unittest.cc         | 15 ++++++++++-----
 3 files changed, 21 insertions(+), 9 deletions(-)

(limited to 'components/web_modal')

diff --git a/components/web_modal/web_contents_modal_dialog_manager.cc b/components/web_modal/web_contents_modal_dialog_manager.cc
index f454445..85b0448 100644
--- a/components/web_modal/web_contents_modal_dialog_manager.cc
+++ b/components/web_modal/web_contents_modal_dialog_manager.cc
@@ -51,7 +51,7 @@ void WebContentsModalDialogManager::FocusTopmostDialog() {
   native_manager_->FocusDialog(child_dialogs_.front().dialog);
 }
 
-void WebContentsModalDialogManager::SetCloseOnInterstitialWebUI(
+void WebContentsModalDialogManager::SetCloseOnInterstitialPage(
     NativeWebContentsModalDialog dialog,
     bool close) {
   WebContentsModalDialogList::iterator loc = FindDialogState(dialog);
@@ -93,7 +93,14 @@ WebContentsModalDialogManager::WebContentsModalDialogManager(
 WebContentsModalDialogManager::DialogState::DialogState(
     NativeWebContentsModalDialog dialog)
     : dialog(dialog),
-      close_on_interstitial_webui(false) {
+#if defined(OS_WIN) || defined(USE_AURA)
+      close_on_interstitial_webui(true)
+#else
+      // TODO(wittman): Test that closing on interstitial webui works properly
+      // on Mac and use the true default for all platforms.
+      close_on_interstitial_webui(false)
+#endif
+                                         {
 }
 
 WebContentsModalDialogManager::WebContentsModalDialogList::iterator
diff --git a/components/web_modal/web_contents_modal_dialog_manager.h b/components/web_modal/web_contents_modal_dialog_manager.h
index 253de18..dc326741 100644
--- a/components/web_modal/web_contents_modal_dialog_manager.h
+++ b/components/web_modal/web_contents_modal_dialog_manager.h
@@ -43,8 +43,8 @@ class WebContentsModalDialogManager
   void FocusTopmostDialog();
 
   // Set to true to close the window when a page load starts on the WebContents.
-  void SetCloseOnInterstitialWebUI(NativeWebContentsModalDialog dialog,
-                                   bool close);
+  void SetCloseOnInterstitialPage(NativeWebContentsModalDialog dialog,
+                                  bool close);
 
   // Overriden from NativeWebContentsModalDialogManagerDelegate:
   virtual content::WebContents* GetWebContents() const OVERRIDE;
diff --git a/components/web_modal/web_contents_modal_dialog_manager_unittest.cc b/components/web_modal/web_contents_modal_dialog_manager_unittest.cc
index 7095498..1353f10 100644
--- a/components/web_modal/web_contents_modal_dialog_manager_unittest.cc
+++ b/components/web_modal/web_contents_modal_dialog_manager_unittest.cc
@@ -198,9 +198,8 @@ TEST_F(WebContentsModalDialogManagerTest, VisibilityObservation) {
             native_manager->GetDialogState(dialog1));
 }
 
-// Test that attaching an interstitial WebUI page closes dialogs configured to
-// close on interstitial WebUI.
-TEST_F(WebContentsModalDialogManagerTest, InterstitialWebUI) {
+// Test that attaching an interstitial page closes dialogs configured to close.
+TEST_F(WebContentsModalDialogManagerTest, InterstitialPage) {
   const NativeWebContentsModalDialog dialog1 = MakeFakeDialog();
   const NativeWebContentsModalDialog dialog2 = MakeFakeDialog();
   const NativeWebContentsModalDialog dialog3 = MakeFakeDialog();
@@ -209,8 +208,14 @@ TEST_F(WebContentsModalDialogManagerTest, InterstitialWebUI) {
   manager->ShowDialog(dialog2);
   manager->ShowDialog(dialog3);
 
-  manager->SetCloseOnInterstitialWebUI(dialog1, true);
-  manager->SetCloseOnInterstitialWebUI(dialog3, true);
+#if defined(OS_WIN) || defined(USE_AURA)
+  manager->SetCloseOnInterstitialPage(dialog2, false);
+#else
+  // TODO(wittman): Remove this section once Mac is changed to close on
+  // interstitial pages by default.
+  manager->SetCloseOnInterstitialPage(dialog1, true);
+  manager->SetCloseOnInterstitialPage(dialog3, true);
+#endif
 
   test_api->DidAttachInterstitialPage();
   EXPECT_EQ(TestNativeWebContentsModalDialogManager::CLOSED,
-- 
cgit v1.1