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

Side by Side 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: Don't observe nav committed for initiator tab 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Erase the initiator tab info associated with |preview_tab|. 69 // Erase the initiator tab info associated with |preview_tab|.
70 void EraseInitiatorTabInfo(content::WebContents* preview_tab); 70 void EraseInitiatorTabInfo(content::WebContents* preview_tab);
71 71
72 bool is_creating_print_preview_dialog() const { 72 bool is_creating_print_preview_dialog() const {
73 return is_creating_print_preview_dialog_; 73 return is_creating_print_preview_dialog_;
74 } 74 }
75 75
76 private: 76 private:
77 friend class base::RefCounted<PrintPreviewDialogController>; 77 friend class base::RefCounted<PrintPreviewDialogController>;
78 78
79 // Used to distinguish between the two varieties of WebContents dealt with by
80 // this class.
81 enum TabType {
Lei Zhang 2013/06/27 21:36:18 nit: the preview is not actually a tab, so PREVIEW
Mike Wittman 2013/06/27 23:39:38 Done. With the web contents modal dialog work, th
82 INITIATOR_TAB,
83 PREVIEW_TAB
84 };
85
79 // 1:1 relationship between a print preview dialog and its initiator tab. 86 // 1:1 relationship between a print preview dialog and its initiator tab.
80 // Key: Print preview dialog. 87 // Key: Print preview dialog.
81 // Value: Initiator tab. 88 // Value: Initiator tab.
82 typedef std::map<content::WebContents*, content::WebContents*> 89 typedef std::map<content::WebContents*, content::WebContents*>
83 PrintPreviewDialogMap; 90 PrintPreviewDialogMap;
84 91
85 virtual ~PrintPreviewDialogController(); 92 virtual ~PrintPreviewDialogController();
86 93
87 // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when 94 // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when
88 // the initiator renderer crashed. 95 // the initiator renderer crashed.
(...skipping 10 matching lines...) Expand all
99 106
100 // Creates a new print preview dialog. 107 // Creates a new print preview dialog.
101 content::WebContents* CreatePrintPreviewDialog( 108 content::WebContents* CreatePrintPreviewDialog(
102 content::WebContents* initiator_tab); 109 content::WebContents* initiator_tab);
103 110
104 // Helper function to store the title of the initiator tab associated with 111 // Helper function to store the title of the initiator tab associated with
105 // |preview_dialog| in |preview_dialog|'s PrintPreviewUI. 112 // |preview_dialog| in |preview_dialog|'s PrintPreviewUI.
106 void SaveInitiatorTabTitle(content::WebContents* preview_dialog); 113 void SaveInitiatorTabTitle(content::WebContents* preview_dialog);
107 114
108 // Adds/Removes observers for notifications from |contents|. 115 // Adds/Removes observers for notifications from |contents|.
109 void AddObservers(content::WebContents* contents); 116 void AddObservers(content::WebContents* contents, TabType tab_type);
110 void RemoveObservers(content::WebContents* contents); 117 void RemoveObservers(content::WebContents* contents, TabType tab_type);
111 118
112 // Removes WebContents when they close/crash/navigate. 119 // Removes WebContents when they close/crash/navigate.
113 void RemoveInitiatorTab(content::WebContents* initiator_tab); 120 void RemoveInitiatorTab(content::WebContents* initiator_tab);
114 void RemovePreviewDialog(content::WebContents* preview_dialog); 121 void RemovePreviewDialog(content::WebContents* preview_dialog);
115 122
116 // Mapping between print preview dialog and the corresponding initiator tab. 123 // Mapping between print preview dialog and the corresponding initiator tab.
117 PrintPreviewDialogMap preview_dialog_map_; 124 PrintPreviewDialogMap preview_dialog_map_;
118 125
119 // A registrar for listening notifications. 126 // A registrar for listening notifications.
120 content::NotificationRegistrar registrar_; 127 content::NotificationRegistrar registrar_;
121 128
122 // True if the controller is waiting for a new preview dialog via 129 // True if the controller is waiting for a new preview dialog via
123 // content::NAVIGATION_TYPE_NEW_PAGE. 130 // content::NAVIGATION_TYPE_NEW_PAGE.
124 bool waiting_for_new_preview_page_; 131 bool waiting_for_new_preview_page_;
125 132
126 // Whether the PrintPreviewDialogController is in the middle of creating a 133 // Whether the PrintPreviewDialogController is in the middle of creating a
127 // print preview dialog. 134 // print preview dialog.
128 bool is_creating_print_preview_dialog_; 135 bool is_creating_print_preview_dialog_;
129 136
130 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogController); 137 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogController);
131 }; 138 };
132 139
133 } // namespace printing 140 } // namespace printing
134 141
135 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_ 142 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698