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/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "chrome/browser/printing/print_view_manager_observer.h" | 16 #include "chrome/browser/printing/print_view_manager_observer.h" |
17 #include "chrome/browser/ui/webui/print_preview/print_preview_distiller.h" | 17 #include "chrome/browser/ui/webui/print_preview/print_preview_distiller.h" |
18 #include "components/signin/core/browser/gaia_cookie_manager_service.h" | 18 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
19 #include "content/public/browser/web_ui_message_handler.h" | 19 #include "content/public/browser/web_ui_message_handler.h" |
20 #include "ui/shell_dialogs/select_file_dialog.h" | 20 #include "ui/shell_dialogs/select_file_dialog.h" |
21 | 21 |
22 #if defined(ENABLE_SERVICE_DISCOVERY) | 22 #if defined(ENABLE_SERVICE_DISCOVERY) |
23 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 23 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
24 #include "chrome/browser/printing/cloud_print/privet_local_printer_lister.h" | 24 #include "chrome/browser/printing/cloud_print/privet_local_printer_lister.h" |
25 #endif // ENABLE_SERVICE_DISCOVERY | 25 #endif // defined(ENABLE_SERVICE_DISCOVERY) |
26 | 26 |
27 class PrinterHandler; | 27 class PrinterHandler; |
28 class PrintPreviewUI; | 28 class PrintPreviewUI; |
29 class PrintSystemTaskProxy; | 29 class PrintSystemTaskProxy; |
30 | 30 |
31 namespace base { | 31 namespace base { |
32 class DictionaryValue; | 32 class DictionaryValue; |
33 class RefCountedBytes; | 33 class RefCountedBytes; |
34 } | 34 } |
35 | 35 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // observer. | 77 // observer. |
78 void OnPrintPreviewDialogDestroyed(); | 78 void OnPrintPreviewDialogDestroyed(); |
79 | 79 |
80 // Called when print preview failed. | 80 // Called when print preview failed. |
81 void OnPrintPreviewFailed(); | 81 void OnPrintPreviewFailed(); |
82 | 82 |
83 #if defined(ENABLE_BASIC_PRINTING) | 83 #if defined(ENABLE_BASIC_PRINTING) |
84 // Called when the user press ctrl+shift+p to display the native system | 84 // Called when the user press ctrl+shift+p to display the native system |
85 // dialog. | 85 // dialog. |
86 void ShowSystemDialog(); | 86 void ShowSystemDialog(); |
87 #endif // ENABLE_BASIC_PRINTING | 87 #endif // defined(ENABLE_BASIC_PRINTING) |
88 | 88 |
89 #if defined(ENABLE_SERVICE_DISCOVERY) | 89 #if defined(ENABLE_SERVICE_DISCOVERY) |
90 // PrivetLocalPrinterLister::Delegate implementation. | 90 // PrivetLocalPrinterLister::Delegate implementation. |
91 void LocalPrinterChanged( | 91 void LocalPrinterChanged( |
92 bool added, | 92 bool added, |
93 const std::string& name, | 93 const std::string& name, |
94 bool has_local_printing, | 94 bool has_local_printing, |
95 const cloud_print::DeviceDescription& description) override; | 95 const cloud_print::DeviceDescription& description) override; |
96 void LocalPrinterRemoved(const std::string& name) override; | 96 void LocalPrinterRemoved(const std::string& name) override; |
97 void LocalPrinterCacheFlushed() override; | 97 void LocalPrinterCacheFlushed() override; |
98 | 98 |
99 // PrivetLocalPrintOperation::Delegate implementation. | 99 // PrivetLocalPrintOperation::Delegate implementation. |
100 void OnPrivetPrintingDone( | 100 void OnPrivetPrintingDone( |
101 const cloud_print::PrivetLocalPrintOperation* print_operation) override; | 101 const cloud_print::PrivetLocalPrintOperation* print_operation) override; |
102 void OnPrivetPrintingError( | 102 void OnPrivetPrintingError( |
103 const cloud_print::PrivetLocalPrintOperation* print_operation, | 103 const cloud_print::PrivetLocalPrintOperation* print_operation, |
104 int http_code) override; | 104 int http_code) override; |
105 #endif // ENABLE_SERVICE_DISCOVERY | 105 #endif // defined(ENABLE_SERVICE_DISCOVERY) |
| 106 |
106 int regenerate_preview_request_count() const { | 107 int regenerate_preview_request_count() const { |
107 return regenerate_preview_request_count_; | 108 return regenerate_preview_request_count_; |
108 } | 109 } |
109 | 110 |
110 // Sets |pdf_file_saved_closure_| to |closure|. | 111 // Sets |pdf_file_saved_closure_| to |closure|. |
111 void SetPdfSavedClosureForTesting(const base::Closure& closure); | 112 void SetPdfSavedClosureForTesting(const base::Closure& closure); |
112 | 113 |
113 private: | 114 private: |
114 friend class PrintPreviewPdfGeneratedBrowserTest; | 115 friend class PrintPreviewPdfGeneratedBrowserTest; |
115 FRIEND_TEST_ALL_PREFIXES(PrintPreviewPdfGeneratedBrowserTest, | 116 FRIEND_TEST_ALL_PREFIXES(PrintPreviewPdfGeneratedBrowserTest, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // First element of |args| is the data to persist. | 158 // First element of |args| is the data to persist. |
158 void HandleSaveAppState(const base::ListValue* args); | 159 void HandleSaveAppState(const base::ListValue* args); |
159 | 160 |
160 // Gets the printer capabilities. First element of |args| is the printer name. | 161 // Gets the printer capabilities. First element of |args| is the printer name. |
161 void HandleGetPrinterCapabilities(const base::ListValue* args); | 162 void HandleGetPrinterCapabilities(const base::ListValue* args); |
162 | 163 |
163 #if defined(ENABLE_BASIC_PRINTING) | 164 #if defined(ENABLE_BASIC_PRINTING) |
164 // Asks the initiator renderer to show the native print system dialog. |args| | 165 // Asks the initiator renderer to show the native print system dialog. |args| |
165 // is unused. | 166 // is unused. |
166 void HandleShowSystemDialog(const base::ListValue* args); | 167 void HandleShowSystemDialog(const base::ListValue* args); |
167 #endif // ENABLE_BASIC_PRINTING | 168 #endif // defined(ENABLE_BASIC_PRINTING) |
168 | 169 |
169 // Callback for the signin dialog to call once signin is complete. | 170 // Callback for the signin dialog to call once signin is complete. |
170 void OnSigninComplete(); | 171 void OnSigninComplete(); |
171 | 172 |
172 // Brings up a dialog to allow the user to sign into cloud print. | 173 // Brings up a dialog to allow the user to sign into cloud print. |
173 // |args| is unused. | 174 // |args| is unused. |
174 void HandleSignin(const base::ListValue* args); | 175 void HandleSignin(const base::ListValue* args); |
175 | 176 |
176 // Generates new token and sends back to UI. | 177 // Generates new token and sends back to UI. |
177 void HandleGetAccessToken(const base::ListValue* args); | 178 void HandleGetAccessToken(const base::ListValue* args); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 const gfx::Size& page_size); | 297 const gfx::Size& page_size); |
297 bool CreatePrivetHTTP( | 298 bool CreatePrivetHTTP( |
298 const std::string& name, | 299 const std::string& name, |
299 const cloud_print::PrivetHTTPAsynchronousFactory::ResultCallback& | 300 const cloud_print::PrivetHTTPAsynchronousFactory::ResultCallback& |
300 callback); | 301 callback); |
301 void FillPrinterDescription( | 302 void FillPrinterDescription( |
302 const std::string& name, | 303 const std::string& name, |
303 const cloud_print::DeviceDescription& description, | 304 const cloud_print::DeviceDescription& description, |
304 bool has_local_printing, | 305 bool has_local_printing, |
305 base::DictionaryValue* printer_value); | 306 base::DictionaryValue* printer_value); |
306 #endif | 307 #endif // defined(ENABLE_SERVICE_DISCOVERY) |
307 | 308 |
308 // Lazily creates |extension_printer_handler_| that can be used to handle | 309 // Lazily creates |extension_printer_handler_| that can be used to handle |
309 // extension printers requests. | 310 // extension printers requests. |
310 void EnsureExtensionPrinterHandlerSet(); | 311 void EnsureExtensionPrinterHandlerSet(); |
311 | 312 |
312 // Called when a list of printers is reported by an extension. | 313 // Called when a list of printers is reported by an extension. |
313 // |printers|: The list of printers managed by the extension. | 314 // |printers|: The list of printers managed by the extension. |
314 // |done|: Whether all the extensions have reported the list of printers | 315 // |done|: Whether all the extensions have reported the list of printers |
315 // they manage. | 316 // they manage. |
316 void OnGotPrintersForExtension(const base::ListValue& printers, bool done); | 317 void OnGotPrintersForExtension(const base::ListValue& printers, bool done); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 scoped_ptr<cloud_print::PrivetLocalPrinterLister> printer_lister_; | 376 scoped_ptr<cloud_print::PrivetLocalPrinterLister> printer_lister_; |
376 | 377 |
377 scoped_ptr<cloud_print::PrivetHTTPAsynchronousFactory> | 378 scoped_ptr<cloud_print::PrivetHTTPAsynchronousFactory> |
378 privet_http_factory_; | 379 privet_http_factory_; |
379 scoped_ptr<cloud_print::PrivetHTTPResolution> privet_http_resolution_; | 380 scoped_ptr<cloud_print::PrivetHTTPResolution> privet_http_resolution_; |
380 scoped_ptr<cloud_print::PrivetV1HTTPClient> privet_http_client_; | 381 scoped_ptr<cloud_print::PrivetV1HTTPClient> privet_http_client_; |
381 scoped_ptr<cloud_print::PrivetJSONOperation> | 382 scoped_ptr<cloud_print::PrivetJSONOperation> |
382 privet_capabilities_operation_; | 383 privet_capabilities_operation_; |
383 scoped_ptr<cloud_print::PrivetLocalPrintOperation> | 384 scoped_ptr<cloud_print::PrivetLocalPrintOperation> |
384 privet_local_print_operation_; | 385 privet_local_print_operation_; |
385 #endif | 386 #endif // defined(ENABLE_SERVICE_DISCOVERY) |
386 | 387 |
387 // Handles requests for extension printers. Created lazily by calling | 388 // Handles requests for extension printers. Created lazily by calling |
388 // |EnsureExtensionPrinterHandlerSet|. | 389 // |EnsureExtensionPrinterHandlerSet|. |
389 scoped_ptr<PrinterHandler> extension_printer_handler_; | 390 scoped_ptr<PrinterHandler> extension_printer_handler_; |
390 | 391 |
391 // Notifies tests that want to know if the PDF has been saved. This doesn't | 392 // Notifies tests that want to know if the PDF has been saved. This doesn't |
392 // notify the test if it was a successful save, only that it was attempted. | 393 // notify the test if it was a successful save, only that it was attempted. |
393 base::Closure pdf_file_saved_closure_; | 394 base::Closure pdf_file_saved_closure_; |
394 | 395 |
395 // A print preview that is responsible for rendering the page after | 396 // A print preview that is responsible for rendering the page after |
396 // being processed by the DOM Distiller. | 397 // being processed by the DOM Distiller. |
397 scoped_ptr<PrintPreviewDistiller> print_preview_distiller_; | 398 scoped_ptr<PrintPreviewDistiller> print_preview_distiller_; |
398 | 399 |
399 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; | 400 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; |
400 | 401 |
401 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 402 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
402 }; | 403 }; |
403 | 404 |
404 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 405 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
OLD | NEW |