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> |
| 10 |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
11 #include "chrome/browser/printing/print_view_manager_observer.h" | 13 #include "chrome/browser/printing/print_view_manager_observer.h" |
12 #include "chrome/browser/ui/shell_dialogs.h" | 14 #include "chrome/browser/ui/shell_dialogs.h" |
13 #include "content/browser/webui/web_ui.h" | 15 #include "content/browser/webui/web_ui.h" |
14 | 16 |
15 class FilePath; | 17 class FilePath; |
16 class PrintSystemTaskProxy; | 18 class PrintSystemTaskProxy; |
17 | 19 |
18 namespace base { | 20 namespace base { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void HandlePrint(const base::ListValue* args); | 73 void HandlePrint(const base::ListValue* args); |
72 | 74 |
73 // Handles the request to hide the preview tab for printing. | 75 // Handles the request to hide the preview tab for printing. |
74 // |args| is unused. | 76 // |args| is unused. |
75 void HandleHidePreview(const base::ListValue* args); | 77 void HandleHidePreview(const base::ListValue* args); |
76 | 78 |
77 // Handles the request to cancel the pending print request. | 79 // Handles the request to cancel the pending print request. |
78 // |args| is unused. | 80 // |args| is unused. |
79 void HandleCancelPendingPrintRequest(const base::ListValue* args); | 81 void HandleCancelPendingPrintRequest(const base::ListValue* args); |
80 | 82 |
| 83 // Handles a request to back up data about the last used cloud print |
| 84 // printer. |
| 85 // First element of |args| is the printer name. |
| 86 // Second element of |args| is the current cloud print data JSON. |
| 87 void HandleSaveLastPrinter(const base::ListValue* args); |
| 88 |
81 // Get the printer capabilities. | 89 // Get the printer capabilities. |
82 // First element of |args| is the printer name. | 90 // First element of |args| is the printer name. |
83 void HandleGetPrinterCapabilities(const base::ListValue* args); | 91 void HandleGetPrinterCapabilities(const base::ListValue* args); |
84 | 92 |
85 // Ask the initiator renderer to show the native print system dialog. | 93 // Ask the initiator renderer to show the native print system dialog. |
86 // |args| is unused. | 94 // |args| is unused. |
87 void HandleShowSystemDialog(const base::ListValue* args); | 95 void HandleShowSystemDialog(const base::ListValue* args); |
88 | 96 |
| 97 // Bring up a web page to allow the user to configure cloud print. |
| 98 // |args| is unused. |
| 99 void HandleManageCloudPrint(const base::ListValue* args); |
| 100 |
89 // Ask the browser to show the native printer management dialog. | 101 // Ask the browser to show the native printer management dialog. |
90 // |args| is unused. | 102 // |args| is unused. |
91 void HandleManagePrinters(const base::ListValue* args); | 103 void HandleManagePrinters(const base::ListValue* args); |
92 | 104 |
93 // Ask the browser to close the preview tab. | 105 // Ask the browser to close the preview tab. |
94 // |args| is unused. | 106 // |args| is unused. |
95 void HandleClosePreviewTab(const base::ListValue* args); | 107 void HandleClosePreviewTab(const base::ListValue* args); |
96 | 108 |
97 // Send the printer capabilities to the Web UI. | 109 // Send the printer capabilities to the Web UI. |
98 // |settings_info| contains printer capabilities information. | 110 // |settings_info| contains printer capabilities information. |
99 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); | 111 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); |
100 | 112 |
101 // Send the default printer to the Web UI. | 113 // Send the default printer to the Web UI. |
102 void SendDefaultPrinter(const base::StringValue& default_printer); | 114 void SendDefaultPrinter(const base::StringValue& default_printer, |
| 115 const base::StringValue& cloud_print_data); |
103 | 116 |
104 // Send the list of printers to the Web UI. | 117 // Send the list of printers to the Web UI. |
105 void SendPrinterList(const base::ListValue& printers); | 118 void SetupPrinterList(const base::ListValue& printers); |
| 119 |
| 120 // Send whether cloud print integration should be enabled. |
| 121 void SendCloudPrintEnabled(); |
| 122 |
| 123 // Send the PDF data to the cloud to print. |
| 124 void SendCloudPrintJob(const base::DictionaryValue& settings, |
| 125 std::string print_ticket); |
106 | 126 |
107 // Helper function to get the initiator tab for the print preview tab. | 127 // Helper function to get the initiator tab for the print preview tab. |
108 TabContents* GetInitiatorTab(); | 128 TabContents* GetInitiatorTab(); |
109 | 129 |
110 // Helper function to close the print preview tab. | 130 // Helper function to close the print preview tab. |
111 void ClosePrintPreviewTab(); | 131 void ClosePrintPreviewTab(); |
112 | 132 |
113 // Helper function to activate the initiator tab and close the preview tab. | 133 // Helper function to activate the initiator tab and close the preview tab. |
114 void ActivateInitiatorTabAndClosePreviewTab(); | 134 void ActivateInitiatorTabAndClosePreviewTab(); |
115 | 135 |
116 // Adds all the recorded stats taken so far to histogram counts. | 136 // Adds all the recorded stats taken so far to histogram counts. |
117 void ReportStats(); | 137 void ReportStats(); |
118 | 138 |
119 // Helper function to hide the preview tab for printing. | 139 // Helper function to hide the preview tab for printing. |
120 void HidePreviewTab(); | 140 void HidePreviewTab(); |
121 | 141 |
122 // Helper function to clear initiator tab details for this preview tab. | 142 // Helper function to clear initiator tab details for this preview tab. |
123 void ClearInitiatorTabDetails(); | 143 void ClearInitiatorTabDetails(); |
124 | 144 |
125 // Pointer to current print system. | 145 // Pointer to current print system. |
126 scoped_refptr<printing::PrintBackend> print_backend_; | 146 scoped_refptr<printing::PrintBackend> print_backend_; |
127 | 147 |
128 // The underlying dialog object. | 148 // The underlying dialog object. |
129 scoped_refptr<SelectFileDialog> select_file_dialog_; | 149 scoped_refptr<SelectFileDialog> select_file_dialog_; |
130 | 150 |
131 static FilePath* last_saved_path_; | 151 static FilePath* last_saved_path_; |
132 static std::string* last_used_printer_; | 152 static std::string* last_used_printer_cloud_print_data_; |
| 153 static std::string* last_used_printer_name_; |
133 | 154 |
134 // A count of how many requests received to regenerate preview data. | 155 // A count of how many requests received to regenerate preview data. |
135 // Initialized to 0 then incremented and emitted to a histogram. | 156 // Initialized to 0 then incremented and emitted to a histogram. |
136 int regenerate_preview_request_count_; | 157 int regenerate_preview_request_count_; |
137 | 158 |
138 // A count of how many requests received to show manage printers dialog. | 159 // A count of how many requests received to show manage printers dialog. |
139 int manage_printers_dialog_request_count_; | 160 int manage_printers_dialog_request_count_; |
140 | 161 |
141 // Whether we have already logged a failed print preview. | 162 // Whether we have already logged a failed print preview. |
142 bool reported_failed_preview_; | 163 bool reported_failed_preview_; |
143 | 164 |
144 // Whether we have already logged the number of printers this session. | 165 // Whether we have already logged the number of printers this session. |
145 bool has_logged_printers_count_; | 166 bool has_logged_printers_count_; |
146 | 167 |
147 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 168 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
148 }; | 169 }; |
149 | 170 |
150 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ | 171 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
OLD | NEW |