| 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 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/printing/print_view_manager_observer.h" | 14 #include "chrome/browser/printing/print_view_manager_observer.h" |
| 14 #include "chrome/browser/ui/shell_dialogs.h" | 15 #include "chrome/browser/ui/shell_dialogs.h" |
| 15 #include "content/browser/webui/web_ui.h" | 16 #include "content/browser/webui/web_ui.h" |
| 16 | 17 |
| 17 class FilePath; | 18 class FilePath; |
| 18 class PrintSystemTaskProxy; | 19 class PrintSystemTaskProxy; |
| 19 class TabContentsWrapper; | 20 class TabContentsWrapper; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 23 class DictionaryValue; |
| 22 class FundamentalValue; | 24 class FundamentalValue; |
| 23 class StringValue; | 25 class StringValue; |
| 24 } | 26 } |
| 25 | 27 |
| 26 namespace printing { | 28 namespace printing { |
| 27 class PrintBackend; | 29 class PrintBackend; |
| 28 } | 30 } |
| 29 | 31 |
| 30 // The handler for Javascript messages related to the print preview dialog. | 32 // The handler for Javascript messages related to the print preview dialog. |
| 31 class PrintPreviewHandler : public WebUIMessageHandler, | 33 class PrintPreviewHandler : public WebUIMessageHandler, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Gets the default printer. |args| is unused. | 74 // Gets the default printer. |args| is unused. |
| 73 void HandleGetDefaultPrinter(const base::ListValue* args); | 75 void HandleGetDefaultPrinter(const base::ListValue* args); |
| 74 | 76 |
| 75 // Gets the list of printers. |args| is unused. | 77 // Gets the list of printers. |args| is unused. |
| 76 void HandleGetPrinters(const base::ListValue* args); | 78 void HandleGetPrinters(const base::ListValue* args); |
| 77 | 79 |
| 78 // 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| |
| 79 // is a job settings JSON string. | 81 // is a job settings JSON string. |
| 80 void HandleGetPreview(const base::ListValue* args); | 82 void HandleGetPreview(const base::ListValue* args); |
| 81 | 83 |
| 82 // 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 |
| 83 // |args| is a job settings JSON string. | 85 // |args| is a job settings JSON string. |
| 84 void HandlePrint(const base::ListValue* args); | 86 void HandlePrint(const base::ListValue* args); |
| 85 | 87 |
| 88 // Handles printing to PDF. |settings| points to a dictionary containing all |
| 89 // the print request parameters. |
| 90 void HandlePrintToPdf(const base::DictionaryValue& settings); |
| 91 |
| 86 // Handles the request to hide the preview tab for printing. |args| is unused. | 92 // Handles the request to hide the preview tab for printing. |args| is unused. |
| 87 void HandleHidePreview(const base::ListValue* args); | 93 void HandleHidePreview(const base::ListValue* args); |
| 88 | 94 |
| 89 // Handles the request to cancel the pending print request. |args| is unused. | 95 // Handles the request to cancel the pending print request. |args| is unused. |
| 90 void HandleCancelPendingPrintRequest(const base::ListValue* args); | 96 void HandleCancelPendingPrintRequest(const base::ListValue* args); |
| 91 | 97 |
| 92 // Handles a request to back up data about the last used cloud print | 98 // Handles a request to back up data about the last used cloud print |
| 93 // printer. | 99 // printer. |
| 94 // First element of |args| is the printer name. | 100 // First element of |args| is the printer name. |
| 95 // Second element of |args| is the current cloud print data JSON. | 101 // Second element of |args| is the current cloud print data JSON. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 160 |
| 155 // Adds all the recorded stats taken so far to histogram counts. | 161 // Adds all the recorded stats taken so far to histogram counts. |
| 156 void ReportStats(); | 162 void ReportStats(); |
| 157 | 163 |
| 158 // Hides the preview tab for printing. | 164 // Hides the preview tab for printing. |
| 159 void HidePreviewTab(); | 165 void HidePreviewTab(); |
| 160 | 166 |
| 161 // Clears initiator tab details for this preview tab. | 167 // Clears initiator tab details for this preview tab. |
| 162 void ClearInitiatorTabDetails(); | 168 void ClearInitiatorTabDetails(); |
| 163 | 169 |
| 170 // Posts a task to save to pdf at |print_to_pdf_path_|. |
| 171 void PostPrintToPdfTask(); |
| 172 |
| 164 // Pointer to current print system. | 173 // Pointer to current print system. |
| 165 scoped_refptr<printing::PrintBackend> print_backend_; | 174 scoped_refptr<printing::PrintBackend> print_backend_; |
| 166 | 175 |
| 167 // The underlying dialog object. | 176 // The underlying dialog object. |
| 168 scoped_refptr<SelectFileDialog> select_file_dialog_; | 177 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 169 | 178 |
| 170 static FilePath* last_saved_path_; | 179 static FilePath* last_saved_path_; |
| 171 static std::string* last_used_printer_cloud_print_data_; | 180 static std::string* last_used_printer_cloud_print_data_; |
| 172 static std::string* last_used_printer_name_; | 181 static std::string* last_used_printer_name_; |
| 173 static bool last_used_color_setting_; | 182 static bool last_used_color_setting_; |
| 174 | 183 |
| 175 // A count of how many requests received to regenerate preview data. | 184 // A count of how many requests received to regenerate preview data. |
| 176 // Initialized to 0 then incremented and emitted to a histogram. | 185 // Initialized to 0 then incremented and emitted to a histogram. |
| 177 int regenerate_preview_request_count_; | 186 int regenerate_preview_request_count_; |
| 178 | 187 |
| 179 // A count of how many requests received to show manage printers dialog. | 188 // A count of how many requests received to show manage printers dialog. |
| 180 int manage_printers_dialog_request_count_; | 189 int manage_printers_dialog_request_count_; |
| 181 | 190 |
| 182 // Whether we have already logged a failed print preview. | 191 // Whether we have already logged a failed print preview. |
| 183 bool reported_failed_preview_; | 192 bool reported_failed_preview_; |
| 184 | 193 |
| 185 // Whether we have already logged the number of printers this session. | 194 // Whether we have already logged the number of printers this session. |
| 186 bool has_logged_printers_count_; | 195 bool has_logged_printers_count_; |
| 187 | 196 |
| 197 // Holds the path to the print to pdf request. It is empty if no such request |
| 198 // exists. |
| 199 scoped_ptr<FilePath> print_to_pdf_path_; |
| 200 |
| 188 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 201 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
| 189 }; | 202 }; |
| 190 | 203 |
| 191 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ | 204 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
| OLD | NEW |