OLD | NEW |
---|---|
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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 // Returns true if |url| is a print preview url. | 72 // Returns true if |url| is a print preview url. |
73 static bool IsPrintPreviewURL(const GURL& url); | 73 static bool IsPrintPreviewURL(const GURL& url); |
74 | 74 |
75 // Erase the initiator info associated with |preview_dialog|. | 75 // Erase the initiator info associated with |preview_dialog|. |
76 void EraseInitiatorInfo(content::WebContents* preview_dialog); | 76 void EraseInitiatorInfo(content::WebContents* preview_dialog); |
77 | 77 |
78 bool is_creating_print_preview_dialog() const { | 78 bool is_creating_print_preview_dialog() const { |
79 return is_creating_print_preview_dialog_; | 79 return is_creating_print_preview_dialog_; |
80 } | 80 } |
81 | 81 |
82 void AddProxyDialogForWebContents(content::WebContents* source, | 82 void AddProxyDialogForWebContents(content::WebContents* distilled_contents, |
Lei Zhang
2015/08/14 05:44:35
It's not clear what |source| and |target| refers t
| |
83 content::WebContents* target); | 83 content::WebContents* initiator); |
84 | 84 |
85 void RemoveProxyDialogForWebContents(content::WebContents* source); | 85 void RemoveProxyDialogForWebContents( |
86 content::WebContents* distilled_contents); | |
86 | 87 |
87 private: | 88 private: |
88 friend class base::RefCounted<PrintPreviewDialogController>; | 89 friend class base::RefCounted<PrintPreviewDialogController>; |
89 | 90 |
90 // 1:1 relationship between a print preview dialog and its initiator tab. | 91 // 1:1 relationship between a print preview dialog and its initiator tab. |
91 // Key: Print preview dialog. | 92 // Key: Print preview dialog. |
92 // Value: Initiator. | 93 // Value: Initiator. |
93 using PrintPreviewDialogMap = | 94 using PrintPreviewDialogMap = |
94 std::map<content::WebContents*, content::WebContents*>; | 95 std::map<content::WebContents*, content::WebContents*>; |
95 | 96 |
97 // 1:1 relationship between the distilled contents and its initiator tab. | |
98 // Key: Distilled contents. | |
99 // Value: Initiator. | |
100 using DistilledContentsMap = | |
101 std::map<content::WebContents*, content::WebContents*>; | |
102 | |
96 ~PrintPreviewDialogController() override; | 103 ~PrintPreviewDialogController() override; |
97 | 104 |
98 // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when | 105 // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when |
99 // the initiator renderer crashed. | 106 // the initiator renderer crashed. |
100 void OnRendererProcessClosed(content::RenderProcessHost* rph); | 107 void OnRendererProcessClosed(content::RenderProcessHost* rph); |
101 | 108 |
102 // Handler for the WEB_CONTENTS_DESTROYED notification. This is observed when | 109 // Handler for the WEB_CONTENTS_DESTROYED notification. This is observed when |
103 // either WebContents is closed. | 110 // either WebContents is closed. |
104 void OnWebContentsDestroyed(content::WebContents* contents); | 111 void OnWebContentsDestroyed(content::WebContents* contents); |
105 | 112 |
(...skipping 14 matching lines...) Expand all Loading... | |
120 void AddObservers(content::WebContents* contents); | 127 void AddObservers(content::WebContents* contents); |
121 void RemoveObservers(content::WebContents* contents); | 128 void RemoveObservers(content::WebContents* contents); |
122 | 129 |
123 // Removes WebContents when they close/crash/navigate. | 130 // Removes WebContents when they close/crash/navigate. |
124 void RemoveInitiator(content::WebContents* initiator); | 131 void RemoveInitiator(content::WebContents* initiator); |
125 void RemovePreviewDialog(content::WebContents* preview_dialog); | 132 void RemovePreviewDialog(content::WebContents* preview_dialog); |
126 | 133 |
127 // Mapping between print preview dialog and the corresponding initiator. | 134 // Mapping between print preview dialog and the corresponding initiator. |
128 PrintPreviewDialogMap preview_dialog_map_; | 135 PrintPreviewDialogMap preview_dialog_map_; |
129 | 136 |
130 PrintPreviewDialogMap proxied_dialog_map_; | 137 // Mapping between distilled contents and the corresponding initiator. |
Lei Zhang
2015/08/14 05:44:35
Please do not reuse PrintPreviewDialogMap. Even th
| |
138 DistilledContentsMap proxied_dialog_map_; | |
131 | 139 |
132 // A registrar for listening to notifications. | 140 // A registrar for listening to notifications. |
133 content::NotificationRegistrar registrar_; | 141 content::NotificationRegistrar registrar_; |
134 | 142 |
135 // True if the controller is waiting for a new preview dialog via | 143 // True if the controller is waiting for a new preview dialog via |
136 // content::NAVIGATION_TYPE_NEW_PAGE. | 144 // content::NAVIGATION_TYPE_NEW_PAGE. |
137 bool waiting_for_new_preview_page_; | 145 bool waiting_for_new_preview_page_; |
138 | 146 |
139 // Whether the PrintPreviewDialogController is in the middle of creating a | 147 // Whether the PrintPreviewDialogController is in the middle of creating a |
140 // print preview dialog. | 148 // print preview dialog. |
141 bool is_creating_print_preview_dialog_; | 149 bool is_creating_print_preview_dialog_; |
142 | 150 |
143 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogController); | 151 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogController); |
144 }; | 152 }; |
145 | 153 |
146 } // namespace printing | 154 } // namespace printing |
147 | 155 |
148 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_ | 156 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_ |
OLD | NEW |