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/privet_local_printer_lister.h" | |
24 #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" |
25 #endif // ENABLE_SERVICE_DISCOVERY | 25 #endif // 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 |
36 namespace content { | 36 namespace content { |
37 class WebContents; | 37 class WebContents; |
38 } | 38 } |
39 | 39 |
40 namespace gfx { | 40 namespace gfx { |
41 class Size; | 41 class Size; |
42 } | 42 } |
43 | 43 |
44 // The handler for Javascript messages related to the print preview dialog. | 44 // The handler for Javascript messages related to the print preview dialog. |
45 class PrintPreviewHandler | 45 class PrintPreviewHandler |
46 : public content::WebUIMessageHandler, | 46 : public content::WebUIMessageHandler, |
47 #if defined(ENABLE_SERVICE_DISCOVERY) | 47 #if defined(ENABLE_SERVICE_DISCOVERY) |
48 public local_discovery::PrivetLocalPrinterLister::Delegate, | 48 public cloud_print::PrivetLocalPrinterLister::Delegate, |
49 public local_discovery::PrivetLocalPrintOperation::Delegate, | 49 public cloud_print::PrivetLocalPrintOperation::Delegate, |
50 #endif | 50 #endif |
51 public ui::SelectFileDialog::Listener, | 51 public ui::SelectFileDialog::Listener, |
52 public printing::PrintViewManagerObserver, | 52 public printing::PrintViewManagerObserver, |
53 public GaiaCookieManagerService::Observer { | 53 public GaiaCookieManagerService::Observer { |
54 public: | 54 public: |
55 PrintPreviewHandler(); | 55 PrintPreviewHandler(); |
56 ~PrintPreviewHandler() override; | 56 ~PrintPreviewHandler() override; |
57 | 57 |
58 // WebUIMessageHandler implementation. | 58 // WebUIMessageHandler implementation. |
59 void RegisterMessages() override; | 59 void RegisterMessages() override; |
(...skipping 25 matching lines...) Expand all Loading... |
85 // dialog. | 85 // dialog. |
86 void ShowSystemDialog(); | 86 void ShowSystemDialog(); |
87 #endif // ENABLE_BASIC_PRINTING | 87 #endif // 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 local_discovery::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(const local_discovery::PrivetLocalPrintOperation* | 100 void OnPrivetPrintingDone( |
101 print_operation) override; | 101 const cloud_print::PrivetLocalPrintOperation* print_operation) override; |
102 void OnPrivetPrintingError( | 102 void OnPrivetPrintingError( |
103 const local_discovery::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 // ENABLE_SERVICE_DISCOVERY |
106 int regenerate_preview_request_count() const { | 106 int regenerate_preview_request_count() const { |
107 return regenerate_preview_request_count_; | 107 return regenerate_preview_request_count_; |
108 } | 108 } |
109 | 109 |
110 // Sets |pdf_file_saved_closure_| to |closure|. | 110 // Sets |pdf_file_saved_closure_| to |closure|. |
111 void SetPdfSavedClosureForTesting(const base::Closure& closure); | 111 void SetPdfSavedClosureForTesting(const base::Closure& closure); |
112 | 112 |
113 private: | 113 private: |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 void ConvertColorSettingToCUPSColorModel( | 272 void ConvertColorSettingToCUPSColorModel( |
273 base::DictionaryValue* settings) const; | 273 base::DictionaryValue* settings) const; |
274 #endif | 274 #endif |
275 | 275 |
276 #if defined(ENABLE_SERVICE_DISCOVERY) | 276 #if defined(ENABLE_SERVICE_DISCOVERY) |
277 void StartPrivetLister(const scoped_refptr< | 277 void StartPrivetLister(const scoped_refptr< |
278 local_discovery::ServiceDiscoverySharedClient>& client); | 278 local_discovery::ServiceDiscoverySharedClient>& client); |
279 void OnPrivetCapabilities(const base::DictionaryValue* capabilities); | 279 void OnPrivetCapabilities(const base::DictionaryValue* capabilities); |
280 void PrivetCapabilitiesUpdateClient( | 280 void PrivetCapabilitiesUpdateClient( |
281 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); | 281 scoped_ptr<cloud_print::PrivetHTTPClient> http_client); |
282 void PrivetLocalPrintUpdateClient( | 282 void PrivetLocalPrintUpdateClient( |
283 std::string print_ticket, | 283 std::string print_ticket, |
284 std::string capabilities, | 284 std::string capabilities, |
285 gfx::Size page_size, | 285 gfx::Size page_size, |
286 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); | 286 scoped_ptr<cloud_print::PrivetHTTPClient> http_client); |
287 bool PrivetUpdateClient( | 287 bool PrivetUpdateClient( |
288 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); | 288 scoped_ptr<cloud_print::PrivetHTTPClient> http_client); |
289 void StartPrivetLocalPrint(const std::string& print_ticket, | 289 void StartPrivetLocalPrint(const std::string& print_ticket, |
290 const std::string& capabilities, | 290 const std::string& capabilities, |
291 const gfx::Size& page_size); | 291 const gfx::Size& page_size); |
292 void SendPrivetCapabilitiesError(const std::string& id); | 292 void SendPrivetCapabilitiesError(const std::string& id); |
293 void PrintToPrivetPrinter(const std::string& printer_name, | 293 void PrintToPrivetPrinter(const std::string& printer_name, |
294 const std::string& print_ticket, | 294 const std::string& print_ticket, |
295 const std::string& capabilities, | 295 const std::string& capabilities, |
296 const gfx::Size& page_size); | 296 const gfx::Size& page_size); |
297 bool CreatePrivetHTTP( | 297 bool CreatePrivetHTTP( |
298 const std::string& name, | 298 const std::string& name, |
299 const local_discovery::PrivetHTTPAsynchronousFactory::ResultCallback& | 299 const cloud_print::PrivetHTTPAsynchronousFactory::ResultCallback& |
300 callback); | 300 callback); |
301 void FillPrinterDescription( | 301 void FillPrinterDescription( |
302 const std::string& name, | 302 const std::string& name, |
303 const local_discovery::DeviceDescription& description, | 303 const cloud_print::DeviceDescription& description, |
304 bool has_local_printing, | 304 bool has_local_printing, |
305 base::DictionaryValue* printer_value); | 305 base::DictionaryValue* printer_value); |
306 #endif | 306 #endif |
307 | 307 |
308 // Lazily creates |extension_printer_handler_| that can be used to handle | 308 // Lazily creates |extension_printer_handler_| that can be used to handle |
309 // extension printers requests. | 309 // extension printers requests. |
310 void EnsureExtensionPrinterHandlerSet(); | 310 void EnsureExtensionPrinterHandlerSet(); |
311 | 311 |
312 // Called when a list of printers is reported by an extension. | 312 // Called when a list of printers is reported by an extension. |
313 // |printers|: The list of printers managed by the extension. | 313 // |printers|: The list of printers managed by the extension. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // Holds token service to get OAuth2 access tokens. | 365 // Holds token service to get OAuth2 access tokens. |
366 scoped_ptr<AccessTokenService> token_service_; | 366 scoped_ptr<AccessTokenService> token_service_; |
367 | 367 |
368 // Pointer to cookie manager service so that print preview can listen for GAIA | 368 // Pointer to cookie manager service so that print preview can listen for GAIA |
369 // cookie changes. | 369 // cookie changes. |
370 GaiaCookieManagerService* gaia_cookie_manager_service_; | 370 GaiaCookieManagerService* gaia_cookie_manager_service_; |
371 | 371 |
372 #if defined(ENABLE_SERVICE_DISCOVERY) | 372 #if defined(ENABLE_SERVICE_DISCOVERY) |
373 scoped_refptr<local_discovery::ServiceDiscoverySharedClient> | 373 scoped_refptr<local_discovery::ServiceDiscoverySharedClient> |
374 service_discovery_client_; | 374 service_discovery_client_; |
375 scoped_ptr<local_discovery::PrivetLocalPrinterLister> printer_lister_; | 375 scoped_ptr<cloud_print::PrivetLocalPrinterLister> printer_lister_; |
376 | 376 |
377 scoped_ptr<local_discovery::PrivetHTTPAsynchronousFactory> | 377 scoped_ptr<cloud_print::PrivetHTTPAsynchronousFactory> |
378 privet_http_factory_; | 378 privet_http_factory_; |
379 scoped_ptr<local_discovery::PrivetHTTPResolution> privet_http_resolution_; | 379 scoped_ptr<cloud_print::PrivetHTTPResolution> privet_http_resolution_; |
380 scoped_ptr<local_discovery::PrivetV1HTTPClient> privet_http_client_; | 380 scoped_ptr<cloud_print::PrivetV1HTTPClient> privet_http_client_; |
381 scoped_ptr<local_discovery::PrivetJSONOperation> | 381 scoped_ptr<cloud_print::PrivetJSONOperation> |
382 privet_capabilities_operation_; | 382 privet_capabilities_operation_; |
383 scoped_ptr<local_discovery::PrivetLocalPrintOperation> | 383 scoped_ptr<cloud_print::PrivetLocalPrintOperation> |
384 privet_local_print_operation_; | 384 privet_local_print_operation_; |
385 #endif | 385 #endif |
386 | 386 |
387 // Handles requests for extension printers. Created lazily by calling | 387 // Handles requests for extension printers. Created lazily by calling |
388 // |EnsureExtensionPrinterHandlerSet|. | 388 // |EnsureExtensionPrinterHandlerSet|. |
389 scoped_ptr<PrinterHandler> extension_printer_handler_; | 389 scoped_ptr<PrinterHandler> extension_printer_handler_; |
390 | 390 |
391 // Notifies tests that want to know if the PDF has been saved. This doesn't | 391 // 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. | 392 // notify the test if it was a successful save, only that it was attempted. |
393 base::Closure pdf_file_saved_closure_; | 393 base::Closure pdf_file_saved_closure_; |
394 | 394 |
395 // A print preview that is responsible for rendering the page after | 395 // A print preview that is responsible for rendering the page after |
396 // being processed by the DOM Distiller. | 396 // being processed by the DOM Distiller. |
397 scoped_ptr<PrintPreviewDistiller> print_preview_distiller_; | 397 scoped_ptr<PrintPreviewDistiller> print_preview_distiller_; |
398 | 398 |
399 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; | 399 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; |
400 | 400 |
401 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 401 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
402 }; | 402 }; |
403 | 403 |
404 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 404 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
OLD | NEW |