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_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/ref_counted_memory.h" |
12 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "chrome/browser/printing/print_preview_data_service.h" |
13 #include "content/browser/webui/web_ui.h" | 15 #include "content/browser/webui/web_ui.h" |
14 | 16 |
15 class PrintPreviewUIHTMLSource; | 17 class PrintPreviewDataService; |
16 | 18 |
17 class PrintPreviewUI : public WebUI { | 19 class PrintPreviewUI : public WebUI { |
18 public: | 20 public: |
19 explicit PrintPreviewUI(TabContents* contents); | 21 explicit PrintPreviewUI(TabContents* contents); |
20 virtual ~PrintPreviewUI(); | 22 virtual ~PrintPreviewUI(); |
21 | 23 |
22 PrintPreviewUIHTMLSource* html_source(); | 24 // Gets the print preview |data|. The data is valid as long as the |
| 25 // PrintPreviewDataService is valid and SetPrintPreviewData() does not get |
| 26 // called. |
| 27 void GetPrintPreviewData(scoped_refptr<RefCountedBytes>* data); |
| 28 |
| 29 // Sets the print preview |data|. |
| 30 void SetPrintPreviewData(const RefCountedBytes* data); |
23 | 31 |
24 // Notify the Web UI renderer that preview data is available. | 32 // Notify the Web UI renderer that preview data is available. |
25 // |expected_pages_count| specifies the total number of pages. | 33 // |expected_pages_count| specifies the total number of pages. |
26 // |job_title| is the title of the page being previewed. | 34 // |job_title| is the title of the page being previewed. |
27 // |modifiable| indicates if the preview can be rerendered with different | 35 // |modifiable| indicates if the preview can be rerendered with different |
28 // print settings. | 36 // print settings. |
29 void OnPreviewDataIsAvailable(int expected_pages_count, | 37 void OnPreviewDataIsAvailable(int expected_pages_count, |
30 const string16& job_title, | 38 const string16& job_title, |
31 bool modifiable); | 39 bool modifiable); |
32 | 40 |
33 // Notify the Web UI that initiator tab is closed, so we can disable all | 41 // Notify the Web UI that initiator tab is closed, so we can disable all |
34 // the controls that need the initiator tab for generating the preview data. | 42 // the controls that need the initiator tab for generating the preview data. |
35 // |initiator_tab_url| is passed in order to display a more accurate error | 43 // |initiator_tab_url| is passed in order to display a more accurate error |
36 // message. | 44 // message. |
37 void OnInitiatorTabClosed(const std::string& initiator_tab_url); | 45 void OnInitiatorTabClosed(const std::string& initiator_tab_url); |
38 | 46 |
39 private: | 47 private: |
40 scoped_refptr<PrintPreviewUIHTMLSource> html_source_; | 48 // Helper function |
| 49 PrintPreviewDataService* print_preview_data_service(); |
| 50 |
41 base::TimeTicks initial_preview_start_time_; | 51 base::TimeTicks initial_preview_start_time_; |
42 | 52 |
| 53 // Store the PrintPreviewUI address string. |
| 54 std::string preview_ui_addr_str_; |
| 55 |
43 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); | 56 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); |
44 }; | 57 }; |
45 | 58 |
46 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 59 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
OLD | NEW |