summaryrefslogtreecommitdiffstats
path: root/chrome/browser/printing/print_preview_dialog_controller.h
diff options
context:
space:
mode:
authorwittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 11:37:27 +0000
committerwittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 11:37:27 +0000
commitfcf88b99fc6e50872629217f3ae1f9e8786740c3 (patch)
tree0f82abe482984ba6b0f3b801ee00dd94edc0b989 /chrome/browser/printing/print_preview_dialog_controller.h
parent2244aafe0754958d0dfa5b3f7861e07d3363bcbd (diff)
downloadchromium_src-fcf88b99fc6e50872629217f3ae1f9e8786740c3.zip
chromium_src-fcf88b99fc6e50872629217f3ae1f9e8786740c3.tar.gz
chromium_src-fcf88b99fc6e50872629217f3ae1f9e8786740c3.tar.bz2
Reland "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 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=211058 Review URL: https://chromiumcodereview.appspot.com/17500003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212329 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/printing/print_preview_dialog_controller.h')
-rw-r--r--chrome/browser/printing/print_preview_dialog_controller.h52
1 files changed, 30 insertions, 22 deletions
diff --git a/chrome/browser/printing/print_preview_dialog_controller.h b/chrome/browser/printing/print_preview_dialog_controller.h
index 0ce70db..da5d385 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 tab that initiates the printing operation is the
-// initiator tab, and the constrained dialog that shows the print preview is
-// the print preview dialog.
+// 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.
// 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_tab|.
+ // Initiate print preview for |initiator|.
// Call this instead of GetOrCreatePreviewDialog().
- static void PrintPreview(content::WebContents* initiator_tab);
+ static void PrintPreview(content::WebContents* initiator);
- // Get/Create the print preview dialog for |initiator_tab|.
+ // Get/Create the print preview dialog for |initiator|.
// Exposed for unit tests.
content::WebContents* GetOrCreatePreviewDialog(
- content::WebContents* initiator_tab);
+ content::WebContents* initiator);
// 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 tab for |preview_dialog|.
- // Returns NULL if no initiator tab exists for |preview_dialog|.
- content::WebContents* GetInitiatorTab(content::WebContents* preview_dialog);
+ // Returns the initiator for |preview_dialog|.
+ // Returns NULL if no initiator exists for |preview_dialog|.
+ content::WebContents* GetInitiator(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 tab info associated with |preview_tab|.
- void EraseInitiatorTabInfo(content::WebContents* preview_tab);
+ // Erase the initiator info associated with |preview_dialog|.
+ void EraseInitiatorInfo(content::WebContents* preview_dialog);
bool is_creating_print_preview_dialog() const {
return is_creating_print_preview_dialog_;
@@ -76,9 +76,16 @@ class PrintPreviewDialogController
private:
friend class base::RefCounted<PrintPreviewDialogController>;
- // 1:1 relationship between a print preview dialog and its initiator tab.
+ // 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.
// Key: Print preview dialog.
- // Value: Initiator tab.
+ // Value: Initiator.
typedef std::map<content::WebContents*, content::WebContents*>
PrintPreviewDialogMap;
@@ -99,21 +106,22 @@ class PrintPreviewDialogController
// Creates a new print preview dialog.
content::WebContents* CreatePrintPreviewDialog(
- content::WebContents* initiator_tab);
+ content::WebContents* initiator);
- // Helper function to store the title of the initiator tab associated with
+ // Helper function to store the title of the initiator associated with
// |preview_dialog| in |preview_dialog|'s PrintPreviewUI.
- void SaveInitiatorTabTitle(content::WebContents* preview_dialog);
+ void SaveInitiatorTitle(content::WebContents* preview_dialog);
// Adds/Removes observers for notifications from |contents|.
- void AddObservers(content::WebContents* contents);
- void RemoveObservers(content::WebContents* contents);
+ void AddObservers(content::WebContents* contents, ContentsType contents_type);
+ void RemoveObservers(content::WebContents* contents,
+ ContentsType contents_type);
// Removes WebContents when they close/crash/navigate.
- void RemoveInitiatorTab(content::WebContents* initiator_tab);
+ void RemoveInitiator(content::WebContents* initiator);
void RemovePreviewDialog(content::WebContents* preview_dialog);
- // Mapping between print preview dialog and the corresponding initiator tab.
+ // Mapping between print preview dialog and the corresponding initiator.
PrintPreviewDialogMap preview_dialog_map_;
// A registrar for listening notifications.