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_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_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/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 13 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
14 | 14 |
15 class PrintPreviewDataService; | 15 class PrintPreviewDataService; |
16 class PrintPreviewHandler; | 16 class PrintPreviewHandler; |
17 struct PrintHostMsg_DidGetPreviewPageCount_Params; | 17 struct PrintHostMsg_DidGetPreviewPageCount_Params; |
18 struct PrintHostMsg_RequestPrintPreview_Params; | 18 struct PrintHostMsg_RequestPrintPreview_Params; |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class RefCountedBytes; | 21 class RefCountedBytes; |
22 class FilePath; | |
Lei Zhang
2014/07/17 21:08:16
nit: Alphabetical order.
ivandavid
2014/07/17 22:27:47
Done.
| |
22 } | 23 } |
23 | 24 |
24 namespace gfx { | 25 namespace gfx { |
25 class Rect; | 26 class Rect; |
26 } | 27 } |
27 | 28 |
28 namespace printing { | 29 namespace printing { |
29 struct PageSizeMargins; | 30 struct PageSizeMargins; |
30 } | 31 } |
31 | 32 |
(...skipping 19 matching lines...) Expand all Loading... | |
51 | 52 |
52 // Returns the available draft page count. | 53 // Returns the available draft page count. |
53 int GetAvailableDraftPageCount(); | 54 int GetAvailableDraftPageCount(); |
54 | 55 |
55 // Setters | 56 // Setters |
56 void SetInitiatorTitle(const base::string16& initiator_title); | 57 void SetInitiatorTitle(const base::string16& initiator_title); |
57 | 58 |
58 base::string16 initiator_title() { return initiator_title_; } | 59 base::string16 initiator_title() { return initiator_title_; } |
59 | 60 |
60 bool source_is_modifiable() { return source_is_modifiable_; } | 61 bool source_is_modifiable() { return source_is_modifiable_; } |
61 | |
62 bool source_has_selection() { return source_has_selection_; } | 62 bool source_has_selection() { return source_has_selection_; } |
63 | 63 |
64 bool print_selection_only() { return print_selection_only_; } | 64 bool print_selection_only() { return print_selection_only_; } |
65 | 65 |
66 // Set initial settings for PrintPreviewUI. | 66 // Set initial settings for PrintPreviewUI. |
67 static void SetInitialParams( | 67 static void SetInitialParams( |
68 content::WebContents* print_preview_dialog, | 68 content::WebContents* print_preview_dialog, |
69 const PrintHostMsg_RequestPrintPreview_Params& params); | 69 const PrintHostMsg_RequestPrintPreview_Params& params); |
70 | 70 |
71 // Determines whether to cancel a print preview request based on | 71 // Determines whether to cancel a print preview request based on |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 // also instructs the dialog to auto-cancel, which is used for testing only. | 147 // also instructs the dialog to auto-cancel, which is used for testing only. |
148 class TestingDelegate { | 148 class TestingDelegate { |
149 public: | 149 public: |
150 virtual bool IsAutoCancelEnabled() = 0; | 150 virtual bool IsAutoCancelEnabled() = 0; |
151 virtual void DidGetPreviewPageCount(int page_count) = 0; | 151 virtual void DidGetPreviewPageCount(int page_count) = 0; |
152 virtual void DidRenderPreviewPage(content::WebContents* preview_dialog) = 0; | 152 virtual void DidRenderPreviewPage(content::WebContents* preview_dialog) = 0; |
153 }; | 153 }; |
154 | 154 |
155 static void SetDelegateForTesting(TestingDelegate* delegate); | 155 static void SetDelegateForTesting(TestingDelegate* delegate); |
156 | 156 |
157 // Allows for tests to set a file path to print a PDF to. This also initiates | |
158 // the printing without having to click a button on the print preview dialog. | |
159 void SetSelectedFileForTesting(const base::FilePath& path); | |
160 | |
157 private: | 161 private: |
158 friend class PrintPreviewHandlerTest; | 162 friend class PrintPreviewHandlerTest; |
159 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsCustom); | 163 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsCustom); |
160 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsDefault); | 164 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsDefault); |
161 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, | 165 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, |
162 StickyMarginsCustomThenDefault); | 166 StickyMarginsCustomThenDefault); |
163 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, | 167 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, |
164 GetLastUsedMarginSettingsCustom); | 168 GetLastUsedMarginSettingsCustom); |
165 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, | 169 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, |
166 GetLastUsedMarginSettingsDefault); | 170 GetLastUsedMarginSettingsDefault); |
(...skipping 25 matching lines...) Expand all Loading... | |
192 // title. | 196 // title. |
193 base::string16 initiator_title_; | 197 base::string16 initiator_title_; |
194 | 198 |
195 // Keeps track of whether OnClosePrintPreviewDialog() has been called or not. | 199 // Keeps track of whether OnClosePrintPreviewDialog() has been called or not. |
196 bool dialog_closed_; | 200 bool dialog_closed_; |
197 | 201 |
198 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); | 202 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); |
199 }; | 203 }; |
200 | 204 |
201 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_ | 205 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_ |
OLD | NEW |