| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Asks the browser to show the native printer management dialog. | 126 // Asks the browser to show the native printer management dialog. |
| 126 // |args| is unused. | 127 // |args| is unused. |
| 127 void HandleManagePrinters(const base::ListValue* args); | 128 void HandleManagePrinters(const base::ListValue* args); |
| 128 | 129 |
| 129 // Asks the browser to show the cloud print dialog. | 130 // Asks the browser to show the cloud print dialog. |
| 130 void HandlePrintWithCloudPrint(); | 131 void HandlePrintWithCloudPrint(); |
| 131 | 132 |
| 132 // Asks the browser to close the preview tab. |args| is unused. | 133 // Asks the browser to close the preview tab. |args| is unused. |
| 133 void HandleClosePreviewTab(const base::ListValue* args); | 134 void HandleClosePreviewTab(const base::ListValue* args); |
| 134 | 135 |
| 135 // Asks the browser for the title of the initiator tab. | 136 // Asks the browser for several settings that are needed before the first |
| 136 // |args| is unused. | 137 // preview is displayed. |
| 137 void HandleGetInitiatorTabTitle(const base::ListValue* args); | 138 void HandleGetInitialSettings(const base::ListValue* args); |
| 138 | |
| 139 // Asks the browser for the number formatting and measurement system according | |
| 140 // to the current locale. | |
| 141 void HandleGetNumberFormatAndMeasurementSystem(const base::ListValue* args); | |
| 142 | 139 |
| 143 // Sends the printer capabilities to the Web UI. |settings_info| contains | 140 // Sends the printer capabilities to the Web UI. |settings_info| contains |
| 144 // printer capabilities information. | 141 // printer capabilities information. |
| 145 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); | 142 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); |
| 146 | 143 |
| 147 // Sends the default printer to the Web UI. | 144 // Sends the default printer to the Web UI. |
| 148 void SendDefaultPrinter(const base::StringValue& default_printer, | 145 void SendDefaultPrinter(const base::StringValue& default_printer, |
| 149 const base::StringValue& cloud_print_data); | 146 const base::StringValue& cloud_print_data); |
| 150 | 147 |
| 151 // Send the list of printers to the Web UI. | 148 // Send the list of printers to the Web UI. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 172 | 169 |
| 173 // Hides the preview tab for printing. | 170 // Hides the preview tab for printing. |
| 174 void HidePreviewTab(); | 171 void HidePreviewTab(); |
| 175 | 172 |
| 176 // Clears initiator tab details for this preview tab. | 173 // Clears initiator tab details for this preview tab. |
| 177 void ClearInitiatorTabDetails(); | 174 void ClearInitiatorTabDetails(); |
| 178 | 175 |
| 179 // Posts a task to save to pdf at |print_to_pdf_path_|. | 176 // Posts a task to save to pdf at |print_to_pdf_path_|. |
| 180 void PostPrintToPdfTask(); | 177 void PostPrintToPdfTask(); |
| 181 | 178 |
| 179 // Populates |number_format| and |measurement_system| according to the |
| 180 // current locale. |
| 181 void GetNumberFormatAndMeasurementSystem(string16* number_format, |
| 182 int* measurement_system); |
| 183 |
| 184 |
| 185 // Populates |last_used_margin_type| and |last_used_custom_margins| according |
| 186 // to the last used margin settings. |
| 187 void GetLastUsedMarginSettings( |
| 188 printing::MarginType* last_used_margin_type, |
| 189 base::DictionaryValue* last_used_custom_margins); |
| 190 |
| 182 // Pointer to current print system. | 191 // Pointer to current print system. |
| 183 scoped_refptr<printing::PrintBackend> print_backend_; | 192 scoped_refptr<printing::PrintBackend> print_backend_; |
| 184 | 193 |
| 185 // The underlying dialog object. | 194 // The underlying dialog object. |
| 186 scoped_refptr<SelectFileDialog> select_file_dialog_; | 195 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 187 | 196 |
| 188 static FilePath* last_saved_path_; | 197 static FilePath* last_saved_path_; |
| 189 static std::string* last_used_printer_cloud_print_data_; | 198 static std::string* last_used_printer_cloud_print_data_; |
| 190 static std::string* last_used_printer_name_; | 199 static std::string* last_used_printer_name_; |
| 191 static printing::ColorModels last_used_color_model_; | 200 static printing::ColorModels last_used_color_model_; |
| 192 static printing::MarginType last_used_margins_type_; | 201 static printing::MarginType last_used_margins_type_; |
| 202 static printing::PageSizeMargins* last_used_page_size_margins_; |
| 193 | 203 |
| 194 // A count of how many requests received to regenerate preview data. | 204 // A count of how many requests received to regenerate preview data. |
| 195 // Initialized to 0 then incremented and emitted to a histogram. | 205 // Initialized to 0 then incremented and emitted to a histogram. |
| 196 int regenerate_preview_request_count_; | 206 int regenerate_preview_request_count_; |
| 197 | 207 |
| 198 // A count of how many requests received to show manage printers dialog. | 208 // A count of how many requests received to show manage printers dialog. |
| 199 int manage_printers_dialog_request_count_; | 209 int manage_printers_dialog_request_count_; |
| 200 | 210 |
| 201 // Whether we have already logged a failed print preview. | 211 // Whether we have already logged a failed print preview. |
| 202 bool reported_failed_preview_; | 212 bool reported_failed_preview_; |
| 203 | 213 |
| 204 // Whether we have already logged the number of printers this session. | 214 // Whether we have already logged the number of printers this session. |
| 205 bool has_logged_printers_count_; | 215 bool has_logged_printers_count_; |
| 206 | 216 |
| 207 // Holds the path to the print to pdf request. It is empty if no such request | 217 // Holds the path to the print to pdf request. It is empty if no such request |
| 208 // exists. | 218 // exists. |
| 209 scoped_ptr<FilePath> print_to_pdf_path_; | 219 scoped_ptr<FilePath> print_to_pdf_path_; |
| 210 | 220 |
| 211 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 221 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
| 212 }; | 222 }; |
| 213 | 223 |
| 214 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ | 224 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
| OLD | NEW |