OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PRINT_PREVIEW_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void HandleShowSystemDialog(const base::ListValue* args); | 108 void HandleShowSystemDialog(const base::ListValue* args); |
109 | 109 |
110 // Callback for the signin dialog to call once signin is complete. | 110 // Callback for the signin dialog to call once signin is complete. |
111 static void OnSigninComplete( | 111 static void OnSigninComplete( |
112 const base::WeakPtr<PrintPreviewHandler>& handler); | 112 const base::WeakPtr<PrintPreviewHandler>& handler); |
113 | 113 |
114 // Brings up a dialog to allow the user to sign into cloud print. | 114 // Brings up a dialog to allow the user to sign into cloud print. |
115 // |args| is unused. | 115 // |args| is unused. |
116 void HandleSignin(const base::ListValue* args); | 116 void HandleSignin(const base::ListValue* args); |
117 | 117 |
| 118 // Generates new token and sends back to UI. |
| 119 void HandleGetAccessToken(const base::ListValue* args); |
| 120 |
118 // Brings up a web page to allow the user to configure cloud print. | 121 // Brings up a web page to allow the user to configure cloud print. |
119 // |args| is unused. | 122 // |args| is unused. |
120 void HandleManageCloudPrint(const base::ListValue* args); | 123 void HandleManageCloudPrint(const base::ListValue* args); |
121 | 124 |
122 // Gathers UMA stats when the print preview dialog is about to close. | 125 // Gathers UMA stats when the print preview dialog is about to close. |
123 // |args| is unused. | 126 // |args| is unused. |
124 void HandleClosePreviewDialog(const base::ListValue* args); | 127 void HandleClosePreviewDialog(const base::ListValue* args); |
125 | 128 |
126 // Asks the browser to show the native printer management dialog. | 129 // Asks the browser to show the native printer management dialog. |
127 // |args| is unused. | 130 // |args| is unused. |
(...skipping 16 matching lines...) Expand all Loading... |
144 // NOTE: This is needed to open FedEx confirmation window as a new tab. | 147 // NOTE: This is needed to open FedEx confirmation window as a new tab. |
145 // Javascript's "window.open" opens a new window popup (since initiated from | 148 // Javascript's "window.open" opens a new window popup (since initiated from |
146 // async HTTP request) and worse yet, on Windows and Chrome OS, the opened | 149 // async HTTP request) and worse yet, on Windows and Chrome OS, the opened |
147 // window opens behind the initiator window. | 150 // window opens behind the initiator window. |
148 void HandleForceOpenNewTab(const base::ListValue* args); | 151 void HandleForceOpenNewTab(const base::ListValue* args); |
149 | 152 |
150 void SendInitialSettings( | 153 void SendInitialSettings( |
151 const std::string& default_printer, | 154 const std::string& default_printer, |
152 const std::string& cloud_print_data); | 155 const std::string& cloud_print_data); |
153 | 156 |
| 157 // Send OAuth2 access token. |
| 158 void SendAccessToken(const std::string& type, |
| 159 const std::string& access_token); |
| 160 |
154 // Sends the printer capabilities to the Web UI. |settings_info| contains | 161 // Sends the printer capabilities to the Web UI. |settings_info| contains |
155 // printer capabilities information. | 162 // printer capabilities information. |
156 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); | 163 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); |
157 | 164 |
158 // Sends error notification to the Web UI when unable to return the printer | 165 // Sends error notification to the Web UI when unable to return the printer |
159 // capabilities. | 166 // capabilities. |
160 void SendFailedToGetPrinterCapabilities(const std::string& printer_name); | 167 void SendFailedToGetPrinterCapabilities(const std::string& printer_name); |
161 | 168 |
162 // Send the list of printers to the Web UI. | 169 // Send the list of printers to the Web UI. |
163 void SetupPrinterList(const base::ListValue& printers); | 170 void SetupPrinterList(const base::ListValue& printers); |
(...skipping 27 matching lines...) Expand all Loading... |
191 void PostPrintToPdfTask(); | 198 void PostPrintToPdfTask(); |
192 | 199 |
193 // Populates |settings| according to the current locale. | 200 // Populates |settings| according to the current locale. |
194 void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); | 201 void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); |
195 | 202 |
196 static printing::StickySettings* GetStickySettings(); | 203 static printing::StickySettings* GetStickySettings(); |
197 | 204 |
198 bool GetPreviewDataAndTitle(scoped_refptr<base::RefCountedBytes>* data, | 205 bool GetPreviewDataAndTitle(scoped_refptr<base::RefCountedBytes>* data, |
199 string16* title) const; | 206 string16* title) const; |
200 | 207 |
| 208 void InitTokenService(); |
| 209 |
201 // Pointer to current print system. | 210 // Pointer to current print system. |
202 scoped_refptr<printing::PrintBackend> print_backend_; | 211 scoped_refptr<printing::PrintBackend> print_backend_; |
203 | 212 |
204 // The underlying dialog object. | 213 // The underlying dialog object. |
205 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 214 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
206 | 215 |
207 // A count of how many requests received to regenerate preview data. | 216 // A count of how many requests received to regenerate preview data. |
208 // Initialized to 0 then incremented and emitted to a histogram. | 217 // Initialized to 0 then incremented and emitted to a histogram. |
209 int regenerate_preview_request_count_; | 218 int regenerate_preview_request_count_; |
210 | 219 |
211 // A count of how many requests received to show manage printers dialog. | 220 // A count of how many requests received to show manage printers dialog. |
212 int manage_printers_dialog_request_count_; | 221 int manage_printers_dialog_request_count_; |
213 int manage_cloud_printers_dialog_request_count_; | 222 int manage_cloud_printers_dialog_request_count_; |
214 | 223 |
215 // Whether we have already logged a failed print preview. | 224 // Whether we have already logged a failed print preview. |
216 bool reported_failed_preview_; | 225 bool reported_failed_preview_; |
217 | 226 |
218 // Whether we have already logged the number of printers this session. | 227 // Whether we have already logged the number of printers this session. |
219 bool has_logged_printers_count_; | 228 bool has_logged_printers_count_; |
220 | 229 |
221 // Holds the path to the print to pdf request. It is empty if no such request | 230 // Holds the path to the print to pdf request. It is empty if no such request |
222 // exists. | 231 // exists. |
223 scoped_ptr<base::FilePath> print_to_pdf_path_; | 232 scoped_ptr<base::FilePath> print_to_pdf_path_; |
224 | 233 |
| 234 // Holds token service to get OAuth2 access tokens. |
| 235 class AccessTokenService; |
| 236 scoped_ptr<AccessTokenService> token_service_; |
| 237 |
225 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 238 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
226 }; | 239 }; |
227 | 240 |
228 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 241 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
OLD | NEW |