| 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 "components/signin/core/browser/gaia_cookie_manager_service.h" | 15 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
| 16 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
| 17 #include "ui/shell_dialogs/select_file_dialog.h" | 17 #include "ui/shell_dialogs/select_file_dialog.h" |
| 18 | 18 |
| 19 #if defined(ENABLE_SERVICE_DISCOVERY) | 19 #if defined(ENABLE_SERVICE_DISCOVERY) |
| 20 #include "chrome/browser/local_discovery/privet_local_printer_lister.h" | 20 #include "chrome/browser/local_discovery/privet_local_printer_lister.h" |
| 21 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 21 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
| 22 #endif // ENABLE_SERVICE_DISCOVERY | 22 #endif // ENABLE_SERVICE_DISCOVERY |
| 23 | 23 |
| 24 class ExtensionPrinterHandler; |
| 24 class PrinterHandler; | 25 class PrinterHandler; |
| 25 class PrintPreviewUI; | 26 class PrintPreviewUI; |
| 26 class PrintSystemTaskProxy; | 27 class PrintSystemTaskProxy; |
| 27 | 28 |
| 28 namespace base { | 29 namespace base { |
| 29 class DictionaryValue; | 30 class DictionaryValue; |
| 30 class RefCountedBytes; | 31 class RefCountedBytes; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 116 |
| 116 static bool PrivetPrintingEnabled(); | 117 static bool PrivetPrintingEnabled(); |
| 117 | 118 |
| 118 content::WebContents* preview_web_contents() const; | 119 content::WebContents* preview_web_contents() const; |
| 119 | 120 |
| 120 PrintPreviewUI* print_preview_ui() const; | 121 PrintPreviewUI* print_preview_ui() const; |
| 121 | 122 |
| 122 // Gets the list of printers. |args| is unused. | 123 // Gets the list of printers. |args| is unused. |
| 123 void HandleGetPrinters(const base::ListValue* args); | 124 void HandleGetPrinters(const base::ListValue* args); |
| 124 | 125 |
| 125 // Starts getting all local privet printers. |arg| is unused. | 126 // Starts getting all local privet printers. |args| is unused. |
| 126 void HandleGetPrivetPrinters(const base::ListValue* args); | 127 void HandleGetPrivetPrinters(const base::ListValue* args); |
| 127 | 128 |
| 128 // Starts getting all local extension managed printers. |arg| is unused. | 129 // Starts getting all local extension managed printers. |args| is unused. |
| 129 void HandleGetExtensionPrinters(const base::ListValue* args); | 130 void HandleGetExtensionPrinters(const base::ListValue* args); |
| 130 | 131 |
| 132 // Grants an extension access to a USB printer. First element of |args| is |
| 133 // the extension ID and the second element is USB device ID. |
| 134 void HandleGrantExtensionUsbPrinterAccess(const base::ListValue* args); |
| 135 |
| 131 // Stops getting all local privet printers. |arg| is unused. | 136 // Stops getting all local privet printers. |arg| is unused. |
| 132 void HandleStopGetPrivetPrinters(const base::ListValue* args); | 137 void HandleStopGetPrivetPrinters(const base::ListValue* args); |
| 133 | 138 |
| 134 // Asks the initiator renderer to generate a preview. First element of |args| | 139 // Asks the initiator renderer to generate a preview. First element of |args| |
| 135 // is a job settings JSON string. | 140 // is a job settings JSON string. |
| 136 void HandleGetPreview(const base::ListValue* args); | 141 void HandleGetPreview(const base::ListValue* args); |
| 137 | 142 |
| 138 // Gets the job settings from Web UI and initiate printing. First element of | 143 // Gets the job settings from Web UI and initiate printing. First element of |
| 139 // |args| is a job settings JSON string. | 144 // |args| is a job settings JSON string. |
| 140 void HandlePrint(const base::ListValue* args); | 145 void HandlePrint(const base::ListValue* args); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // Lazily creates |extension_printer_handler_| that can be used to handle | 306 // Lazily creates |extension_printer_handler_| that can be used to handle |
| 302 // extension printers requests. | 307 // extension printers requests. |
| 303 void EnsureExtensionPrinterHandlerSet(); | 308 void EnsureExtensionPrinterHandlerSet(); |
| 304 | 309 |
| 305 // Called when a list of printers is reported by an extension. | 310 // Called when a list of printers is reported by an extension. |
| 306 // |printers|: The list of printers managed by the extension. | 311 // |printers|: The list of printers managed by the extension. |
| 307 // |done|: Whether all the extensions have reported the list of printers | 312 // |done|: Whether all the extensions have reported the list of printers |
| 308 // they manage. | 313 // they manage. |
| 309 void OnGotPrintersForExtension(const base::ListValue& printers, bool done); | 314 void OnGotPrintersForExtension(const base::ListValue& printers, bool done); |
| 310 | 315 |
| 316 // Called when an extension reports information for a USB printer it has just |
| 317 // been granted access to. |
| 318 // |extension_id|: The extension that was queried. |
| 319 // |device_id|: The id of the USB device. |
| 320 // |printer_info|: The data reported by the extension. |
| 321 void OnGotExtensionUsbPrinterInfo(const std::string& extension_id, |
| 322 int device_id, |
| 323 const base::DictionaryValue& printer_info); |
| 324 |
| 311 // Called when an extension reports the set of print capabilites for a | 325 // Called when an extension reports the set of print capabilites for a |
| 312 // printer. | 326 // printer. |
| 313 // |printer_id|: The id of the printer whose capabilities are reported. | 327 // |printer_id|: The id of the printer whose capabilities are reported. |
| 314 // |capabilities|: The printer capabilities. | 328 // |capabilities|: The printer capabilities. |
| 315 void OnGotExtensionPrinterCapabilities( | 329 void OnGotExtensionPrinterCapabilities( |
| 316 const std::string& printer_id, | 330 const std::string& printer_id, |
| 317 const base::DictionaryValue& capabilities); | 331 const base::DictionaryValue& capabilities); |
| 318 | 332 |
| 319 // Called when an extension print job is completed. | 333 // Called when an extension print job is completed. |
| 320 // |success|: Whether the job succeeded. | 334 // |success|: Whether the job succeeded. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 scoped_ptr<local_discovery::PrivetHTTPResolution> privet_http_resolution_; | 379 scoped_ptr<local_discovery::PrivetHTTPResolution> privet_http_resolution_; |
| 366 scoped_ptr<local_discovery::PrivetV1HTTPClient> privet_http_client_; | 380 scoped_ptr<local_discovery::PrivetV1HTTPClient> privet_http_client_; |
| 367 scoped_ptr<local_discovery::PrivetJSONOperation> | 381 scoped_ptr<local_discovery::PrivetJSONOperation> |
| 368 privet_capabilities_operation_; | 382 privet_capabilities_operation_; |
| 369 scoped_ptr<local_discovery::PrivetLocalPrintOperation> | 383 scoped_ptr<local_discovery::PrivetLocalPrintOperation> |
| 370 privet_local_print_operation_; | 384 privet_local_print_operation_; |
| 371 #endif | 385 #endif |
| 372 | 386 |
| 373 // Handles requests for extension printers. Created lazily by calling | 387 // Handles requests for extension printers. Created lazily by calling |
| 374 // |EnsureExtensionPrinterHandlerSet|. | 388 // |EnsureExtensionPrinterHandlerSet|. |
| 375 scoped_ptr<PrinterHandler> extension_printer_handler_; | 389 scoped_ptr<ExtensionPrinterHandler> extension_printer_handler_; |
| 376 | 390 |
| 377 // 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 |
| 378 // 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. |
| 379 base::Closure pdf_file_saved_closure_; | 393 base::Closure pdf_file_saved_closure_; |
| 380 | 394 |
| 381 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; | 395 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; |
| 382 | 396 |
| 383 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 397 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
| 384 }; | 398 }; |
| 385 | 399 |
| 386 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 400 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
| OLD | NEW |