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

Unified Diff: components/web_modal/web_contents_modal_dialog_manager.cc

Issue 17500003: Close web contents modal dialogs on content load start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: components/web_modal/web_contents_modal_dialog_manager.cc
diff --git a/components/web_modal/web_contents_modal_dialog_manager.cc b/components/web_modal/web_contents_modal_dialog_manager.cc
index 0e07f8dd1d96cee1aba119f641a82522aa48018c..84d213dc82cf23c4983e55ec9d66a6649988edb4 100644
--- a/components/web_modal/web_contents_modal_dialog_manager.cc
+++ b/components/web_modal/web_contents_modal_dialog_manager.cc
@@ -74,16 +74,19 @@ void WebContentsModalDialogManager::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED);
-
- if (child_dialogs_.empty())
- return;
-
- bool visible = *content::Details<bool>(details).ptr();
- if (visible)
- native_manager_->ShowDialog(child_dialogs_.front());
- else
- native_manager_->HideDialog(child_dialogs_.front());
+ if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) {
+ if (child_dialogs_.empty())
+ return;
+
+ bool visible = *content::Details<bool>(details).ptr();
+ if (visible)
+ native_manager_->ShowDialog(child_dialogs_.front());
+ else
+ native_manager_->HideDialog(child_dialogs_.front());
+ } else if (type == content::NOTIFICATION_LOAD_START) {
+ if (!child_dialogs_.empty())
+ native_manager_->CloseDialog(child_dialogs_.front());
+ }
}
WebContentsModalDialogManager::WebContentsModalDialogManager(
@@ -93,6 +96,11 @@ WebContentsModalDialogManager::WebContentsModalDialogManager(
native_manager_(CreateNativeManager(this)),
closing_all_dialogs_(false) {
DCHECK(native_manager_);
+ content::NavigationController* controller =
+ &GetWebContents()->GetController();
+ registrar_.Add(this,
+ content::NOTIFICATION_LOAD_START,
+ content::Source<content::NavigationController>(controller));
registrar_.Add(this,
content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
content::Source<content::WebContents>(web_contents));
@@ -123,16 +131,6 @@ void WebContentsModalDialogManager::CloseAllDialogs() {
closing_all_dialogs_ = false;
}
-void WebContentsModalDialogManager::DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) {
- // Close constrained windows if necessary.
- if (!net::registry_controlled_domains::SameDomainOrHost(
- details.previous_url, details.entry->GetURL(),
- net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES))
- CloseAllDialogs();
-}
-
void WebContentsModalDialogManager::DidGetIgnoredUIEvent() {
if (!child_dialogs_.empty())
native_manager_->FocusDialog(child_dialogs_.front());

Powered by Google App Engine
This is Rietveld 408576698