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 "chrome/browser/ui/select_file_dialog.h" | |
17 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
18 #include "printing/print_job_constants.h" | 17 #include "printing/print_job_constants.h" |
| 18 #include "ui/base/dialogs/select_file_dialog.h" |
19 | 19 |
20 class FilePath; | 20 class FilePath; |
21 class PrintSystemTaskProxy; | 21 class PrintSystemTaskProxy; |
22 class TabContents; | 22 class TabContents; |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 class DictionaryValue; | 25 class DictionaryValue; |
26 class RefCountedBytes; | 26 class RefCountedBytes; |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 class WebContents; | 30 class WebContents; |
31 } | 31 } |
32 | 32 |
33 namespace printing { | 33 namespace printing { |
34 struct PageSizeMargins; | 34 struct PageSizeMargins; |
35 class PrintBackend; | 35 class PrintBackend; |
36 class StickySettings; | 36 class StickySettings; |
37 } | 37 } |
38 | 38 |
39 // The handler for Javascript messages related to the print preview dialog. | 39 // The handler for Javascript messages related to the print preview dialog. |
40 class PrintPreviewHandler : public content::WebUIMessageHandler, | 40 class PrintPreviewHandler : public content::WebUIMessageHandler, |
41 public base::SupportsWeakPtr<PrintPreviewHandler>, | 41 public base::SupportsWeakPtr<PrintPreviewHandler>, |
42 public SelectFileDialog::Listener, | 42 public ui::SelectFileDialog::Listener, |
43 public printing::PrintViewManagerObserver { | 43 public printing::PrintViewManagerObserver { |
44 public: | 44 public: |
45 PrintPreviewHandler(); | 45 PrintPreviewHandler(); |
46 virtual ~PrintPreviewHandler(); | 46 virtual ~PrintPreviewHandler(); |
47 | 47 |
48 // WebUIMessageHandler implementation. | 48 // WebUIMessageHandler implementation. |
49 virtual void RegisterMessages() OVERRIDE; | 49 virtual void RegisterMessages() OVERRIDE; |
50 | 50 |
51 // SelectFileDialog::Listener implementation. | 51 // SelectFileDialog::Listener implementation. |
52 virtual void FileSelected(const FilePath& path, | 52 virtual void FileSelected(const FilePath& path, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 // Populates |settings| according to the current locale. | 189 // Populates |settings| according to the current locale. |
190 void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); | 190 void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); |
191 | 191 |
192 static printing::StickySettings* GetStickySettings(); | 192 static printing::StickySettings* GetStickySettings(); |
193 | 193 |
194 // Pointer to current print system. | 194 // Pointer to current print system. |
195 scoped_refptr<printing::PrintBackend> print_backend_; | 195 scoped_refptr<printing::PrintBackend> print_backend_; |
196 | 196 |
197 // The underlying dialog object. | 197 // The underlying dialog object. |
198 scoped_refptr<SelectFileDialog> select_file_dialog_; | 198 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
199 | 199 |
200 // A count of how many requests received to regenerate preview data. | 200 // A count of how many requests received to regenerate preview data. |
201 // Initialized to 0 then incremented and emitted to a histogram. | 201 // Initialized to 0 then incremented and emitted to a histogram. |
202 int regenerate_preview_request_count_; | 202 int regenerate_preview_request_count_; |
203 | 203 |
204 // A count of how many requests received to show manage printers dialog. | 204 // A count of how many requests received to show manage printers dialog. |
205 int manage_printers_dialog_request_count_; | 205 int manage_printers_dialog_request_count_; |
206 int manage_cloud_printers_dialog_request_count_; | 206 int manage_cloud_printers_dialog_request_count_; |
207 | 207 |
208 // Whether we have already logged a failed print preview. | 208 // Whether we have already logged a failed print preview. |
209 bool reported_failed_preview_; | 209 bool reported_failed_preview_; |
210 | 210 |
211 // Whether we have already logged the number of printers this session. | 211 // Whether we have already logged the number of printers this session. |
212 bool has_logged_printers_count_; | 212 bool has_logged_printers_count_; |
213 | 213 |
214 // Holds the path to the print to pdf request. It is empty if no such request | 214 // Holds the path to the print to pdf request. It is empty if no such request |
215 // exists. | 215 // exists. |
216 scoped_ptr<FilePath> print_to_pdf_path_; | 216 scoped_ptr<FilePath> print_to_pdf_path_; |
217 | 217 |
218 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 218 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
219 }; | 219 }; |
220 | 220 |
221 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 221 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
OLD | NEW |