OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "chrome/browser/printing/print_preview_data_service.h" | 14 #include "chrome/browser/printing/print_preview_data_service.h" |
15 #include "chrome/browser/ui/webui/constrained_html_ui.h" | 15 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
16 | 16 |
17 class PrintPreviewDataService; | 17 class PrintPreviewDataService; |
18 class PrintPreviewHandler; | 18 class PrintPreviewHandler; |
19 struct PrintHostMsg_DidGetPreviewPageCount_Params; | 19 struct PrintHostMsg_DidGetPreviewPageCount_Params; |
20 | 20 |
21 namespace printing { | 21 namespace printing { |
22 struct PageSizeMargins; | 22 struct PageSizeMargins; |
23 } | 23 } |
24 | 24 |
25 class PrintPreviewUI : public ConstrainedHtmlUI { | 25 class PrintPreviewUI : public ChromeWebUI { |
26 public: | 26 public: |
27 explicit PrintPreviewUI(TabContents* contents); | 27 explicit PrintPreviewUI(TabContents* contents); |
28 virtual ~PrintPreviewUI(); | 28 virtual ~PrintPreviewUI(); |
29 | 29 |
30 // Gets the print preview |data|. |index| is zero-based, and can be | 30 // Gets the print preview |data|. |index| is zero-based, and can be |
31 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to get the entire preview | 31 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to get the entire preview |
32 // document. | 32 // document. |
33 void GetPrintPreviewDataForIndex(int index, | 33 void GetPrintPreviewDataForIndex(int index, |
34 scoped_refptr<RefCountedBytes>* data); | 34 scoped_refptr<RefCountedBytes>* data); |
35 | 35 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // |preview_request_id| indicates which request resulted in this response. | 93 // |preview_request_id| indicates which request resulted in this response. |
94 void OnReusePreviewData(int preview_request_id); | 94 void OnReusePreviewData(int preview_request_id); |
95 | 95 |
96 // Notifies the Web UI that preview tab is destroyed. This is the last chance | 96 // Notifies the Web UI that preview tab is destroyed. This is the last chance |
97 // to communicate with the source tab before the association is erased. | 97 // to communicate with the source tab before the association is erased. |
98 void OnTabDestroyed(); | 98 void OnTabDestroyed(); |
99 | 99 |
100 // Notifies the Web UI that the print preview failed to render. | 100 // Notifies the Web UI that the print preview failed to render. |
101 void OnPrintPreviewFailed(); | 101 void OnPrintPreviewFailed(); |
102 | 102 |
103 // Notified the Web UI that this print preview tab's RenderProcess has been | |
104 // closed, which may occur for several reasons, e.g. tab closure or crash. | |
105 void OnPrintPreviewTabClosed(); | |
106 | |
107 // Notifies the Web UI that initiator tab is closed, so we can disable all the | 103 // Notifies the Web UI that initiator tab is closed, so we can disable all the |
108 // controls that need the initiator tab for generating the preview data. | 104 // controls that need the initiator tab for generating the preview data. |
109 void OnInitiatorTabClosed(); | 105 void OnInitiatorTabClosed(); |
110 | 106 |
| 107 // Notifies the Web UI that the initiator tab has crashed. |
| 108 void OnInitiatorTabCrashed(); |
| 109 |
111 // Notifies the Web UI renderer that file selection has been cancelled. | 110 // Notifies the Web UI renderer that file selection has been cancelled. |
112 void OnFileSelectionCancelled(); | 111 void OnFileSelectionCancelled(); |
113 | 112 |
114 // Notifies the Web UI that the printer is unavailable or its settings are | 113 // Notifies the Web UI that the printer is unavailable or its settings are |
115 // invalid. | 114 // invalid. |
116 void OnInvalidPrinterSettings(); | 115 void OnInvalidPrinterSettings(); |
117 | 116 |
118 // Notifies the Web UI to cancel the pending preview request. | 117 // Notifies the Web UI to cancel the pending preview request. |
119 void OnCancelPendingPreviewRequest(); | 118 void OnCancelPendingPreviewRequest(); |
120 | 119 |
121 // Hides the print preview tab. | |
122 void OnHidePreviewTab(); | |
123 | |
124 // Closes the print preview tab. | |
125 void OnClosePrintPreviewTab(); | |
126 | |
127 // Reload the printers list. | |
128 void OnReloadPrintersList(); | |
129 | |
130 private: | 120 private: |
131 friend class PrintPreviewHandlerTest; | 121 friend class PrintPreviewHandlerTest; |
132 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsCustom); | 122 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsCustom); |
133 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsDefault); | 123 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsDefault); |
134 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, | 124 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, |
135 StickyMarginsCustomThenDefault); | 125 StickyMarginsCustomThenDefault); |
136 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, | 126 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, |
137 GetLastUsedMarginSettingsCustom); | 127 GetLastUsedMarginSettingsCustom); |
138 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, | 128 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, |
139 GetLastUsedMarginSettingsDefault); | 129 GetLastUsedMarginSettingsDefault); |
(...skipping 15 matching lines...) Expand all Loading... |
155 // when the initiator tab is closed/crashed. | 145 // when the initiator tab is closed/crashed. |
156 std::string initiator_url_; | 146 std::string initiator_url_; |
157 | 147 |
158 // Indicates whether the source document can be modified. | 148 // Indicates whether the source document can be modified. |
159 bool source_is_modifiable_; | 149 bool source_is_modifiable_; |
160 | 150 |
161 // Store the initiator tab title, used for populating the print preview tab | 151 // Store the initiator tab title, used for populating the print preview tab |
162 // title. | 152 // title. |
163 string16 initiator_tab_title_; | 153 string16 initiator_tab_title_; |
164 | 154 |
165 // Keeps track of whether OnClosePrintPreviewTab() has been called or not. | |
166 bool tab_closed_; | |
167 | |
168 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); | 155 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); |
169 }; | 156 }; |
170 | 157 |
171 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 158 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
OLD | NEW |