| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/printing/print_view_manager_observer.h" | 11 #include "chrome/browser/printing/print_view_manager_observer.h" |
| 12 #include "chrome/browser/ui/shell_dialogs.h" | 12 #include "chrome/browser/ui/shell_dialogs.h" |
| 13 #include "content/browser/webui/web_ui.h" | 13 #include "content/browser/webui/web_ui.h" |
| 14 | 14 |
| 15 class FilePath; | 15 class FilePath; |
| 16 class PrintSystemTaskProxy; |
| 17 |
| 18 namespace base { |
| 16 class FundamentalValue; | 19 class FundamentalValue; |
| 17 class PrintSystemTaskProxy; | |
| 18 class StringValue; | 20 class StringValue; |
| 21 } |
| 19 | 22 |
| 20 namespace printing { | 23 namespace printing { |
| 21 class PrintBackend; | 24 class PrintBackend; |
| 22 } | 25 } |
| 23 | 26 |
| 24 // The handler for Javascript messages related to the print preview dialog. | 27 // The handler for Javascript messages related to the print preview dialog. |
| 25 class PrintPreviewHandler : public WebUIMessageHandler, | 28 class PrintPreviewHandler : public WebUIMessageHandler, |
| 26 public base::SupportsWeakPtr<PrintPreviewHandler>, | 29 public base::SupportsWeakPtr<PrintPreviewHandler>, |
| 27 public SelectFileDialog::Listener, | 30 public SelectFileDialog::Listener, |
| 28 public printing::PrintViewManagerObserver { | 31 public printing::PrintViewManagerObserver { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 // this object has access to the PrintViewManager in order to disconnect the | 50 // this object has access to the PrintViewManager in order to disconnect the |
| 48 // observer. | 51 // observer. |
| 49 void OnNavigation(); | 52 void OnNavigation(); |
| 50 | 53 |
| 51 private: | 54 private: |
| 52 friend class PrintSystemTaskProxy; | 55 friend class PrintSystemTaskProxy; |
| 53 | 56 |
| 54 TabContents* preview_tab(); | 57 TabContents* preview_tab(); |
| 55 | 58 |
| 56 // Get the default printer. |args| is unused. | 59 // Get the default printer. |args| is unused. |
| 57 void HandleGetDefaultPrinter(const ListValue* args); | 60 void HandleGetDefaultPrinter(const base::ListValue* args); |
| 58 | 61 |
| 59 // Get the list of printers. |args| is unused. | 62 // Get the list of printers. |args| is unused. |
| 60 void HandleGetPrinters(const ListValue* args); | 63 void HandleGetPrinters(const base::ListValue* args); |
| 61 | 64 |
| 62 // Ask the initiator renderer to generate a preview. | 65 // Ask the initiator renderer to generate a preview. |
| 63 // First element of |args| is a job settings JSON string. | 66 // First element of |args| is a job settings JSON string. |
| 64 void HandleGetPreview(const ListValue* args); | 67 void HandleGetPreview(const base::ListValue* args); |
| 65 | 68 |
| 66 // Get the job settings from Web UI and initiate printing. | 69 // Get the job settings from Web UI and initiate printing. |
| 67 // First element of |args| is a job settings JSON string. | 70 // First element of |args| is a job settings JSON string. |
| 68 void HandlePrint(const ListValue* args); | 71 void HandlePrint(const base::ListValue* args); |
| 69 | 72 |
| 70 // Handles the request to hide the preview tab for printing. | 73 // Handles the request to hide the preview tab for printing. |
| 71 // |args| is unused. | 74 // |args| is unused. |
| 72 void HandleHidePreview(const ListValue* args); | 75 void HandleHidePreview(const base::ListValue* args); |
| 73 | 76 |
| 74 // Handles the request to cancel the pending print request. | 77 // Handles the request to cancel the pending print request. |
| 75 // |args| is unused. | 78 // |args| is unused. |
| 76 void HandleCancelPendingPrintRequest(const ListValue* args); | 79 void HandleCancelPendingPrintRequest(const base::ListValue* args); |
| 77 | 80 |
| 78 // Get the printer capabilities. | 81 // Get the printer capabilities. |
| 79 // First element of |args| is the printer name. | 82 // First element of |args| is the printer name. |
| 80 void HandleGetPrinterCapabilities(const ListValue* args); | 83 void HandleGetPrinterCapabilities(const base::ListValue* args); |
| 81 | 84 |
| 82 // Ask the initiator renderer to show the native print system dialog. | 85 // Ask the initiator renderer to show the native print system dialog. |
| 83 // |args| is unused. | 86 // |args| is unused. |
| 84 void HandleShowSystemDialog(const ListValue* args); | 87 void HandleShowSystemDialog(const base::ListValue* args); |
| 85 | 88 |
| 86 // Ask the browser to show the native printer management dialog. | 89 // Ask the browser to show the native printer management dialog. |
| 87 // |args| is unused. | 90 // |args| is unused. |
| 88 void HandleManagePrinters(const ListValue* args); | 91 void HandleManagePrinters(const base::ListValue* args); |
| 89 | 92 |
| 90 // Ask the browser to close the preview tab. | 93 // Ask the browser to close the preview tab. |
| 91 // |args| is unused. | 94 // |args| is unused. |
| 92 void HandleClosePreviewTab(const ListValue* args); | 95 void HandleClosePreviewTab(const base::ListValue* args); |
| 93 | 96 |
| 94 // Send the printer capabilities to the Web UI. | 97 // Send the printer capabilities to the Web UI. |
| 95 // |settings_info| contains printer capabilities information. | 98 // |settings_info| contains printer capabilities information. |
| 96 void SendPrinterCapabilities(const DictionaryValue& settings_info); | 99 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); |
| 97 | 100 |
| 98 // Send the default printer to the Web UI. | 101 // Send the default printer to the Web UI. |
| 99 void SendDefaultPrinter(const StringValue& default_printer); | 102 void SendDefaultPrinter(const base::StringValue& default_printer); |
| 100 | 103 |
| 101 // Send the list of printers to the Web UI. | 104 // Send the list of printers to the Web UI. |
| 102 void SendPrinterList(const ListValue& printers); | 105 void SendPrinterList(const base::ListValue& printers); |
| 103 | 106 |
| 104 // Helper function to get the initiator tab for the print preview tab. | 107 // Helper function to get the initiator tab for the print preview tab. |
| 105 TabContents* GetInitiatorTab(); | 108 TabContents* GetInitiatorTab(); |
| 106 | 109 |
| 107 // Helper function to close the print preview tab. | 110 // Helper function to close the print preview tab. |
| 108 void ClosePrintPreviewTab(); | 111 void ClosePrintPreviewTab(); |
| 109 | 112 |
| 110 // Helper function to activate the initiator tab and close the preview tab. | 113 // Helper function to activate the initiator tab and close the preview tab. |
| 111 void ActivateInitiatorTabAndClosePreviewTab(); | 114 void ActivateInitiatorTabAndClosePreviewTab(); |
| 112 | 115 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 138 // Whether we have already logged a failed print preview. | 141 // Whether we have already logged a failed print preview. |
| 139 bool reported_failed_preview_; | 142 bool reported_failed_preview_; |
| 140 | 143 |
| 141 // Whether we have already logged the number of printers this session. | 144 // Whether we have already logged the number of printers this session. |
| 142 bool has_logged_printers_count_; | 145 bool has_logged_printers_count_; |
| 143 | 146 |
| 144 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 147 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
| 145 }; | 148 }; |
| 146 | 149 |
| 147 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ | 150 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ |
| OLD | NEW |