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

Unified Diff: chrome/browser/printing/print_preview_dialog_controller.h

Issue 17500003: Close web contents modal dialogs on content load start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compilation fixes, change "inhibit" variable names Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/printing/print_preview_dialog_controller.h
diff --git a/chrome/browser/printing/print_preview_dialog_controller.h b/chrome/browser/printing/print_preview_dialog_controller.h
index 0ce70db172da1131dd2aff6e6b80627a5ecf8b86..da5d3851d446d0be7ecc1d1a264fa0b295c006fa 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.
« no previous file with comments | « chrome/browser/printing/background_printing_manager.cc ('k') | chrome/browser/printing/print_preview_dialog_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698