| 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/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/printing/print_view_manager_observer.h" | 14 #include "chrome/browser/printing/print_view_manager_observer.h" |
| 15 #include "content/public/browser/web_ui_message_handler.h" | 15 #include "content/public/browser/web_ui_message_handler.h" |
| 16 #include "ui/shell_dialogs/select_file_dialog.h" | 16 #include "ui/shell_dialogs/select_file_dialog.h" |
| 17 | 17 |
| 18 #if defined(ENABLE_MDNS) | 18 #if defined(ENABLE_SERVICE_DISCOVERY) |
| 19 #include "chrome/browser/local_discovery/privet_local_printer_lister.h" | 19 #include "chrome/browser/local_discovery/privet_local_printer_lister.h" |
| 20 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 20 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
| 21 #endif // ENABLE_MDNS | 21 #endif // ENABLE_SERVICE_DISCOVERY |
| 22 | 22 |
| 23 class PrintSystemTaskProxy; | 23 class PrintSystemTaskProxy; |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class DictionaryValue; | 26 class DictionaryValue; |
| 27 class RefCountedBytes; | 27 class RefCountedBytes; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 class WebContents; | 31 class WebContents; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace gfx { | 34 namespace gfx { |
| 35 class Size; | 35 class Size; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace printing { | 38 namespace printing { |
| 39 struct PageSizeMargins; | 39 struct PageSizeMargins; |
| 40 class PrintBackend; | 40 class PrintBackend; |
| 41 } | 41 } |
| 42 | 42 |
| 43 // The handler for Javascript messages related to the print preview dialog. | 43 // The handler for Javascript messages related to the print preview dialog. |
| 44 class PrintPreviewHandler | 44 class PrintPreviewHandler |
| 45 : public content::WebUIMessageHandler, | 45 : public content::WebUIMessageHandler, |
| 46 #if defined(ENABLE_MDNS) | 46 #if defined(ENABLE_SERVICE_DISCOVERY) |
| 47 public local_discovery::PrivetLocalPrinterLister::Delegate, | 47 public local_discovery::PrivetLocalPrinterLister::Delegate, |
| 48 public local_discovery::PrivetLocalPrintOperation::Delegate, | 48 public local_discovery::PrivetLocalPrintOperation::Delegate, |
| 49 #endif | 49 #endif |
| 50 public ui::SelectFileDialog::Listener, | 50 public ui::SelectFileDialog::Listener, |
| 51 public printing::PrintViewManagerObserver { | 51 public printing::PrintViewManagerObserver { |
| 52 public: | 52 public: |
| 53 PrintPreviewHandler(); | 53 PrintPreviewHandler(); |
| 54 virtual ~PrintPreviewHandler(); | 54 virtual ~PrintPreviewHandler(); |
| 55 | 55 |
| 56 // WebUIMessageHandler implementation. | 56 // WebUIMessageHandler implementation. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 73 // observer. | 73 // observer. |
| 74 void OnPrintPreviewDialogDestroyed(); | 74 void OnPrintPreviewDialogDestroyed(); |
| 75 | 75 |
| 76 // Called when print preview failed. | 76 // Called when print preview failed. |
| 77 void OnPrintPreviewFailed(); | 77 void OnPrintPreviewFailed(); |
| 78 | 78 |
| 79 // Called when the user press ctrl+shift+p to display the native system | 79 // Called when the user press ctrl+shift+p to display the native system |
| 80 // dialog. | 80 // dialog. |
| 81 void ShowSystemDialog(); | 81 void ShowSystemDialog(); |
| 82 | 82 |
| 83 #if defined(ENABLE_MDNS) | 83 #if defined(ENABLE_SERVICE_DISCOVERY) |
| 84 // PrivetLocalPrinterLister::Delegate implementation. | 84 // PrivetLocalPrinterLister::Delegate implementation. |
| 85 virtual void LocalPrinterChanged( | 85 virtual void LocalPrinterChanged( |
| 86 bool added, | 86 bool added, |
| 87 const std::string& name, | 87 const std::string& name, |
| 88 bool has_local_printing, | 88 bool has_local_printing, |
| 89 const local_discovery::DeviceDescription& description) OVERRIDE; | 89 const local_discovery::DeviceDescription& description) OVERRIDE; |
| 90 virtual void LocalPrinterRemoved(const std::string& name) OVERRIDE; | 90 virtual void LocalPrinterRemoved(const std::string& name) OVERRIDE; |
| 91 virtual void LocalPrinterCacheFlushed() OVERRIDE; | 91 virtual void LocalPrinterCacheFlushed() OVERRIDE; |
| 92 | 92 |
| 93 // PrivetLocalPrintOperation::Delegate implementation. | 93 // PrivetLocalPrintOperation::Delegate implementation. |
| 94 virtual void OnPrivetPrintingDone( | 94 virtual void OnPrivetPrintingDone( |
| 95 const local_discovery::PrivetLocalPrintOperation* | 95 const local_discovery::PrivetLocalPrintOperation* |
| 96 print_operation) OVERRIDE; | 96 print_operation) OVERRIDE; |
| 97 virtual void OnPrivetPrintingError( | 97 virtual void OnPrivetPrintingError( |
| 98 const local_discovery::PrivetLocalPrintOperation* print_operation, | 98 const local_discovery::PrivetLocalPrintOperation* print_operation, |
| 99 int http_code) OVERRIDE; | 99 int http_code) OVERRIDE; |
| 100 #endif // ENABLE_MDNS | 100 #endif // ENABLE_SERVICE_DISCOVERY |
| 101 int regenerate_preview_request_count() const { | 101 int regenerate_preview_request_count() const { |
| 102 return regenerate_preview_request_count_; | 102 return regenerate_preview_request_count_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 class AccessTokenService; | 106 class AccessTokenService; |
| 107 struct CUPSPrinterColorModels; | 107 struct CUPSPrinterColorModels; |
| 108 | 108 |
| 109 static bool PrivetPrintingEnabled(); | 109 static bool PrivetPrintingEnabled(); |
| 110 | 110 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 bool GetPreviewDataAndTitle(scoped_refptr<base::RefCountedBytes>* data, | 240 bool GetPreviewDataAndTitle(scoped_refptr<base::RefCountedBytes>* data, |
| 241 base::string16* title) const; | 241 base::string16* title) const; |
| 242 | 242 |
| 243 #if defined(USE_CUPS) | 243 #if defined(USE_CUPS) |
| 244 void SaveCUPSColorSetting(const base::DictionaryValue* settings); | 244 void SaveCUPSColorSetting(const base::DictionaryValue* settings); |
| 245 | 245 |
| 246 void ConvertColorSettingToCUPSColorModel( | 246 void ConvertColorSettingToCUPSColorModel( |
| 247 base::DictionaryValue* settings) const; | 247 base::DictionaryValue* settings) const; |
| 248 #endif | 248 #endif |
| 249 | 249 |
| 250 #if defined(ENABLE_MDNS) | 250 #if defined(ENABLE_SERVICE_DISCOVERY) |
| 251 void OnPrivetCapabilities(const base::DictionaryValue* capabilities); | 251 void OnPrivetCapabilities(const base::DictionaryValue* capabilities); |
| 252 | |
| 253 | |
| 254 void PrivetCapabilitiesUpdateClient( | 252 void PrivetCapabilitiesUpdateClient( |
| 255 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); | 253 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); |
| 256 void PrivetLocalPrintUpdateClient( | 254 void PrivetLocalPrintUpdateClient( |
| 257 std::string print_ticket, | 255 std::string print_ticket, |
| 258 gfx::Size page_size, | 256 gfx::Size page_size, |
| 259 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); | 257 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); |
| 260 bool PrivetUpdateClient( | 258 bool PrivetUpdateClient( |
| 261 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); | 259 scoped_ptr<local_discovery::PrivetHTTPClient> http_client); |
| 262 void StartPrivetLocalPrint(const std::string& print_ticket, | 260 void StartPrivetLocalPrint(const std::string& print_ticket, |
| 263 const gfx::Size& page_size); | 261 const gfx::Size& page_size); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 base::FilePath print_to_pdf_path_; | 299 base::FilePath print_to_pdf_path_; |
| 302 | 300 |
| 303 // Holds token service to get OAuth2 access tokens. | 301 // Holds token service to get OAuth2 access tokens. |
| 304 scoped_ptr<AccessTokenService> token_service_; | 302 scoped_ptr<AccessTokenService> token_service_; |
| 305 | 303 |
| 306 #if defined(USE_CUPS) | 304 #if defined(USE_CUPS) |
| 307 // The color capabilities from the last printer queried. | 305 // The color capabilities from the last printer queried. |
| 308 scoped_ptr<CUPSPrinterColorModels> cups_printer_color_models_; | 306 scoped_ptr<CUPSPrinterColorModels> cups_printer_color_models_; |
| 309 #endif | 307 #endif |
| 310 | 308 |
| 311 #if defined(ENABLE_MDNS) | 309 #if defined(ENABLE_SERVICE_DISCOVERY) |
| 312 scoped_refptr<local_discovery::ServiceDiscoverySharedClient> | 310 scoped_refptr<local_discovery::ServiceDiscoverySharedClient> |
| 313 service_discovery_client_; | 311 service_discovery_client_; |
| 314 scoped_ptr<local_discovery::PrivetLocalPrinterLister> printer_lister_; | 312 scoped_ptr<local_discovery::PrivetLocalPrinterLister> printer_lister_; |
| 315 | 313 |
| 316 scoped_ptr<local_discovery::PrivetHTTPAsynchronousFactory> | 314 scoped_ptr<local_discovery::PrivetHTTPAsynchronousFactory> |
| 317 privet_http_factory_; | 315 privet_http_factory_; |
| 318 scoped_ptr<local_discovery::PrivetHTTPResolution> privet_http_resolution_; | 316 scoped_ptr<local_discovery::PrivetHTTPResolution> privet_http_resolution_; |
| 319 scoped_ptr<local_discovery::PrivetHTTPClient> privet_http_client_; | 317 scoped_ptr<local_discovery::PrivetHTTPClient> privet_http_client_; |
| 320 scoped_ptr<local_discovery::PrivetJSONOperation> | 318 scoped_ptr<local_discovery::PrivetJSONOperation> |
| 321 privet_capabilities_operation_; | 319 privet_capabilities_operation_; |
| 322 scoped_ptr<local_discovery::PrivetLocalPrintOperation> | 320 scoped_ptr<local_discovery::PrivetLocalPrintOperation> |
| 323 privet_local_print_operation_; | 321 privet_local_print_operation_; |
| 324 #endif | 322 #endif |
| 325 | 323 |
| 326 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; | 324 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; |
| 327 | 325 |
| 328 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 326 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
| 329 }; | 327 }; |
| 330 | 328 |
| 331 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 329 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
| OLD | NEW |