summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/background_printing_manager.cc9
-rw-r--r--chrome/browser/printing/print_preview_dialog_controller.cc187
-rw-r--r--chrome/browser/printing/print_preview_dialog_controller.h52
-rw-r--r--chrome/browser/printing/print_preview_dialog_controller_browsertest.cc32
-rw-r--r--chrome/browser/printing/print_preview_dialog_controller_unittest.cc68
-rw-r--r--chrome/browser/printing/print_view_manager.h2
-rw-r--r--chrome/browser/repost_form_warning_controller.cc2
-rw-r--r--chrome/browser/resources/print_preview/native_layer.js12
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc18
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.h7
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm1
-rw-r--r--chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h2
-rw-r--r--chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm8
-rw-r--r--chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h3
-rw-r--r--chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm6
-rw-r--r--chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.cc12
-rw-r--r--chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h5
-rw-r--r--chrome/browser/ui/tab_modal_confirm_dialog.h6
-rw-r--r--chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc16
-rw-r--r--chrome/browser/ui/tab_modal_confirm_dialog_delegate.h24
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.cc2
-rw-r--r--chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc12
-rw-r--r--chrome/browser/ui/views/tab_modal_confirm_dialog_views.h3
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.cc90
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.h8
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui.cc6
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui.h18
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc46
-rw-r--r--chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc17
-rw-r--r--chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h3
-rw-r--r--components/web_modal/web_contents_modal_dialog_manager.cc79
-rw-r--r--components/web_modal/web_contents_modal_dialog_manager.h21
32 files changed, 329 insertions, 448 deletions
diff --git a/chrome/browser/printing/background_printing_manager.cc b/chrome/browser/printing/background_printing_manager.cc
index f0aa96a..4db8f15 100644
--- a/chrome/browser/printing/background_printing_manager.cc
+++ b/chrome/browser/printing/background_printing_manager.cc
@@ -63,15 +63,16 @@ void BackgroundPrintingManager::OwnPrintPreviewDialog(
rph_source);
}
- // Activate the initiator.
+ // Activate the initiator tab.
PrintPreviewDialogController* dialog_controller =
PrintPreviewDialogController::GetInstance();
if (!dialog_controller)
return;
- WebContents* initiator = dialog_controller->GetInitiator(preview_dialog);
- if (!initiator)
+ WebContents* initiator_tab =
+ dialog_controller->GetInitiatorTab(preview_dialog);
+ if (!initiator_tab)
return;
- initiator->GetDelegate()->ActivateContents(initiator);
+ initiator_tab->GetDelegate()->ActivateContents(initiator_tab);
}
void BackgroundPrintingManager::Observe(
diff --git a/chrome/browser/printing/print_preview_dialog_controller.cc b/chrome/browser/printing/print_preview_dialog_controller.cc
index 6d96eb3..3e4522f 100644
--- a/chrome/browser/printing/print_preview_dialog_controller.cc
+++ b/chrome/browser/printing/print_preview_dialog_controller.cc
@@ -74,7 +74,7 @@ void EnableInternalPDFPluginForContents(WebContents* preview_dialog) {
// will look like.
class PrintPreviewDialogDelegate : public WebDialogDelegate {
public:
- explicit PrintPreviewDialogDelegate(WebContents* initiator);
+ explicit PrintPreviewDialogDelegate(WebContents* initiator_tab);
virtual ~PrintPreviewDialogDelegate();
virtual ui::ModalType GetDialogModalType() const OVERRIDE;
@@ -90,13 +90,14 @@ class PrintPreviewDialogDelegate : public WebDialogDelegate {
virtual bool ShouldShowDialogTitle() const OVERRIDE;
private:
- WebContents* initiator_;
+ WebContents* initiator_tab_;
DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogDelegate);
};
-PrintPreviewDialogDelegate::PrintPreviewDialogDelegate(WebContents* initiator)
- : initiator_(initiator) {
+PrintPreviewDialogDelegate::PrintPreviewDialogDelegate(
+ WebContents* initiator_tab) {
+ initiator_tab_ = initiator_tab;
}
PrintPreviewDialogDelegate::~PrintPreviewDialogDelegate() {
@@ -128,7 +129,7 @@ void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const {
const int kBorder = 25;
const int kConstrainedWindowOverlap = 3;
gfx::Rect rect;
- initiator_->GetView()->GetContainerBounds(&rect);
+ initiator_tab_->GetView()->GetContainerBounds(&rect);
size->set_width(std::max(rect.width(), kMinDialogSize.width()) - 2 * kBorder);
size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder +
kConstrainedWindowOverlap);
@@ -164,7 +165,7 @@ bool PrintPreviewDialogDelegate::ShouldShowDialogTitle() const {
// renderer to the browser.
class PrintPreviewWebContentDelegate : public WebDialogWebContentsDelegate {
public:
- PrintPreviewWebContentDelegate(Profile* profile, WebContents* initiator);
+ PrintPreviewWebContentDelegate(Profile* profile, WebContents* initiator_tab);
virtual ~PrintPreviewWebContentDelegate();
// Overridden from WebDialogWebContentsDelegate:
@@ -180,9 +181,9 @@ class PrintPreviewWebContentDelegate : public WebDialogWebContentsDelegate {
PrintPreviewWebContentDelegate::PrintPreviewWebContentDelegate(
Profile* profile,
- WebContents* initiator)
+ WebContents* initiator_tab)
: WebDialogWebContentsDelegate(profile, new ChromeWebContentsHandler),
- tab_(initiator) {}
+ tab_(initiator_tab) {}
PrintPreviewWebContentDelegate::~PrintPreviewWebContentDelegate() {}
@@ -215,28 +216,28 @@ PrintPreviewDialogController* PrintPreviewDialogController::GetInstance() {
}
// static
-void PrintPreviewDialogController::PrintPreview(WebContents* initiator) {
- if (initiator->ShowingInterstitialPage())
+void PrintPreviewDialogController::PrintPreview(WebContents* initiator_tab) {
+ if (initiator_tab->ShowingInterstitialPage())
return;
PrintPreviewDialogController* dialog_controller = GetInstance();
if (!dialog_controller)
return;
- if (!dialog_controller->GetOrCreatePreviewDialog(initiator))
- PrintViewManager::FromWebContents(initiator)->PrintPreviewDone();
+ if (!dialog_controller->GetOrCreatePreviewDialog(initiator_tab))
+ PrintViewManager::FromWebContents(initiator_tab)->PrintPreviewDone();
}
WebContents* PrintPreviewDialogController::GetOrCreatePreviewDialog(
- WebContents* initiator) {
- DCHECK(initiator);
+ WebContents* initiator_tab) {
+ DCHECK(initiator_tab);
- // Get the print preview dialog for |initiator|.
- WebContents* preview_dialog = GetPrintPreviewForContents(initiator);
+ // Get the print preview dialog for |initiator_tab|.
+ WebContents* preview_dialog = GetPrintPreviewForContents(initiator_tab);
if (!preview_dialog)
- return CreatePrintPreviewDialog(initiator);
+ return CreatePrintPreviewDialog(initiator_tab);
- // Show the initiator holding the existing preview dialog.
- initiator->GetDelegate()->ActivateContents(initiator);
+ // Show the initiator tab holding the existing preview dialog.
+ initiator_tab->GetDelegate()->ActivateContents(initiator_tab);
return preview_dialog;
}
@@ -251,7 +252,7 @@ WebContents* PrintPreviewDialogController::GetPrintPreviewForContents(
for (it = preview_dialog_map_.begin();
it != preview_dialog_map_.end();
++it) {
- // If |contents| is an initiator.
+ // If |contents| is an initiator tab.
if (contents == it->second) {
// Return the associated preview dialog.
return it->first;
@@ -260,7 +261,7 @@ WebContents* PrintPreviewDialogController::GetPrintPreviewForContents(
return NULL;
}
-WebContents* PrintPreviewDialogController::GetInitiator(
+WebContents* PrintPreviewDialogController::GetInitiatorTab(
WebContents* preview_dialog) {
PrintPreviewDialogMap::iterator it = preview_dialog_map_.find(preview_dialog);
return (it != preview_dialog_map_.end()) ? it->second : NULL;
@@ -296,13 +297,13 @@ bool PrintPreviewDialogController::IsPrintPreviewURL(const GURL& url) {
url.host() == chrome::kChromeUIPrintHost);
}
-void PrintPreviewDialogController::EraseInitiatorInfo(
+void PrintPreviewDialogController::EraseInitiatorTabInfo(
WebContents* preview_dialog) {
PrintPreviewDialogMap::iterator it = preview_dialog_map_.find(preview_dialog);
if (it == preview_dialog_map_.end())
return;
- RemoveObservers(it->second, INITIATOR);
+ RemoveObservers(it->second);
preview_dialog_map_[preview_dialog] = NULL;
}
@@ -312,17 +313,17 @@ void PrintPreviewDialogController::OnRendererProcessClosed(
content::RenderProcessHost* rph) {
// Store contents in a vector and deal with them after iterating through
// |preview_dialog_map_| because RemoveFoo() can change |preview_dialog_map_|.
- std::vector<WebContents*> closed_initiators;
+ std::vector<WebContents*> closed_initiator_tabs;
std::vector<WebContents*> closed_preview_dialogs;
for (PrintPreviewDialogMap::iterator iter = preview_dialog_map_.begin();
iter != preview_dialog_map_.end(); ++iter) {
WebContents* preview_dialog = iter->first;
- WebContents* initiator = iter->second;
+ WebContents* initiator_tab = iter->second;
if (preview_dialog->GetRenderProcessHost() == rph) {
closed_preview_dialogs.push_back(preview_dialog);
- } else if (initiator &&
- initiator->GetRenderProcessHost() == rph) {
- closed_initiators.push_back(initiator);
+ } else if (initiator_tab &&
+ initiator_tab->GetRenderProcessHost() == rph) {
+ closed_initiator_tabs.push_back(initiator_tab);
}
}
@@ -334,8 +335,8 @@ void PrintPreviewDialogController::OnRendererProcessClosed(
print_preview_ui->OnPrintPreviewDialogClosed();
}
- for (size_t i = 0; i < closed_initiators.size(); ++i)
- RemoveInitiator(closed_initiators[i]);
+ for (size_t i = 0; i < closed_initiator_tabs.size(); ++i)
+ RemoveInitiatorTab(closed_initiator_tabs[i]);
}
void PrintPreviewDialogController::OnWebContentsDestroyed(
@@ -349,7 +350,7 @@ void PrintPreviewDialogController::OnWebContentsDestroyed(
if (contents == preview_dialog)
RemovePreviewDialog(contents);
else
- RemoveInitiator(contents);
+ RemoveInitiatorTab(contents);
}
void PrintPreviewDialogController::OnNavEntryCommitted(
@@ -360,40 +361,42 @@ void PrintPreviewDialogController::OnNavEntryCommitted(
return;
}
- DCHECK_EQ(contents, preview_dialog);
-
- // Preview dialog navigated.
- if (details) {
- content::PageTransition transition_type =
- details->entry->GetTransitionType();
- content::NavigationType nav_type = details->type;
-
- // New |preview_dialog| is created. Don't update/erase map entry.
- if (waiting_for_new_preview_page_ &&
- transition_type == content::PAGE_TRANSITION_AUTO_TOPLEVEL &&
- nav_type == content::NAVIGATION_TYPE_NEW_PAGE) {
- waiting_for_new_preview_page_ = false;
- SaveInitiatorTitle(preview_dialog);
- return;
- }
-
- // Cloud print sign-in causes a reload.
- if (!waiting_for_new_preview_page_ &&
- transition_type == content::PAGE_TRANSITION_RELOAD &&
- nav_type == content::NAVIGATION_TYPE_EXISTING_PAGE &&
- IsPrintPreviewURL(details->previous_url)) {
- return;
+ if (contents == preview_dialog) {
+ // Preview dialog navigated.
+ if (details) {
+ content::PageTransition transition_type =
+ details->entry->GetTransitionType();
+ content::NavigationType nav_type = details->type;
+
+ // New |preview_dialog| is created. Don't update/erase map entry.
+ if (waiting_for_new_preview_page_ &&
+ transition_type == content::PAGE_TRANSITION_AUTO_TOPLEVEL &&
+ nav_type == content::NAVIGATION_TYPE_NEW_PAGE) {
+ waiting_for_new_preview_page_ = false;
+ SaveInitiatorTabTitle(preview_dialog);
+ return;
+ }
+
+ // Cloud print sign-in causes a reload.
+ if (!waiting_for_new_preview_page_ &&
+ transition_type == content::PAGE_TRANSITION_RELOAD &&
+ nav_type == content::NAVIGATION_TYPE_EXISTING_PAGE &&
+ IsPrintPreviewURL(details->previous_url)) {
+ return;
+ }
}
+ NOTREACHED();
+ return;
}
- NOTREACHED();
+ RemoveInitiatorTab(contents);
}
WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
- WebContents* initiator) {
+ WebContents* initiator_tab) {
base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true);
Profile* profile =
- Profile::FromBrowserContext(initiator->GetBrowserContext());
+ Profile::FromBrowserContext(initiator_tab->GetBrowserContext());
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) {
// Chrome Frame only ever runs on the native desktop, so it is safe to
// create the popup on the native desktop.
@@ -409,48 +412,45 @@ WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
// |web_dialog_ui_delegate| deletes itself in
// PrintPreviewDialogDelegate::OnDialogClosed().
WebDialogDelegate* web_dialog_delegate =
- new PrintPreviewDialogDelegate(initiator);
+ new PrintPreviewDialogDelegate(initiator_tab);
// |web_dialog_delegate|'s owner is |constrained_delegate|.
PrintPreviewWebContentDelegate* pp_wcd =
- new PrintPreviewWebContentDelegate(profile, initiator);
+ new PrintPreviewWebContentDelegate(profile, initiator_tab);
ConstrainedWebDialogDelegate* constrained_delegate =
CreateConstrainedWebDialog(profile,
web_dialog_delegate,
pp_wcd,
- initiator);
+ initiator_tab);
WebContents* preview_dialog = constrained_delegate->GetWebContents();
EnableInternalPDFPluginForContents(preview_dialog);
PrintViewManager::CreateForWebContents(preview_dialog);
// Add an entry to the map.
- preview_dialog_map_[preview_dialog] = initiator;
+ preview_dialog_map_[preview_dialog] = initiator_tab;
waiting_for_new_preview_page_ = true;
- AddObservers(initiator, INITIATOR);
- AddObservers(preview_dialog, PREVIEW_DIALOG);
+ AddObservers(initiator_tab);
+ AddObservers(preview_dialog);
return preview_dialog;
}
-void PrintPreviewDialogController::SaveInitiatorTitle(
+void PrintPreviewDialogController::SaveInitiatorTabTitle(
WebContents* preview_dialog) {
- WebContents* initiator = GetInitiator(preview_dialog);
- if (initiator && preview_dialog->GetWebUI()) {
+ WebContents* initiator_tab = GetInitiatorTab(preview_dialog);
+ if (initiator_tab && preview_dialog->GetWebUI()) {
PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
preview_dialog->GetWebUI()->GetController());
- print_preview_ui->SetInitiatorTitle(
- PrintViewManager::FromWebContents(initiator)->RenderSourceName());
+ print_preview_ui->SetInitiatorTabTitle(
+ PrintViewManager::FromWebContents(initiator_tab)->RenderSourceName());
}
}
-void PrintPreviewDialogController::AddObservers(WebContents* contents,
- ContentsType contents_type) {
+void PrintPreviewDialogController::AddObservers(WebContents* contents) {
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::Source<WebContents>(contents));
- if (contents_type == PREVIEW_DIALOG) {
- registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
- content::Source<NavigationController>(&contents->GetController()));
- }
+ registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
+ content::Source<NavigationController>(&contents->GetController()));
// Multiple sites may share the same RenderProcessHost, so check if this
// notification has already been added.
@@ -463,14 +463,11 @@ void PrintPreviewDialogController::AddObservers(WebContents* contents,
}
}
-void PrintPreviewDialogController::RemoveObservers(WebContents* contents,
- ContentsType contents_type) {
+void PrintPreviewDialogController::RemoveObservers(WebContents* contents) {
registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::Source<WebContents>(contents));
- if (contents_type == PREVIEW_DIALOG) {
- registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
- content::Source<NavigationController>(&contents->GetController()));
- }
+ registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
+ content::Source<NavigationController>(&contents->GetController()));
// Multiple sites may share the same RenderProcessHost, so check if this
// notification has already been added.
@@ -483,43 +480,43 @@ void PrintPreviewDialogController::RemoveObservers(WebContents* contents,
}
}
-void PrintPreviewDialogController::RemoveInitiator(
- WebContents* initiator) {
- WebContents* preview_dialog = GetPrintPreviewForContents(initiator);
+void PrintPreviewDialogController::RemoveInitiatorTab(
+ WebContents* initiator_tab) {
+ WebContents* preview_dialog = GetPrintPreviewForContents(initiator_tab);
DCHECK(preview_dialog);
// Update the map entry first, so when the print preview dialog gets destroyed
// and reaches RemovePreviewDialog(), it does not attempt to also remove the
- // initiator's observers.
+ // initiator tab's observers.
preview_dialog_map_[preview_dialog] = NULL;
- RemoveObservers(initiator, INITIATOR);
+ RemoveObservers(initiator_tab);
- PrintViewManager::FromWebContents(initiator)->PrintPreviewDone();
+ PrintViewManager::FromWebContents(initiator_tab)->PrintPreviewDone();
- // initiator is closed. Close the print preview dialog too.
+ // Initiator tab is closed. Close the print preview dialog too.
PrintPreviewUI* print_preview_ui =
static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController());
if (print_preview_ui)
- print_preview_ui->OnInitiatorClosed();
+ print_preview_ui->OnInitiatorTabClosed();
}
void PrintPreviewDialogController::RemovePreviewDialog(
WebContents* preview_dialog) {
- // Remove the initiator's observers before erasing the mapping.
- WebContents* initiator = GetInitiator(preview_dialog);
- if (initiator) {
- RemoveObservers(initiator, INITIATOR);
- PrintViewManager::FromWebContents(initiator)->PrintPreviewDone();
+ // Remove the initiator tab's observers before erasing the mapping.
+ WebContents* initiator_tab = GetInitiatorTab(preview_dialog);
+ if (initiator_tab) {
+ RemoveObservers(initiator_tab);
+ PrintViewManager::FromWebContents(initiator_tab)->PrintPreviewDone();
}
// Print preview WebContents is destroyed. Notify |PrintPreviewUI| to abort
- // the initiator preview request.
+ // the initiator tab preview request.
PrintPreviewUI* print_preview_ui =
static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController());
if (print_preview_ui)
print_preview_ui->OnPrintPreviewDialogDestroyed();
preview_dialog_map_.erase(preview_dialog);
- RemoveObservers(preview_dialog, PREVIEW_DIALOG);
+ RemoveObservers(preview_dialog);
}
} // namespace printing
diff --git a/chrome/browser/printing/print_preview_dialog_controller.h b/chrome/browser/printing/print_preview_dialog_controller.h
index da5d385..0ce70db 100644
--- a/chrome/browser/printing/print_preview_dialog_controller.h
+++ b/chrome/browser/printing/print_preview_dialog_controller.h
@@ -1,4 +1,4 @@
- // Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,9 +22,9 @@ class WebContents;
namespace printing {
-// For print preview, the WebContents that initiates the printing operation is
-// the initiator, and the constrained dialog that shows the print preview is the
-// print preview dialog.
+// For print preview, the tab that initiates the printing operation is the
+// initiator tab, and the constrained dialog that shows the print preview is
+// the print preview dialog.
// This class manages print preview dialog creation and destruction, and keeps
// track of the 1:1 relationship between initiatora tabs and print preview
// dialogs.
@@ -36,14 +36,14 @@ class PrintPreviewDialogController
static PrintPreviewDialogController* GetInstance();
- // Initiate print preview for |initiator|.
+ // Initiate print preview for |initiator_tab|.
// Call this instead of GetOrCreatePreviewDialog().
- static void PrintPreview(content::WebContents* initiator);
+ static void PrintPreview(content::WebContents* initiator_tab);
- // Get/Create the print preview dialog for |initiator|.
+ // Get/Create the print preview dialog for |initiator_tab|.
// Exposed for unit tests.
content::WebContents* GetOrCreatePreviewDialog(
- content::WebContents* initiator);
+ content::WebContents* initiator_tab);
// Returns the preview dialog for |contents|.
// Returns |contents| if |contents| is a preview dialog.
@@ -51,9 +51,9 @@ class PrintPreviewDialogController
content::WebContents* GetPrintPreviewForContents(
content::WebContents* contents) const;
- // Returns the initiator for |preview_dialog|.
- // Returns NULL if no initiator exists for |preview_dialog|.
- content::WebContents* GetInitiator(content::WebContents* preview_dialog);
+ // Returns the initiator tab for |preview_dialog|.
+ // Returns NULL if no initiator tab exists for |preview_dialog|.
+ content::WebContents* GetInitiatorTab(content::WebContents* preview_dialog);
// content::NotificationObserver implementation.
virtual void Observe(int type,
@@ -66,8 +66,8 @@ class PrintPreviewDialogController
// Returns true if |url| is a print preview url.
static bool IsPrintPreviewURL(const GURL& url);
- // Erase the initiator info associated with |preview_dialog|.
- void EraseInitiatorInfo(content::WebContents* preview_dialog);
+ // Erase the initiator tab info associated with |preview_tab|.
+ void EraseInitiatorTabInfo(content::WebContents* preview_tab);
bool is_creating_print_preview_dialog() const {
return is_creating_print_preview_dialog_;
@@ -76,16 +76,9 @@ class PrintPreviewDialogController
private:
friend class base::RefCounted<PrintPreviewDialogController>;
- // Used to distinguish between the two varieties of WebContents dealt with by
- // this class.
- enum ContentsType {
- INITIATOR,
- PREVIEW_DIALOG
- };
-
- // 1:1 relationship between a print preview dialog and its initiator.
+ // 1:1 relationship between a print preview dialog and its initiator tab.
// Key: Print preview dialog.
- // Value: Initiator.
+ // Value: Initiator tab.
typedef std::map<content::WebContents*, content::WebContents*>
PrintPreviewDialogMap;
@@ -106,22 +99,21 @@ class PrintPreviewDialogController
// Creates a new print preview dialog.
content::WebContents* CreatePrintPreviewDialog(
- content::WebContents* initiator);
+ content::WebContents* initiator_tab);
- // Helper function to store the title of the initiator associated with
+ // Helper function to store the title of the initiator tab associated with
// |preview_dialog| in |preview_dialog|'s PrintPreviewUI.
- void SaveInitiatorTitle(content::WebContents* preview_dialog);
+ void SaveInitiatorTabTitle(content::WebContents* preview_dialog);
// Adds/Removes observers for notifications from |contents|.
- void AddObservers(content::WebContents* contents, ContentsType contents_type);
- void RemoveObservers(content::WebContents* contents,
- ContentsType contents_type);
+ void AddObservers(content::WebContents* contents);
+ void RemoveObservers(content::WebContents* contents);
// Removes WebContents when they close/crash/navigate.
- void RemoveInitiator(content::WebContents* initiator);
+ void RemoveInitiatorTab(content::WebContents* initiator_tab);
void RemovePreviewDialog(content::WebContents* preview_dialog);
- // Mapping between print preview dialog and the corresponding initiator.
+ // Mapping between print preview dialog and the corresponding initiator tab.
PrintPreviewDialogMap preview_dialog_map_;
// A registrar for listening notifications.
diff --git a/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc b/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc
index c64c3bf8..b9bcb4e 100644
--- a/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc
+++ b/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc
@@ -103,11 +103,11 @@ class PrintPreviewDialogDestroyedObserver : public WebContentsObserver {
class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
public:
- PrintPreviewDialogControllerBrowserTest() : initiator_(NULL) {}
+ PrintPreviewDialogControllerBrowserTest() : initiator_tab_(NULL) {}
virtual ~PrintPreviewDialogControllerBrowserTest() {}
- WebContents* initiator() {
- return initiator_;
+ WebContents* initiator_tab() {
+ return initiator_tab_;
}
void PrintPreview() {
@@ -120,7 +120,7 @@ class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
WebContents* GetPrintPreviewDialog() {
printing::PrintPreviewDialogController* dialog_controller =
printing::PrintPreviewDialogController::GetInstance();
- return dialog_controller->GetPrintPreviewForContents(initiator_);
+ return dialog_controller->GetPrintPreviewForContents(initiator_tab_);
}
private:
@@ -143,14 +143,14 @@ class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
cloned_tab_observer_.reset(new PrintPreviewDialogClonedObserver(first_tab));
chrome::DuplicateTab(browser());
- initiator_ = browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(initiator_);
- ASSERT_NE(first_tab, initiator_);
+ initiator_tab_ = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(initiator_tab_);
+ ASSERT_NE(first_tab, initiator_tab_);
}
virtual void CleanUpOnMainThread() OVERRIDE {
cloned_tab_observer_.reset();
- initiator_ = NULL;
+ initiator_tab_ = NULL;
}
RequestPrintPreviewObserver* request_preview_tab_observer() {
@@ -158,13 +158,13 @@ class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
}
scoped_ptr<PrintPreviewDialogClonedObserver> cloned_tab_observer_;
- WebContents* initiator_;
+ WebContents* initiator_tab_;
DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogControllerBrowserTest);
};
-// Test to verify that when a initiator navigates, we can create a new preview
-// dialog for the new tab contents.
+// Test to verify that when a initiator tab navigates, we can create a new
+// preview dialog for the new tab contents.
IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
NavigateFromInitiatorTab) {
// print for the first time.
@@ -175,7 +175,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
// Check a new print preview dialog got created.
ASSERT_TRUE(preview_dialog);
- ASSERT_NE(initiator(), preview_dialog);
+ ASSERT_NE(initiator_tab(), preview_dialog);
// Navigate in the initiator tab. Make sure navigating destroys the print
// preview dialog.
@@ -193,8 +193,8 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
EXPECT_TRUE(new_preview_dialog);
}
-// Test to verify that after reloading the initiator, it creates a new print
-// preview dialog.
+// Test to verify that after reloading the initiator tab, it creates a new
+// print preview dialog.
IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
ReloadInitiatorTab) {
// print for the first time.
@@ -204,9 +204,9 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
// Check a new print preview dialog got created.
ASSERT_TRUE(preview_dialog);
- ASSERT_NE(initiator(), preview_dialog);
+ ASSERT_NE(initiator_tab(), preview_dialog);
- // Reload the initiator. Make sure reloading destroys the print preview
+ // Reload the initiator tab. Make sure reloading destroys the print preview
// dialog.
PrintPreviewDialogDestroyedObserver dialog_destroyed_observer(preview_dialog);
content::WindowedNotificationObserver notification_observer(
diff --git a/chrome/browser/printing/print_preview_dialog_controller_unittest.cc b/chrome/browser/printing/print_preview_dialog_controller_unittest.cc
index 6ec20ba..a336631 100644
--- a/chrome/browser/printing/print_preview_dialog_controller_unittest.cc
+++ b/chrome/browser/printing/print_preview_dialog_controller_unittest.cc
@@ -16,23 +16,23 @@
using content::WebContents;
-// Test crashes on Aura due to initiator's native view having no parent.
+// Test crashes on Aura due to initiator tab's native view having no parent.
// http://crbug.com/104284
#if defined(USE_AURA)
#define MAYBE_GetOrCreatePreviewDialog DISABLED_GetOrCreatePreviewDialog
#define MAYBE_MultiplePreviewDialogs DISABLED_MultiplePreviewDialogs
-#define MAYBE_ClearInitiatorDetails DISABLED_ClearInitiatorDetails
+#define MAYBE_ClearInitiatorTabDetails DISABLED_ClearInitiatorTabDetails
#else
#define MAYBE_GetOrCreatePreviewDialog GetOrCreatePreviewDialog
#define MAYBE_MultiplePreviewDialogs MultiplePreviewDialogs
-#define MAYBE_ClearInitiatorDetails ClearInitiatorDetails
+#define MAYBE_ClearInitiatorTabDetails ClearInitiatorTabDetails
#endif
namespace printing {
typedef PrintPreviewTest PrintPreviewDialogControllerUnitTest;
-// Create/Get a preview dialog for initiator.
+// Create/Get a preview dialog for initiator tab.
TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_GetOrCreatePreviewDialog) {
// Lets start with one window with one tab.
EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
@@ -40,37 +40,38 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_GetOrCreatePreviewDialog) {
chrome::NewTab(browser());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- // Create a reference to initiator contents.
- WebContents* initiator = browser()->tab_strip_model()->GetActiveWebContents();
+ // Create a reference to initiator tab contents.
+ WebContents* initiator_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
PrintPreviewDialogController* dialog_controller =
PrintPreviewDialogController::GetInstance();
ASSERT_TRUE(dialog_controller);
- // Get the preview dialog for initiator.
- PrintViewManager::FromWebContents(initiator)->PrintPreviewNow(false);
+ // Get the preview dialog for initiator tab.
+ PrintViewManager::FromWebContents(initiator_tab)->PrintPreviewNow(false);
WebContents* preview_dialog =
- dialog_controller->GetOrCreatePreviewDialog(initiator);
+ dialog_controller->GetOrCreatePreviewDialog(initiator_tab);
// New print preview dialog is a constrained window, so the number of tabs is
// still 1.
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- EXPECT_NE(initiator, preview_dialog);
+ EXPECT_NE(initiator_tab, preview_dialog);
- // Get the print preview dialog for the same initiator.
+ // Get the print preview dialog for the same initiator tab.
WebContents* new_preview_dialog =
- dialog_controller->GetOrCreatePreviewDialog(initiator);
+ dialog_controller->GetOrCreatePreviewDialog(initiator_tab);
// Preview dialog already exists. Tab count remains the same.
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- // 1:1 relationship between initiator and preview dialog.
+ // 1:1 relationship between initiator tab and preview dialog.
EXPECT_EQ(new_preview_dialog, preview_dialog);
}
-// Tests multiple print preview dialogs exist in the same browser for different
-// initiators. If a preview dialog already exists for an initiator, that
-// initiator gets focused.
+// Tests multiple print preview dialogs exist in the same browser for
+// different initiator tabs. If a preview dialog already exists for an
+// initiator tab, that initiator tab gets focused.
TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewDialogs) {
// Lets start with one window and two tabs.
EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
@@ -79,7 +80,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewDialogs) {
EXPECT_EQ(0, tab_strip_model->count());
- // Create some new initiators.
+ // Create some new initiator tabs.
chrome::NewTab(browser());
WebContents* web_contents_1 = tab_strip_model->GetActiveWebContents();
ASSERT_TRUE(web_contents_1);
@@ -108,8 +109,8 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewDialogs) {
EXPECT_NE(web_contents_2, preview_dialog_2);
EXPECT_NE(preview_dialog_1, preview_dialog_2);
- // 2 initiators and 2 preview dialogs exist in the same browser. The preview
- // dialogs are constrained in their respective initiators.
+ // 2 initiator tabs and 2 preview dialogs exist in the same browser.
+ // The preview dialogs are constrained in their respective initiator tabs.
EXPECT_EQ(2, tab_strip_model->count());
int tab_1_index = tab_strip_model->GetIndexOfWebContents(web_contents_1);
@@ -124,7 +125,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewDialogs) {
EXPECT_EQ(-1, preview_dialog_2_index);
// Since |preview_dialog_2_index| was the most recently created dialog, its
- // initiator should have focus.
+ // initiator tab should have focus.
EXPECT_EQ(tab_2_index, tab_strip_model->active_index());
// When we get the preview dialog for |web_contents_1|,
@@ -133,38 +134,39 @@ TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_MultiplePreviewDialogs) {
EXPECT_EQ(tab_1_index, tab_strip_model->active_index());
}
-// Check clearing the initiator details associated with a print preview dialog
-// allows the initiator to create another print preview dialog.
-TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_ClearInitiatorDetails) {
+// Check clearing the initiator tab details associated with a print preview
+// dialog allows the initiator tab to create another print preview dialog.
+TEST_F(PrintPreviewDialogControllerUnitTest, MAYBE_ClearInitiatorTabDetails) {
// Lets start with one window with one tab.
EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
EXPECT_EQ(0, browser()->tab_strip_model()->count());
chrome::NewTab(browser());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- // Create a reference to initiator contents.
- WebContents* initiator = browser()->tab_strip_model()->GetActiveWebContents();
+ // Create a reference to initiator tab contents.
+ WebContents* initiator_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
PrintPreviewDialogController* dialog_controller =
PrintPreviewDialogController::GetInstance();
ASSERT_TRUE(dialog_controller);
- // Get the preview dialog for the initiator.
- PrintViewManager::FromWebContents(initiator)->PrintPreviewNow(false);
+ // Get the preview dialog for the initiator tab.
+ PrintViewManager::FromWebContents(initiator_tab)->PrintPreviewNow(false);
WebContents* preview_dialog =
- dialog_controller->GetOrCreatePreviewDialog(initiator);
+ dialog_controller->GetOrCreatePreviewDialog(initiator_tab);
// New print preview dialog is a constrained window, so the number of tabs is
// still 1.
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- EXPECT_NE(initiator, preview_dialog);
+ EXPECT_NE(initiator_tab, preview_dialog);
- // Clear the initiator details associated with the preview dialog.
- dialog_controller->EraseInitiatorInfo(preview_dialog);
+ // Clear the initiator tab details associated with the preview dialog.
+ dialog_controller->EraseInitiatorTabInfo(preview_dialog);
- // Get a new print preview dialog for the initiator.
+ // Get a new print preview dialog for the initiator tab.
WebContents* new_preview_dialog =
- dialog_controller->GetOrCreatePreviewDialog(initiator);
+ dialog_controller->GetOrCreatePreviewDialog(initiator_tab);
// New print preview dialog is a constrained window, so the number of tabs is
// still 1.
diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h
index 616ff00..55b4708 100644
--- a/chrome/browser/printing/print_view_manager.h
+++ b/chrome/browser/printing/print_view_manager.h
@@ -46,7 +46,7 @@ class PrintViewManager : public content::NotificationObserver,
bool PrintForSystemDialogNow();
// Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to
- // show the native system dialog. This can happen from both initiator and
+ // show the native system dialog. This can happen from both initiator tab and
// preview dialog.
bool AdvancedPrintNow();
diff --git a/chrome/browser/repost_form_warning_controller.cc b/chrome/browser/repost_form_warning_controller.cc
index e665b29..0d9ac56 100644
--- a/chrome/browser/repost_form_warning_controller.cc
+++ b/chrome/browser/repost_form_warning_controller.cc
@@ -45,9 +45,7 @@ const char* RepostFormWarningController::GetCancelButtonIcon() {
#endif // defined(TOOLKIT_GTK)
void RepostFormWarningController::OnAccepted() {
- operations_delegate()->SetPreventCloseOnLoadStart(true);
web_contents()->GetController().ContinuePendingReload();
- operations_delegate()->SetPreventCloseOnLoadStart(false);
}
void RepostFormWarningController::OnCanceled() {
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js
index bda89a7..469c362 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -345,7 +345,7 @@ cr.define('print_preview', function() {
numberFormatSymbols[1] || '.',
unitType,
initialSettings['previewModifiable'] || false,
- initialSettings['initiatorTitle'] || '',
+ initialSettings['initiatorTabTitle'] || '',
initialSettings['documentHasSelection'] || false,
initialSettings['shouldPrintSelectionOnly'] || false,
initialSettings['printerName'] || null,
@@ -417,7 +417,7 @@ cr.define('print_preview', function() {
/**
* Called from the C++ layer.
* Take the PDF data handed to us and submit it to the cloud, closing the
- * print preview dialog once the upload is successful.
+ * print preview tab once the upload is successful.
* @param {string} data Data to send as the print job.
* @private
*/
@@ -430,7 +430,7 @@ cr.define('print_preview', function() {
/**
* Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print
- * preview dialog regarding the file selection cancel event.
+ * preview tab regarding the file selection cancel event.
* @private
*/
onFileSelectionCancelled_: function() {
@@ -439,12 +439,12 @@ cr.define('print_preview', function() {
/**
* Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print
- * preview dialog regarding the file selection completed event.
+ * preview tab regarding the file selection completed event.
* @private
*/
onFileSelectionCompleted_: function() {
- // If the file selection is completed and the dialog is not already closed
- // it means that a pending print to pdf request exists.
+ // If the file selection is completed and the tab is not already closed it
+ // means that a pending print to pdf request exists.
cr.dispatchSimpleEvent(
this, NativeLayer.EventType.FILE_SELECTION_COMPLETE);
},
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index 1f6e16e..398ee75 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -70,7 +70,6 @@
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "grit/webkit_resources.h"
-#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/cert/cert_status_flags.h"
#include "ui/base/base_window.h"
#include "ui/base/l10n/l10n_util.h"
@@ -2098,20 +2097,6 @@ void AutofillDialogControllerImpl::Observe(
}
////////////////////////////////////////////////////////////////////////////////
-// content::WebContentsObserver implementation.
-
-void AutofillDialogControllerImpl::DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) {
- // Close view if necessary.
- if (!net::registry_controlled_domains::SameDomainOrHost(
- details.previous_url, details.entry->GetURL(),
- net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)) {
- Hide();
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
// SuggestionsMenuModelDelegate implementation.
void AutofillDialogControllerImpl::SuggestionItemSelected(
@@ -2353,8 +2338,7 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl(
const DialogType dialog_type,
const base::Callback<void(const FormStructure*,
const std::string&)>& callback)
- : WebContentsObserver(contents),
- profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
+ : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
contents_(contents),
initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
dialog_type_(dialog_type),
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
index 2b4ec01..cac7e46 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
@@ -33,7 +33,6 @@
#include "components/autofill/core/browser/personal_data_manager_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/ssl_status.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/ui_base_types.h"
@@ -70,7 +69,6 @@ class WalletSigninHelper;
class AutofillDialogControllerImpl : public AutofillDialogController,
public AutofillPopupDelegate,
public content::NotificationObserver,
- public content::WebContentsObserver,
public SuggestionsMenuModelDelegate,
public wallet::WalletClientDelegate,
public wallet::WalletSigninHelperDelegate,
@@ -196,11 +194,6 @@ class AutofillDialogControllerImpl : public AutofillDialogController,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // content::WebContentsObserver implementation.
- virtual void DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) OVERRIDE;
-
// SuggestionsMenuModelDelegate implementation.
virtual void SuggestionItemSelected(SuggestionsMenuModel* model,
size_t index) OVERRIDE;
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
index 282048b..f8094cd 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
@@ -58,7 +58,6 @@ void AutofillDialogCocoa::Show() {
initWithCustomWindow:[sheet_controller_ window]]);
constrained_window_.reset(
new ConstrainedWindowMac(this, controller_->web_contents(), sheet));
- constrained_window_->SetPreventCloseOnLoadStart(true);
}
void AutofillDialogCocoa::Hide() {
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h
index d6f0715..73202e8 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h
@@ -41,8 +41,6 @@ class ConstrainedWindowMac {
void PulseWebContentsModalDialog();
web_modal::NativeWebContentsModalDialog GetNativeDialog();
- void SetPreventCloseOnLoadStart(bool prevent);
-
private:
// Gets the parent window of the dialog.
NSWindow* GetParentWindow() const;
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
index 49d753f..df302df 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
@@ -78,14 +78,6 @@ NativeWebContentsModalDialog ConstrainedWindowMac::GetNativeDialog() {
return this;
}
-void ConstrainedWindowMac::SetPreventCloseOnLoadStart(bool prevent) {
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->SetPreventCloseOnLoadStart(
- GetNativeDialog(),
- prevent);
-}
-
NSWindow* ConstrainedWindowMac::GetParentWindow() const {
// Tab contents in a tabbed browser may not be inside a window. For this
// reason use a browser window if possible.
diff --git a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h
index 85aea22..0ead38a 100644
--- a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h
+++ b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h
@@ -38,9 +38,8 @@ class TabModalConfirmDialogMac : public TabModalConfirmDialog,
virtual void AcceptTabModalDialog() OVERRIDE;
virtual void CancelTabModalDialog() OVERRIDE;
- // TabModalConfirmDialogOperationsDelegate:
+ // TabModalConfirmDialogCloseDelegate:
virtual void CloseDialog() OVERRIDE;
- virtual void SetPreventCloseOnLoadStart(bool prevent) OVERRIDE;
// ConstrainedWindowMacDelegate:
virtual void OnConstrainedWindowClosed(
diff --git a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm
index a006fe9..bdca853 100644
--- a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm
+++ b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm
@@ -88,7 +88,7 @@ TabModalConfirmDialogMac::TabModalConfirmDialogMac(
[[CustomConstrainedWindowSheet alloc]
initWithCustomWindow:[alert_ window]]);
window_.reset(new ConstrainedWindowMac(this, web_contents, sheet));
- delegate_->set_operations_delegate(this);
+ delegate_->set_close_delegate(this);
}
TabModalConfirmDialogMac::~TabModalConfirmDialogMac() {
@@ -106,10 +106,6 @@ void TabModalConfirmDialogMac::CloseDialog() {
window_->CloseWebContentsModalDialog();
}
-void TabModalConfirmDialogMac::SetPreventCloseOnLoadStart(bool prevent) {
- window_->SetPreventCloseOnLoadStart(prevent);
-}
-
void TabModalConfirmDialogMac::OnConstrainedWindowClosed(
ConstrainedWindowMac* window) {
delete this;
diff --git a/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.cc b/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.cc
index 625b7c8..9b98a30 100644
--- a/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.cc
@@ -31,8 +31,7 @@ TabModalConfirmDialog* TabModalConfirmDialog::Create(
TabModalConfirmDialogGtk::TabModalConfirmDialogGtk(
TabModalConfirmDialogDelegate* delegate,
content::WebContents* web_contents)
- : web_contents_(web_contents),
- delegate_(delegate),
+ : delegate_(delegate),
window_(NULL) {
dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
GtkWidget* label = gtk_label_new(
@@ -101,7 +100,7 @@ TabModalConfirmDialogGtk::TabModalConfirmDialogGtk(
g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroyThunk), this);
window_ = CreateWebContentsModalDialogGtk(dialog_, cancel_);
- delegate_->set_operations_delegate(this);
+ delegate_->set_close_delegate(this);
WebContentsModalDialogManager* web_contents_modal_dialog_manager =
WebContentsModalDialogManager::FromWebContents(web_contents);
@@ -124,13 +123,6 @@ void TabModalConfirmDialogGtk::CloseDialog() {
gtk_widget_destroy(window_);
}
-void TabModalConfirmDialogGtk::SetPreventCloseOnLoadStart(bool prevent) {
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->SetPreventCloseOnLoadStart(window_,
- prevent);
-}
-
void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) {
delegate_->Accept();
}
diff --git a/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h b/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h
index bdbff19..8c7104a 100644
--- a/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h
+++ b/chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h
@@ -38,9 +38,8 @@ class TabModalConfirmDialogGtk : public TabModalConfirmDialog {
virtual void AcceptTabModalDialog() OVERRIDE;
virtual void CancelTabModalDialog() OVERRIDE;
- // TabModalConfirmDialogOperationsDelegate:
+ // TabModalConfirmDialogCloseDelegate:
virtual void CloseDialog() OVERRIDE;
- virtual void SetPreventCloseOnLoadStart(bool prevent) OVERRIDE;
// Callbacks:
CHROMEGTK_CALLBACK_0(TabModalConfirmDialogGtk, void, OnAccept);
@@ -48,8 +47,6 @@ class TabModalConfirmDialogGtk : public TabModalConfirmDialog {
CHROMEGTK_CALLBACK_0(TabModalConfirmDialogGtk, void, OnDestroy);
CHROMEGTK_CALLBACK_0(TabModalConfirmDialogGtk, void, OnLinkClicked);
- content::WebContents* web_contents_;
-
scoped_ptr<TabModalConfirmDialogDelegate> delegate_;
GtkWidget* dialog_;
diff --git a/chrome/browser/ui/tab_modal_confirm_dialog.h b/chrome/browser/ui/tab_modal_confirm_dialog.h
index 838e705..6bd54ac 100644
--- a/chrome/browser/ui/tab_modal_confirm_dialog.h
+++ b/chrome/browser/ui/tab_modal_confirm_dialog.h
@@ -12,7 +12,7 @@ class WebContents;
}
// Base class for the tab modal confirm dialog.
-class TabModalConfirmDialog : public TabModalConfirmDialogOperationsDelegate {
+class TabModalConfirmDialog : public TabModalConfirmDialogCloseDelegate {
public:
// Platform specific factory function. This function will automatically show
// the dialog.
@@ -24,11 +24,9 @@ class TabModalConfirmDialog : public TabModalConfirmDialogOperationsDelegate {
// Cancels the dialog.
virtual void CancelTabModalDialog() = 0;
- // TabModalConfirmDialogOperationsDelegate:
+ // TabModalConfirmDialogCloseDelegate:
// Closes the dialog.
virtual void CloseDialog() = 0;
- // Prevents the dialog from closing on WebContents load start.
- virtual void SetPreventCloseOnLoadStart(bool prevent) = 0;
protected:
virtual ~TabModalConfirmDialog() {}
diff --git a/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc b/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc
index c8e1a58..c8d87ea 100644
--- a/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc
+++ b/chrome/browser/ui/tab_modal_confirm_dialog_delegate.cc
@@ -16,9 +16,11 @@ using content::WebContents;
TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate(
WebContents* web_contents)
- : operations_delegate_(NULL),
+ : close_delegate_(NULL),
closing_(false) {
NavigationController* controller = &web_contents->GetController();
+ registrar_.Add(this, content::NOTIFICATION_LOAD_START,
+ content::Source<NavigationController>(controller));
registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING,
content::Source<NavigationController>(controller));
}
@@ -26,7 +28,7 @@ TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate(
TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() {
// If we end up here, the window has been closed, so make sure we don't close
// it again.
- operations_delegate_ = NULL;
+ close_delegate_ = NULL;
// Make sure everything is cleaned up.
Cancel();
}
@@ -65,8 +67,10 @@ void TabModalConfirmDialogDelegate::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- // Close the dialog if the tab is closed.
- if (type == chrome::NOTIFICATION_TAB_CLOSING) {
+ // Close the dialog if we load a page (because the action might not apply to
+ // the same page anymore) or if the tab is closed.
+ if (type == content::NOTIFICATION_LOAD_START ||
+ type == chrome::NOTIFICATION_TAB_CLOSING) {
Cancel();
} else {
NOTREACHED();
@@ -108,6 +112,6 @@ void TabModalConfirmDialogDelegate::OnLinkClicked(
}
void TabModalConfirmDialogDelegate::CloseDialog() {
- if (operations_delegate_)
- operations_delegate_->CloseDialog();
+ if (close_delegate_)
+ close_delegate_->CloseDialog();
}
diff --git a/chrome/browser/ui/tab_modal_confirm_dialog_delegate.h b/chrome/browser/ui/tab_modal_confirm_dialog_delegate.h
index 4f20b07..e58e00d 100644
--- a/chrome/browser/ui/tab_modal_confirm_dialog_delegate.h
+++ b/chrome/browser/ui/tab_modal_confirm_dialog_delegate.h
@@ -20,18 +20,15 @@ namespace gfx {
class Image;
}
-// Operations to be performed on the dialog by the
-// TabModalConfirmDialogDelegate.
-class TabModalConfirmDialogOperationsDelegate {
+class TabModalConfirmDialogCloseDelegate {
public:
- TabModalConfirmDialogOperationsDelegate() {}
- virtual ~TabModalConfirmDialogOperationsDelegate() {}
+ TabModalConfirmDialogCloseDelegate() {}
+ virtual ~TabModalConfirmDialogCloseDelegate() {}
virtual void CloseDialog() = 0;
- virtual void SetPreventCloseOnLoadStart(bool prevent) = 0;
private:
- DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogOperationsDelegate);
+ DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogCloseDelegate);
};
// This class acts as the delegate for a simple tab-modal dialog confirming
@@ -41,9 +38,8 @@ class TabModalConfirmDialogDelegate : public content::NotificationObserver {
explicit TabModalConfirmDialogDelegate(content::WebContents* web_contents);
virtual ~TabModalConfirmDialogDelegate();
- void set_operations_delegate(
- TabModalConfirmDialogOperationsDelegate* operations_delegate) {
- operations_delegate_ = operations_delegate;
+ void set_close_delegate(TabModalConfirmDialogCloseDelegate* close_delegate) {
+ close_delegate_ = close_delegate;
}
// Accepts the confirmation prompt and calls |OnAccepted|.
@@ -85,12 +81,12 @@ class TabModalConfirmDialogDelegate : public content::NotificationObserver {
virtual const char* GetCancelButtonIcon();
protected:
- TabModalConfirmDialogOperationsDelegate* operations_delegate() {
- return operations_delegate_;
+ TabModalConfirmDialogCloseDelegate* close_delegate() {
+ return close_delegate_;
}
// content::NotificationObserver implementation.
- // Watch for a closed tab and dismiss the dialog if it occurs.
+ // Watch for a new load or a closed tab and dismiss the dialog if they occur.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
@@ -113,7 +109,7 @@ class TabModalConfirmDialogDelegate : public content::NotificationObserver {
// Close the dialog.
void CloseDialog();
- TabModalConfirmDialogOperationsDelegate* operations_delegate_;
+ TabModalConfirmDialogCloseDelegate* close_delegate_;
// True iff we are in the process of closing, to avoid running callbacks
// multiple times.
bool closing_;
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
index e574c4a..2e8ee7a 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -1248,8 +1248,6 @@ void AutofillDialogViews::Show() {
web_contents_modal_dialog_manager->delegate()->
GetWebContentsModalDialogHost());
web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView());
- web_contents_modal_dialog_manager->SetPreventCloseOnLoadStart(
- window_->GetNativeView(), true);
focus_manager_ = window_->GetFocusManager();
focus_manager_->AddFocusChangeListener(this);
diff --git a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
index b6e35ab..6823d1a 100644
--- a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
+++ b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
@@ -39,8 +39,7 @@ TabModalConfirmDialog* TabModalConfirmDialog::Create(
TabModalConfirmDialogViews::TabModalConfirmDialogViews(
TabModalConfirmDialogDelegate* delegate,
content::WebContents* web_contents)
- : web_contents_(web_contents),
- delegate_(delegate),
+ : delegate_(delegate),
dialog_(NULL),
browser_context_(web_contents->GetBrowserContext()) {
views::MessageBoxView::InitParams init_params(delegate->GetMessage());
@@ -60,7 +59,7 @@ TabModalConfirmDialogViews::TabModalConfirmDialogViews(
web_contents_modal_dialog_manager->delegate()->
GetWebContentsModalDialogHost());
web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView());
- delegate_->set_operations_delegate(this);
+ delegate_->set_close_delegate(this);
}
TabModalConfirmDialogViews::~TabModalConfirmDialogViews() {
@@ -78,13 +77,6 @@ void TabModalConfirmDialogViews::CloseDialog() {
dialog_->Close();
}
-void TabModalConfirmDialogViews::SetPreventCloseOnLoadStart(bool prevent) {
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->SetPreventCloseOnLoadStart(
- dialog_->GetNativeView(), prevent);
-}
-
//////////////////////////////////////////////////////////////////////////////
// TabModalConfirmDialogViews, views::LinkListener implementation:
diff --git a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h
index 36e3de3..28d2e5b 100644
--- a/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h
+++ b/chrome/browser/ui/views/tab_modal_confirm_dialog_views.h
@@ -58,13 +58,10 @@ class TabModalConfirmDialogViews : public TabModalConfirmDialog,
// TabModalConfirmDialogCloseDelegate:
virtual void CloseDialog() OVERRIDE;
- virtual void SetPreventCloseOnLoadStart(bool prevent) OVERRIDE;
// views::LinkListener:
virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
- content::WebContents* web_contents_;
-
scoped_ptr<TabModalConfirmDialogDelegate> delegate_;
// The message box view whose commands we handle.
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 32e6012..b22c90e 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -92,8 +92,8 @@ enum UserActionBuckets {
FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
PREVIEW_FAILED,
PREVIEW_STARTED,
- INITIATOR_CRASHED, // UNUSED
- INITIATOR_CLOSED,
+ INITIATOR_TAB_CRASHED, // UNUSED
+ INITIATOR_TAB_CLOSED,
PRINT_WITH_CLOUD_PRINT,
USERACTION_BUCKET_BOUNDARY
};
@@ -157,8 +157,8 @@ void ReportGcpPromoHistogram(enum GcpPromoBuckets event) {
// Name of a dictionary field holding cloud print related data;
const char kAppState[] = "appState";
-// Name of a dictionary field holding the initiator title.
-const char kInitiatorTitle[] = "initiatorTitle";
+// Name of a dictionary field holding the initiator tab title.
+const char kInitiatorTabTitle[] = "initiatorTabTitle";
// Name of a dictionary field holding the measurement system according to the
// locale.
const char kMeasurementSystem[] = "measurementSystem";
@@ -445,9 +445,9 @@ void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
// Increment request count.
++regenerate_preview_request_count_;
- WebContents* initiator = GetInitiator();
- if (!initiator) {
- ReportUserActionHistogram(INITIATOR_CLOSED);
+ WebContents* initiator_tab = GetInitiatorTab();
+ if (!initiator_tab) {
+ ReportUserActionHistogram(INITIATOR_TAB_CLOSED);
print_preview_ui->OnClosePrintPreviewDialog();
return;
}
@@ -461,9 +461,9 @@ void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
}
if (display_header_footer) {
settings->SetString(printing::kSettingHeaderFooterTitle,
- initiator->GetTitle());
+ initiator_tab->GetTitle());
std::string url;
- NavigationEntry* entry = initiator->GetController().GetActiveEntry();
+ NavigationEntry* entry = initiator_tab->GetController().GetActiveEntry();
if (entry)
url = entry->GetVirtualURL().spec();
settings->SetString(printing::kSettingHeaderFooterURL, url);
@@ -491,7 +491,7 @@ void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
}
VLOG(1) << "Print preview request start";
- RenderViewHost* rvh = initiator->GetRenderViewHost();
+ RenderViewHost* rvh = initiator_tab->GetRenderViewHost();
rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings));
}
@@ -503,9 +503,9 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint",
regenerate_preview_request_count_);
- WebContents* initiator = GetInitiator();
- if (initiator) {
- RenderViewHost* rvh = initiator->GetRenderViewHost();
+ WebContents* initiator_tab = GetInitiatorTab();
+ if (initiator_tab) {
+ RenderViewHost* rvh = initiator_tab->GetRenderViewHost();
rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->GetRoutingID()));
}
@@ -556,15 +556,15 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
ReportUserActionHistogram(PRINT_TO_PRINTER);
ReportPrintSettingsStats(*settings);
- // This tries to activate the initiator as well, so do not clear the
- // association with the initiator yet.
+ // This tries to activate the initiator tab as well, so do not clear the
+ // association with the initiator tab yet.
PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
web_ui()->GetController());
print_preview_ui->OnHidePreviewDialog();
- // Do this so the initiator can open a new print preview dialog, while the
- // current print preview dialog is still handling its print job.
- ClearInitiatorDetails();
+ // Do this so the initiator tab can open a new print preview dialog, while
+ // the current print preview dialog is still handling its print job.
+ ClearInitiatorTabDetails();
// The PDF being printed contains only the pages that the user selected,
// so ignore the page range and print all pages.
@@ -583,9 +583,9 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
// printing has finished. Then the dialog closes and PrintPreviewDone() gets
// called. In the case below, since the preview dialog will be hidden and
// not closed, we need to make this call.
- if (initiator) {
+ if (initiator_tab) {
printing::PrintViewManager* print_view_manager =
- printing::PrintViewManager::FromWebContents(initiator);
+ printing::PrintViewManager::FromWebContents(initiator_tab);
print_view_manager->PrintPreviewDone();
}
}
@@ -601,7 +601,7 @@ void PrintPreviewHandler::PrintToPdf() {
PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
web_ui()->GetController());
// Pre-populating select file dialog with print job title.
- string16 print_job_title_utf16 = print_preview_ui->initiator_title();
+ string16 print_job_title_utf16 = print_preview_ui->initiator_tab_title();
#if defined(OS_WIN)
base::FilePath::StringType print_job_title(print_job_title_utf16);
@@ -627,11 +627,11 @@ void PrintPreviewHandler::HandleHidePreview(const ListValue* /*args*/) {
void PrintPreviewHandler::HandleCancelPendingPrintRequest(
const ListValue* /*args*/) {
- WebContents* initiator = GetInitiator();
- if (initiator)
- ClearInitiatorDetails();
- gfx::NativeWindow parent = initiator ?
- initiator->GetView()->GetTopLevelNativeWindow() :
+ WebContents* initiator_tab = GetInitiatorTab();
+ if (initiator_tab)
+ ClearInitiatorTabDetails();
+ gfx::NativeWindow parent = initiator_tab ?
+ initiator_tab->GetView()->GetTopLevelNativeWindow() :
NULL;
chrome::ShowPrintErrorDialog(parent);
}
@@ -737,12 +737,12 @@ void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* /*args*/) {
ReportStats();
ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG);
- WebContents* initiator = GetInitiator();
- if (!initiator)
+ WebContents* initiator_tab = GetInitiatorTab();
+ if (!initiator_tab)
return;
printing::PrintViewManager* print_view_manager =
- printing::PrintViewManager::FromWebContents(initiator);
+ printing::PrintViewManager::FromWebContents(initiator_tab);
print_view_manager->set_observer(this);
print_view_manager->PrintForSystemDialogNow();
@@ -848,7 +848,7 @@ void PrintPreviewHandler::HandleForceOpenNewTab(const ListValue* args) {
std::string url;
if (!args->GetString(0, &url))
return;
- Browser* browser = chrome::FindBrowserWithWebContents(GetInitiator());
+ Browser* browser = chrome::FindBrowserWithWebContents(GetInitiatorTab());
if (!browser)
return;
chrome::AddSelectedTabWithURL(browser,
@@ -863,8 +863,8 @@ void PrintPreviewHandler::SendInitialSettings(
web_ui()->GetController());
base::DictionaryValue initial_settings;
- initial_settings.SetString(kInitiatorTitle,
- print_preview_ui->initiator_title());
+ initial_settings.SetString(kInitiatorTabTitle,
+ print_preview_ui->initiator_tab_title());
initial_settings.SetBoolean(printing::kSettingPreviewModifiable,
print_preview_ui->source_is_modifiable());
initial_settings.SetString(printing::kSettingPrinterName, default_printer);
@@ -944,12 +944,12 @@ void PrintPreviewHandler::SendCloudPrintJob(const base::RefCountedBytes* data) {
web_ui()->CallJavascriptFunction("printToCloud", data_value);
}
-WebContents* PrintPreviewHandler::GetInitiator() const {
+WebContents* PrintPreviewHandler::GetInitiatorTab() const {
printing::PrintPreviewDialogController* dialog_controller =
printing::PrintPreviewDialogController::GetInstance();
if (!dialog_controller)
return NULL;
- return dialog_controller->GetInitiator(preview_web_contents());
+ return dialog_controller->GetInitiatorTab(preview_web_contents());
}
void PrintPreviewHandler::OnPrintDialogShown() {
@@ -991,12 +991,12 @@ void PrintPreviewHandler::SelectFile(const base::FilePath& default_filename) {
}
void PrintPreviewHandler::OnPrintPreviewDialogDestroyed() {
- WebContents* initiator = GetInitiator();
- if (!initiator)
+ WebContents* initiator_tab = GetInitiatorTab();
+ if (!initiator_tab)
return;
printing::PrintViewManager* print_view_manager =
- printing::PrintViewManager::FromWebContents(initiator);
+ printing::PrintViewManager::FromWebContents(initiator_tab);
print_view_manager->set_observer(NULL);
}
@@ -1055,18 +1055,18 @@ void PrintPreviewHandler::FileSelectionCanceled(void* params) {
print_preview_ui->OnFileSelectionCancelled();
}
-void PrintPreviewHandler::ClearInitiatorDetails() {
- WebContents* initiator = GetInitiator();
- if (!initiator)
+void PrintPreviewHandler::ClearInitiatorTabDetails() {
+ WebContents* initiator_tab = GetInitiatorTab();
+ if (!initiator_tab)
return;
- // We no longer require the initiator details. Remove those details associated
- // with the preview dialog to allow the initiator to create another preview
- // dialog.
+ // We no longer require the initiator tab details. Remove those details
+ // associated with the preview dialog to allow the initiator tab to create
+ // another preview dialog.
printing::PrintPreviewDialogController* dialog_controller =
printing::PrintPreviewDialogController::GetInstance();
if (dialog_controller)
- dialog_controller->EraseInitiatorInfo(preview_web_contents());
+ dialog_controller->EraseInitiatorTabInfo(preview_web_contents());
}
bool PrintPreviewHandler::GetPreviewDataAndTitle(
@@ -1085,7 +1085,7 @@ bool PrintPreviewHandler::GetPreviewDataAndTitle(
DCHECK(tmp_data->size() && tmp_data->front());
*data = tmp_data;
- *title = print_preview_ui->initiator_title();
+ *title = print_preview_ui->initiator_tab_title();
return true;
}
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.h b/chrome/browser/ui/webui/print_preview/print_preview_handler.h
index 36ec0a9..6dde25d 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.h
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.h
@@ -182,8 +182,8 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// Asks the browser to show the cloud print dialog.
void PrintWithCloudPrintDialog();
- // Gets the initiator for the print preview dialog.
- content::WebContents* GetInitiator() const;
+ // Gets the initiator tab for the print preview dialog.
+ content::WebContents* GetInitiatorTab() const;
// Closes the preview dialog.
void ClosePreviewDialog();
@@ -191,8 +191,8 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// Adds all the recorded stats taken so far to histogram counts.
void ReportStats();
- // Clears initiator details for the print preview dialog.
- void ClearInitiatorDetails();
+ // Clears initiator tab details for the print preview dialog.
+ void ClearInitiatorTabDetails();
// Posts a task to save |data| to pdf at |print_to_pdf_path_|.
void PostPrintToPdfTask();
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
index ca4c7e4..142ac95 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
@@ -388,9 +388,9 @@ int PrintPreviewUI::GetAvailableDraftPageCount() {
return print_preview_data_service()->GetAvailableDraftPageCount(id_);
}
-void PrintPreviewUI::SetInitiatorTitle(
+void PrintPreviewUI::SetInitiatorTabTitle(
const string16& job_title) {
- initiator_title_ = job_title;
+ initiator_tab_title_ = job_title;
}
// static
@@ -431,7 +431,7 @@ void PrintPreviewUI::OnPrintPreviewDialogClosed() {
OnClosePrintPreviewDialog();
}
-void PrintPreviewUI::OnInitiatorClosed() {
+void PrintPreviewUI::OnInitiatorTabClosed() {
WebContents* preview_dialog = web_ui()->GetWebContents();
printing::BackgroundPrintingManager* background_printing_manager =
g_browser_process->background_printing_manager();
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.h b/chrome/browser/ui/webui/print_preview/print_preview_ui.h
index 1cd81e3..51fdd021 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui.h
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.h
@@ -53,9 +53,9 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
int GetAvailableDraftPageCount();
// Setters
- void SetInitiatorTitle(const string16& initiator_title);
+ void SetInitiatorTabTitle(const string16& initiator_tab_title);
- string16 initiator_title() { return initiator_title_; }
+ string16 initiator_tab_title() { return initiator_tab_title_; }
bool source_is_modifiable() { return source_is_modifiable_; }
@@ -109,8 +109,8 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
void OnReusePreviewData(int preview_request_id);
// Notifies the Web UI that preview dialog has been destroyed. This is the
- // last chance to communicate with the initiator before the association is
- // erased.
+ // last chance to communicate with the initiator tab before the association
+ // is erased.
void OnPrintPreviewDialogDestroyed();
// Notifies the Web UI that the print preview failed to render.
@@ -120,9 +120,9 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
// closed, which may occur for several reasons, e.g. tab closure or crash.
void OnPrintPreviewDialogClosed();
- // Notifies the Web UI that initiator is closed, so we can disable all the
- // controls that need the initiator for generating the preview data.
- void OnInitiatorClosed();
+ // Notifies the Web UI that initiator tab is closed, so we can disable all the
+ // controls that need the initiator tab for generating the preview data.
+ void OnInitiatorTabClosed();
// Notifies the Web UI renderer that file selection has been cancelled.
void OnFileSelectionCancelled();
@@ -181,9 +181,9 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
// Indicates whether only the selection should be printed.
bool print_selection_only_;
- // Store the initiator title, used for populating the print preview dialog
+ // Store the initiator tab title, used for populating the print preview dialog
// title.
- string16 initiator_title_;
+ string16 initiator_tab_title_;
// Keeps track of whether OnClosePrintPreviewDialog() has been called or not.
bool dialog_closed_;
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
index 0f48f49..8d813fd 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
@@ -61,24 +61,26 @@ void PrintPreviewUIUnitTest::SetUp() {
chrome::NewTab(browser());
}
-// Create/Get a preview tab for initiator.
+// Create/Get a preview tab for initiator tab.
TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) {
- WebContents* initiator = browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(initiator);
- EXPECT_FALSE(IsShowingWebContentsModalDialog(initiator));
+ WebContents* initiator_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(initiator_tab);
+ EXPECT_FALSE(IsShowingWebContentsModalDialog(initiator_tab));
printing::PrintPreviewDialogController* controller =
printing::PrintPreviewDialogController::GetInstance();
ASSERT_TRUE(controller);
printing::PrintViewManager* print_view_manager =
- printing::PrintViewManager::FromWebContents(initiator);
+ printing::PrintViewManager::FromWebContents(initiator_tab);
print_view_manager->PrintPreviewNow(false);
- WebContents* preview_dialog = controller->GetOrCreatePreviewDialog(initiator);
+ WebContents* preview_dialog =
+ controller->GetOrCreatePreviewDialog(initiator_tab);
- EXPECT_NE(initiator, preview_dialog);
+ EXPECT_NE(initiator_tab, preview_dialog);
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator));
+ EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator_tab));
PrintPreviewUI* preview_ui = static_cast<PrintPreviewUI*>(
preview_dialog->GetWebUI()->GetController());
@@ -117,21 +119,23 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) {
// Set and get the individual draft pages.
TEST_F(PrintPreviewUIUnitTest, PrintPreviewDraftPages) {
- WebContents* initiator = browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(initiator);
+ WebContents* initiator_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(initiator_tab);
printing::PrintPreviewDialogController* controller =
printing::PrintPreviewDialogController::GetInstance();
ASSERT_TRUE(controller);
printing::PrintViewManager* print_view_manager =
- printing::PrintViewManager::FromWebContents(initiator);
+ printing::PrintViewManager::FromWebContents(initiator_tab);
print_view_manager->PrintPreviewNow(false);
- WebContents* preview_dialog = controller->GetOrCreatePreviewDialog(initiator);
+ WebContents* preview_dialog =
+ controller->GetOrCreatePreviewDialog(initiator_tab);
- EXPECT_NE(initiator, preview_dialog);
+ EXPECT_NE(initiator_tab, preview_dialog);
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator));
+ EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator_tab));
PrintPreviewUI* preview_ui = static_cast<PrintPreviewUI*>(
preview_dialog->GetWebUI()->GetController());
@@ -177,21 +181,23 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewDraftPages) {
// Test the browser-side print preview cancellation functionality.
TEST_F(PrintPreviewUIUnitTest, GetCurrentPrintPreviewStatus) {
- WebContents* initiator = browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(initiator);
+ WebContents* initiator_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(initiator_tab);
printing::PrintPreviewDialogController* controller =
printing::PrintPreviewDialogController::GetInstance();
ASSERT_TRUE(controller);
printing::PrintViewManager* print_view_manager =
- printing::PrintViewManager::FromWebContents(initiator);
+ printing::PrintViewManager::FromWebContents(initiator_tab);
print_view_manager->PrintPreviewNow(false);
- WebContents* preview_dialog = controller->GetOrCreatePreviewDialog(initiator);
+ WebContents* preview_dialog =
+ controller->GetOrCreatePreviewDialog(initiator_tab);
- EXPECT_NE(initiator, preview_dialog);
+ EXPECT_NE(initiator_tab, preview_dialog);
EXPECT_EQ(1, browser()->tab_strip_model()->count());
- EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator));
+ EXPECT_TRUE(IsShowingWebContentsModalDialog(initiator_tab));
PrintPreviewUI* preview_ui = static_cast<PrintPreviewUI*>(
preview_dialog->GetWebUI()->GetController());
diff --git a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc
index d5b8ed9..8c37a05 100644
--- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc
+++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/common/url_constants.h"
-#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "grit/browser_resources.h"
@@ -29,7 +28,6 @@
using content::WebContents;
using content::WebUIMessageHandler;
-using web_modal::WebContentsModalDialogManager;
// static
TabModalConfirmDialog* TabModalConfirmDialog::Create(
@@ -44,8 +42,7 @@ const int kDialogHeight = 120;
TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI(
TabModalConfirmDialogDelegate* delegate,
WebContents* web_contents)
- : web_contents_(web_contents),
- delegate_(delegate) {
+ : delegate_(delegate) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
content::WebUIDataSource* data_source = content::WebUIDataSource::Create(
@@ -56,7 +53,7 @@ TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI(
constrained_web_dialog_delegate_ =
CreateConstrainedWebDialog(profile, this, NULL, web_contents);
- delegate_->set_operations_delegate(this);
+ delegate_->set_close_delegate(this);
}
ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const {
@@ -98,7 +95,7 @@ void TabModalConfirmDialogWebUI::OnDialogClosed(
NOTREACHED() << "Missing or unreadable response from dialog";
}
- delegate_->set_operations_delegate(NULL);
+ delegate_->set_close_delegate(NULL);
if (accepted)
delegate_->Accept();
else
@@ -123,11 +120,3 @@ void TabModalConfirmDialogWebUI::CancelTabModalDialog() {
void TabModalConfirmDialogWebUI::CloseDialog() {
constrained_web_dialog_delegate_->OnDialogCloseFromWebUI();
}
-
-void TabModalConfirmDialogWebUI::SetPreventCloseOnLoadStart(bool prevent) {
- web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->SetPreventCloseOnLoadStart(
- constrained_web_dialog_delegate_->GetNativeDialog(),
- prevent);
-}
diff --git a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h
index 592a9f2..c77ac74 100644
--- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h
+++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h
@@ -59,9 +59,6 @@ class TabModalConfirmDialogWebUI : public TabModalConfirmDialog,
// TabModalConfirmDialogCloseDelegate:
virtual void CloseDialog() OVERRIDE;
- virtual void SetPreventCloseOnLoadStart(bool prevent) OVERRIDE;
-
- content::WebContents* web_contents_;
scoped_ptr<TabModalConfirmDialogDelegate> delegate_;
diff --git a/components/web_modal/web_contents_modal_dialog_manager.cc b/components/web_modal/web_contents_modal_dialog_manager.cc
index 461fb65..0e07f8d 100644
--- a/components/web_modal/web_contents_modal_dialog_manager.cc
+++ b/components/web_modal/web_contents_modal_dialog_manager.cc
@@ -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 @@ WebContentsModalDialogManager::~WebContentsModalDialogManager() {
void WebContentsModalDialogManager::ShowDialog(
NativeWebContentsModalDialog dialog) {
- child_dialogs_.push_back(DialogState(dialog));
+ child_dialogs_.push_back(dialog);
native_manager_->ManageDialog(dialog);
@@ -43,15 +44,7 @@ bool WebContentsModalDialogManager::IsShowingDialog() const {
void WebContentsModalDialogManager::FocusTopmostDialog() {
DCHECK(!child_dialogs_.empty());
- native_manager_->FocusDialog(child_dialogs_.front().dialog);
-}
-
-void WebContentsModalDialogManager::SetPreventCloseOnLoadStart(
- NativeWebContentsModalDialog dialog,
- bool prevent) {
- WebContentsModalDialogList::iterator loc = FindDialogState(dialog);
- DCHECK(loc != child_dialogs_.end());
- loc->prevent_close_on_load_start = true;
+ native_manager_->FocusDialog(child_dialogs_.front());
}
content::WebContents* WebContentsModalDialogManager::GetWebContents() const {
@@ -60,7 +53,8 @@ content::WebContents* WebContentsModalDialogManager::GetWebContents() const {
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 @@ void WebContentsModalDialogManager::WillClose(
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 @@ void WebContentsModalDialogManager::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- 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().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);
- }
+ 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());
}
WebContentsModalDialogManager::WebContentsModalDialogManager(
@@ -103,34 +93,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));
}
-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 @@ void WebContentsModalDialogManager::CloseAllDialogs() {
// 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) {
diff --git a/components/web_modal/web_contents_modal_dialog_manager.h b/components/web_modal/web_contents_modal_dialog_manager.h
index 00671b2..e2548c0 100644
--- a/components/web_modal/web_contents_modal_dialog_manager.h
+++ b/components/web_modal/web_contents_modal_dialog_manager.h
@@ -45,11 +45,6 @@ class WebContentsModalDialogManager
// calling this function.
void FocusTopmostDialog();
- // Set to true to prevent closing the window when a page load starts on the
- // WebContents.
- void SetPreventCloseOnLoadStart(NativeWebContentsModalDialog dialog,
- bool prevent);
-
// Overriden from NativeWebContentsModalDialogManagerDelegate:
virtual content::WebContents* GetWebContents() const OVERRIDE;
// Called when a WebContentsModalDialogs we own is about to be closed.
@@ -81,18 +76,7 @@ class WebContentsModalDialogManager
explicit WebContentsModalDialogManager(content::WebContents* web_contents);
friend class content::WebContentsUserData<WebContentsModalDialogManager>;
- struct DialogState {
- explicit DialogState(NativeWebContentsModalDialog dialog);
-
- NativeWebContentsModalDialog dialog;
- bool prevent_close_on_load_start;
- };
-
- typedef std::deque<DialogState> WebContentsModalDialogList;
-
- // Utility function to get the dialog state for a dialog.
- WebContentsModalDialogList::iterator FindDialogState(
- NativeWebContentsModalDialog dialog);
+ typedef std::deque<NativeWebContentsModalDialog> WebContentsModalDialogList;
// Blocks/unblocks interaction with renderer process.
void BlockWebContentsInteraction(bool blocked);
@@ -103,6 +87,9 @@ 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;