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_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 class PrintSystemTaskProxy; | 21 class PrintSystemTaskProxy; |
22 class TabContentsWrapper; | 22 class TabContentsWrapper; |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 class DictionaryValue; | 25 class DictionaryValue; |
26 class FundamentalValue; | 26 class FundamentalValue; |
27 class StringValue; | 27 class StringValue; |
28 } | 28 } |
29 | 29 |
30 namespace printing { | 30 namespace printing { |
| 31 struct PageSizeMargins; |
31 class PrintBackend; | 32 class PrintBackend; |
32 } | 33 } |
33 | 34 |
34 // The handler for Javascript messages related to the print preview dialog. | 35 // The handler for Javascript messages related to the print preview dialog. |
35 class PrintPreviewHandler : public WebUIMessageHandler, | 36 class PrintPreviewHandler : public WebUIMessageHandler, |
36 public base::SupportsWeakPtr<PrintPreviewHandler>, | 37 public base::SupportsWeakPtr<PrintPreviewHandler>, |
37 public SelectFileDialog::Listener, | 38 public SelectFileDialog::Listener, |
38 public printing::PrintViewManagerObserver { | 39 public printing::PrintViewManagerObserver { |
39 public: | 40 public: |
40 PrintPreviewHandler(); | 41 PrintPreviewHandler(); |
(...skipping 25 matching lines...) Expand all Loading... |
66 // Called when the user press ctrl+shift+p to display the native system | 67 // Called when the user press ctrl+shift+p to display the native system |
67 // dialog. | 68 // dialog. |
68 void ShowSystemDialog(); | 69 void ShowSystemDialog(); |
69 | 70 |
70 private: | 71 private: |
71 friend class PrintSystemTaskProxy; | 72 friend class PrintSystemTaskProxy; |
72 | 73 |
73 TabContentsWrapper* preview_tab_wrapper() const; | 74 TabContentsWrapper* preview_tab_wrapper() const; |
74 TabContents* preview_tab() const; | 75 TabContents* preview_tab() const; |
75 | 76 |
76 // Gets the default printer. |args| is unused. | |
77 void HandleGetDefaultPrinter(const base::ListValue* args); | |
78 | |
79 // Gets the list of printers. |args| is unused. | 77 // Gets the list of printers. |args| is unused. |
80 void HandleGetPrinters(const base::ListValue* args); | 78 void HandleGetPrinters(const base::ListValue* args); |
81 | 79 |
82 // Asks the initiator renderer to generate a preview. First element of |args| | 80 // Asks the initiator renderer to generate a preview. First element of |args| |
83 // is a job settings JSON string. | 81 // is a job settings JSON string. |
84 void HandleGetPreview(const base::ListValue* args); | 82 void HandleGetPreview(const base::ListValue* args); |
85 | 83 |
86 // Gets the job settings from Web UI and initiate printing. First element of | 84 // Gets the job settings from Web UI and initiate printing. First element of |
87 // |args| is a job settings JSON string. | 85 // |args| is a job settings JSON string. |
88 void HandlePrint(const base::ListValue* args); | 86 void HandlePrint(const base::ListValue* args); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Asks the browser to show the native printer management dialog. | 123 // Asks the browser to show the native printer management dialog. |
126 // |args| is unused. | 124 // |args| is unused. |
127 void HandleManagePrinters(const base::ListValue* args); | 125 void HandleManagePrinters(const base::ListValue* args); |
128 | 126 |
129 // Asks the browser to show the cloud print dialog. | 127 // Asks the browser to show the cloud print dialog. |
130 void HandlePrintWithCloudPrint(); | 128 void HandlePrintWithCloudPrint(); |
131 | 129 |
132 // Asks the browser to close the preview tab. |args| is unused. | 130 // Asks the browser to close the preview tab. |args| is unused. |
133 void HandleClosePreviewTab(const base::ListValue* args); | 131 void HandleClosePreviewTab(const base::ListValue* args); |
134 | 132 |
135 // Asks the browser for the title of the initiator tab. | 133 // Asks the browser for several settings that are needed before the first |
136 // |args| is unused. | 134 // preview is displayed. |
137 void HandleGetInitiatorTabTitle(const base::ListValue* args); | 135 void HandleGetInitialSettings(const base::ListValue* args); |
138 | 136 |
139 // Asks the browser for the number formatting and measurement system according | 137 void SendInitialSettings( |
140 // to the current locale. | 138 const std::string& default_printer, |
141 void HandleGetNumberFormatAndMeasurementSystem(const base::ListValue* args); | 139 const std::string& cloud_print_data); |
142 | 140 |
143 // Sends the printer capabilities to the Web UI. |settings_info| contains | 141 // Sends the printer capabilities to the Web UI. |settings_info| contains |
144 // printer capabilities information. | 142 // printer capabilities information. |
145 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); | 143 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); |
146 | 144 |
147 // Sends the default printer to the Web UI. | |
148 void SendDefaultPrinter(const base::StringValue& default_printer, | |
149 const base::StringValue& cloud_print_data); | |
150 | |
151 // Send the list of printers to the Web UI. | 145 // Send the list of printers to the Web UI. |
152 void SetupPrinterList(const base::ListValue& printers); | 146 void SetupPrinterList(const base::ListValue& printers); |
153 | 147 |
154 // Send whether cloud print integration should be enabled. | 148 // Send whether cloud print integration should be enabled. |
155 void SendCloudPrintEnabled(); | 149 void SendCloudPrintEnabled(); |
156 | 150 |
157 // Send the PDF data to the cloud to print. | 151 // Send the PDF data to the cloud to print. |
158 void SendCloudPrintJob(const base::DictionaryValue& settings, | 152 void SendCloudPrintJob(const base::DictionaryValue& settings, |
159 std::string print_ticket); | 153 std::string print_ticket); |
160 | 154 |
(...skipping 11 matching lines...) Expand all Loading... |
172 | 166 |
173 // Hides the preview tab for printing. | 167 // Hides the preview tab for printing. |
174 void HidePreviewTab(); | 168 void HidePreviewTab(); |
175 | 169 |
176 // Clears initiator tab details for this preview tab. | 170 // Clears initiator tab details for this preview tab. |
177 void ClearInitiatorTabDetails(); | 171 void ClearInitiatorTabDetails(); |
178 | 172 |
179 // Posts a task to save to pdf at |print_to_pdf_path_|. | 173 // Posts a task to save to pdf at |print_to_pdf_path_|. |
180 void PostPrintToPdfTask(); | 174 void PostPrintToPdfTask(); |
181 | 175 |
| 176 // Populates |number_format| and |measurement_system| according to the |
| 177 // current locale. |
| 178 void GetNumberFormatAndMeasurementSystem(string16* number_format, |
| 179 int* measurement_system); |
| 180 |
| 181 |
| 182 // Populates |last_used_custom_margins| according to the last used margin |
| 183 // settings. |
| 184 void GetLastUsedMarginSettings( |
| 185 base::DictionaryValue* last_used_custom_margins); |
| 186 |
182 // Pointer to current print system. | 187 // Pointer to current print system. |
183 scoped_refptr<printing::PrintBackend> print_backend_; | 188 scoped_refptr<printing::PrintBackend> print_backend_; |
184 | 189 |
185 // The underlying dialog object. | 190 // The underlying dialog object. |
186 scoped_refptr<SelectFileDialog> select_file_dialog_; | 191 scoped_refptr<SelectFileDialog> select_file_dialog_; |
187 | 192 |
188 static FilePath* last_saved_path_; | 193 static FilePath* last_saved_path_; |
189 static std::string* last_used_printer_cloud_print_data_; | 194 static std::string* last_used_printer_cloud_print_data_; |
190 static std::string* last_used_printer_name_; | 195 static std::string* last_used_printer_name_; |
191 static printing::ColorModels last_used_color_model_; | 196 static printing::ColorModels last_used_color_model_; |
192 static printing::MarginType last_used_margins_type_; | 197 static printing::MarginType last_used_margins_type_; |
| 198 static printing::PageSizeMargins* last_used_page_size_margins_; |
193 | 199 |
194 // A count of how many requests received to regenerate preview data. | 200 // A count of how many requests received to regenerate preview data. |
195 // Initialized to 0 then incremented and emitted to a histogram. | 201 // Initialized to 0 then incremented and emitted to a histogram. |
196 int regenerate_preview_request_count_; | 202 int regenerate_preview_request_count_; |
197 | 203 |
198 // A count of how many requests received to show manage printers dialog. | 204 // A count of how many requests received to show manage printers dialog. |
199 int manage_printers_dialog_request_count_; | 205 int manage_printers_dialog_request_count_; |
200 | 206 |
201 // Whether we have already logged a failed print preview. | 207 // Whether we have already logged a failed print preview. |
202 bool reported_failed_preview_; | 208 bool reported_failed_preview_; |
203 | 209 |
204 // Whether we have already logged the number of printers this session. | 210 // Whether we have already logged the number of printers this session. |
205 bool has_logged_printers_count_; | 211 bool has_logged_printers_count_; |
206 | 212 |
207 // Holds the path to the print to pdf request. It is empty if no such request | 213 // Holds the path to the print to pdf request. It is empty if no such request |
208 // exists. | 214 // exists. |
209 scoped_ptr<FilePath> print_to_pdf_path_; | 215 scoped_ptr<FilePath> print_to_pdf_path_; |
210 | 216 |
211 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 217 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
212 }; | 218 }; |
213 | 219 |
214 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ | 220 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
OLD | NEW |