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

Unified Diff: trunk/src/components/web_modal/web_contents_modal_dialog_manager.cc

Issue 21372006: Revert 212329 "Reland "Close web contents modal dialogs on conte..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « trunk/src/components/web_modal/web_contents_modal_dialog_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/components/web_modal/web_contents_modal_dialog_manager.cc
===================================================================
--- trunk/src/components/web_modal/web_contents_modal_dialog_manager.cc (revision 214772)
+++ trunk/src/components/web_modal/web_contents_modal_dialog_manager.cc (working copy)
@@ -13,6 +13,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
+#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
using content::WebContents;
@@ -26,7 +27,7 @@
void WebContentsModalDialogManager::ShowDialog(
NativeWebContentsModalDialog dialog) {
- child_dialogs_.push_back(DialogState(dialog));
+ child_dialogs_.push_back(dialog);
native_manager_->ManageDialog(dialog);
@@ -43,24 +44,17 @@
void WebContentsModalDialogManager::FocusTopmostDialog() {
DCHECK(!child_dialogs_.empty());
- native_manager_->FocusDialog(child_dialogs_.front().dialog);
+ native_manager_->FocusDialog(child_dialogs_.front());
}
-void WebContentsModalDialogManager::SetPreventCloseOnLoadStart(
- NativeWebContentsModalDialog dialog,
- bool prevent) {
- WebContentsModalDialogList::iterator loc = FindDialogState(dialog);
- DCHECK(loc != child_dialogs_.end());
- loc->prevent_close_on_load_start = true;
-}
-
content::WebContents* WebContentsModalDialogManager::GetWebContents() const {
return web_contents();
}
void WebContentsModalDialogManager::WillClose(
NativeWebContentsModalDialog dialog) {
- WebContentsModalDialogList::iterator i = FindDialogState(dialog);
+ WebContentsModalDialogList::iterator i(
+ std::find(child_dialogs_.begin(), child_dialogs_.end(), dialog));
// The Views tab contents modal dialog calls WillClose twice. Ignore the
// second invocation.
@@ -71,7 +65,7 @@
child_dialogs_.erase(i);
if (!child_dialogs_.empty() && removed_topmost_dialog &&
!closing_all_dialogs_)
- native_manager_->ShowDialog(child_dialogs_.front().dialog);
+ native_manager_->ShowDialog(child_dialogs_.front());
BlockWebContentsInteraction(!child_dialogs_.empty());
}
@@ -80,20 +74,16 @@
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) {
- if (child_dialogs_.empty())
- return;
+ DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED);
- bool visible = *content::Details<bool>(details).ptr();
- if (visible)
- native_manager_->ShowDialog(child_dialogs_.front().dialog);
- else
- native_manager_->HideDialog(child_dialogs_.front().dialog);
- } else if (type == content::NOTIFICATION_LOAD_START) {
- if (!child_dialogs_.empty() &&
- !child_dialogs_.front().prevent_close_on_load_start)
- native_manager_->CloseDialog(child_dialogs_.front().dialog);
- }
+ 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());
}
WebContentsModalDialogManager::WebContentsModalDialogManager(
@@ -103,34 +93,11 @@
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));
}
-WebContentsModalDialogManager::DialogState::DialogState(
- NativeWebContentsModalDialog dialog)
- : dialog(dialog),
- prevent_close_on_load_start(false) {
-}
-
-WebContentsModalDialogManager::WebContentsModalDialogList::iterator
- WebContentsModalDialogManager::FindDialogState(
- NativeWebContentsModalDialog dialog) {
- WebContentsModalDialogList::iterator i;
- for (i = child_dialogs_.begin(); i != child_dialogs_.end(); ++i) {
- if (i->dialog == dialog)
- break;
- }
-
- return i;
-}
-
void WebContentsModalDialogManager::BlockWebContentsInteraction(bool blocked) {
WebContents* contents = web_contents();
if (!contents) {
@@ -151,14 +118,24 @@
// Clear out any dialogs since we are leaving this page entirely.
while (!child_dialogs_.empty())
- native_manager_->CloseDialog(child_dialogs_.front().dialog);
+ native_manager_->CloseDialog(child_dialogs_.front());
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().dialog);
+ native_manager_->FocusDialog(child_dialogs_.front());
}
void WebContentsModalDialogManager::WebContentsDestroyed(WebContents* tab) {
« no previous file with comments | « trunk/src/components/web_modal/web_contents_modal_dialog_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698