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/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.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 "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/printing/print_view_manager_observer.h" | 15 #include "chrome/browser/printing/print_view_manager_observer.h" |
16 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
17 #include "printing/print_job_constants.h" | 17 #include "printing/print_job_constants.h" |
18 #include "ui/shell_dialogs/select_file_dialog.h" | 18 #include "ui/shell_dialogs/select_file_dialog.h" |
19 | 19 |
20 class FilePath; | |
21 class PrintSystemTaskProxy; | 20 class PrintSystemTaskProxy; |
22 | 21 |
23 namespace base { | 22 namespace base { |
24 class DictionaryValue; | 23 class DictionaryValue; |
| 24 class FilePath; |
25 class RefCountedBytes; | 25 class RefCountedBytes; |
26 } | 26 } |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 class WebContents; | 29 class WebContents; |
30 } | 30 } |
31 | 31 |
32 namespace printing { | 32 namespace printing { |
33 struct PageSizeMargins; | 33 struct PageSizeMargins; |
34 class PrintBackend; | 34 class PrintBackend; |
35 class StickySettings; | 35 class StickySettings; |
36 } | 36 } |
37 | 37 |
38 // The handler for Javascript messages related to the print preview dialog. | 38 // The handler for Javascript messages related to the print preview dialog. |
39 class PrintPreviewHandler : public content::WebUIMessageHandler, | 39 class PrintPreviewHandler : public content::WebUIMessageHandler, |
40 public base::SupportsWeakPtr<PrintPreviewHandler>, | 40 public base::SupportsWeakPtr<PrintPreviewHandler>, |
41 public ui::SelectFileDialog::Listener, | 41 public ui::SelectFileDialog::Listener, |
42 public printing::PrintViewManagerObserver { | 42 public printing::PrintViewManagerObserver { |
43 public: | 43 public: |
44 PrintPreviewHandler(); | 44 PrintPreviewHandler(); |
45 virtual ~PrintPreviewHandler(); | 45 virtual ~PrintPreviewHandler(); |
46 | 46 |
47 // WebUIMessageHandler implementation. | 47 // WebUIMessageHandler implementation. |
48 virtual void RegisterMessages() OVERRIDE; | 48 virtual void RegisterMessages() OVERRIDE; |
49 | 49 |
50 // SelectFileDialog::Listener implementation. | 50 // SelectFileDialog::Listener implementation. |
51 virtual void FileSelected(const FilePath& path, | 51 virtual void FileSelected(const base::FilePath& path, |
52 int index, | 52 int index, |
53 void* params) OVERRIDE; | 53 void* params) OVERRIDE; |
54 virtual void FileSelectionCanceled(void* params) OVERRIDE; | 54 virtual void FileSelectionCanceled(void* params) OVERRIDE; |
55 | 55 |
56 // PrintViewManagerObserver implementation. | 56 // PrintViewManagerObserver implementation. |
57 virtual void OnPrintDialogShown() OVERRIDE; | 57 virtual void OnPrintDialogShown() OVERRIDE; |
58 | 58 |
59 // Displays a modal dialog, prompting the user to select a file. | 59 // Displays a modal dialog, prompting the user to select a file. |
60 void SelectFile(const FilePath& default_path); | 60 void SelectFile(const base::FilePath& default_path); |
61 | 61 |
62 // Called when the print preview dialog is destroyed. This is the last time | 62 // Called when the print preview dialog is destroyed. This is the last time |
63 // this object has access to the PrintViewManager in order to disconnect the | 63 // this object has access to the PrintViewManager in order to disconnect the |
64 // observer. | 64 // observer. |
65 void OnPrintPreviewDialogDestroyed(); | 65 void OnPrintPreviewDialogDestroyed(); |
66 | 66 |
67 // Called when print preview failed. | 67 // Called when print preview failed. |
68 void OnPrintPreviewFailed(); | 68 void OnPrintPreviewFailed(); |
69 | 69 |
70 // Called when the user press ctrl+shift+p to display the native system | 70 // Called when the user press ctrl+shift+p to display the native system |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 int manage_cloud_printers_dialog_request_count_; | 213 int manage_cloud_printers_dialog_request_count_; |
214 | 214 |
215 // Whether we have already logged a failed print preview. | 215 // Whether we have already logged a failed print preview. |
216 bool reported_failed_preview_; | 216 bool reported_failed_preview_; |
217 | 217 |
218 // Whether we have already logged the number of printers this session. | 218 // Whether we have already logged the number of printers this session. |
219 bool has_logged_printers_count_; | 219 bool has_logged_printers_count_; |
220 | 220 |
221 // Holds the path to the print to pdf request. It is empty if no such request | 221 // Holds the path to the print to pdf request. It is empty if no such request |
222 // exists. | 222 // exists. |
223 scoped_ptr<FilePath> print_to_pdf_path_; | 223 scoped_ptr<base::FilePath> print_to_pdf_path_; |
224 | 224 |
225 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 225 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
226 }; | 226 }; |
227 | 227 |
228 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 228 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
OLD | NEW |