diff options
author | wittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 10:46:10 +0000 |
---|---|---|
committer | wittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 10:46:10 +0000 |
commit | d494302fa6af992c43d9447b6f594b26140fe142 (patch) | |
tree | 4dc7a7b8ee2a90a462abd71fae4f3822e35fe0be /components/web_modal | |
parent | fc38a0027c65756ea4474d5d990d31e306af8d3f (diff) | |
download | chromium_src-d494302fa6af992c43d9447b6f594b26140fe142.zip chromium_src-d494302fa6af992c43d9447b6f594b26140fe142.tar.gz chromium_src-d494302fa6af992c43d9447b6f594b26140fe142.tar.bz2 |
Close web contents modal dialogs on content load start
Address the failure of some web contents modal dialogs to close when
interstitial WebUI is displayed by closing the dialogs on content load start.
Remove existing ad hoc support in dialogs for closing on page loading in favor
of a uniform approach.
I'm using load start as the trigger for dialog close as this seems to be the
point in time at which the user first perceives the page to be changing.
Notes on the print preview changes: with this change the dialog is closed when
load starts and the initiator tab gets removed via RemovePreviewDialog, so there
is no longer a need to handle NOTIFICATION_NAV_ENTRY_COMITTED for the initiator
tab. The PrintViewManager::PrintPreviewDone() DCHECK is removed since now
PrintViewManager::RenderViewGone() may be invoked and print_preview_state_ reset
due to WebContents closure before the dialog is destroyed and PrintPreviewDone()
is invoked.
BUG=240575
Review URL: https://chromiumcodereview.appspot.com/17500003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211058 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/web_modal')
-rw-r--r-- | components/web_modal/web_contents_modal_dialog_manager.cc | 38 | ||||
-rw-r--r-- | components/web_modal/web_contents_modal_dialog_manager.h | 3 |
2 files changed, 18 insertions, 23 deletions
diff --git a/components/web_modal/web_contents_modal_dialog_manager.cc b/components/web_modal/web_contents_modal_dialog_manager.cc index 0e07f8d..84d213d 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()); diff --git a/components/web_modal/web_contents_modal_dialog_manager.h b/components/web_modal/web_contents_modal_dialog_manager.h index e2548c0..a168693 100644 --- a/components/web_modal/web_contents_modal_dialog_manager.h +++ b/components/web_modal/web_contents_modal_dialog_manager.h @@ -87,9 +87,6 @@ class WebContentsModalDialogManager void CloseAllDialogs(); // Overridden from content::WebContentsObserver: - virtual void DidNavigateMainFrame( - const content::LoadCommittedDetails& details, - const content::FrameNavigateParams& params) OVERRIDE; virtual void DidGetIgnoredUIEvent() OVERRIDE; virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |