Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_ui.h

Issue 2824283004: Mark some PrintPreviewUI methods as const. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 17 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
18 #include "printing/features/features.h" 18 #include "printing/features/features.h"
19 19
20 class PrintPreviewDataService;
21 class PrintPreviewHandler; 20 class PrintPreviewHandler;
22 struct PrintHostMsg_DidGetPreviewPageCount_Params; 21 struct PrintHostMsg_DidGetPreviewPageCount_Params;
23 struct PrintHostMsg_RequestPrintPreview_Params; 22 struct PrintHostMsg_RequestPrintPreview_Params;
24 struct PrintHostMsg_SetOptionsFromDocument_Params; 23 struct PrintHostMsg_SetOptionsFromDocument_Params;
25 24
26 namespace base { 25 namespace base {
27 class FilePath; 26 class FilePath;
28 class RefCountedBytes; 27 class RefCountedBytes;
29 } 28 }
30 29
31 namespace gfx { 30 namespace gfx {
32 class Rect; 31 class Rect;
33 } 32 }
34 33
35 namespace printing { 34 namespace printing {
36 struct PageSizeMargins; 35 struct PageSizeMargins;
37 } 36 }
38 37
39 class PrintPreviewUI : public ConstrainedWebDialogUI { 38 class PrintPreviewUI : public ConstrainedWebDialogUI {
40 public: 39 public:
41 explicit PrintPreviewUI(content::WebUI* web_ui); 40 explicit PrintPreviewUI(content::WebUI* web_ui);
42 ~PrintPreviewUI() override; 41 ~PrintPreviewUI() override;
43 42
44 // Gets the print preview |data|. |index| is zero-based, and can be 43 // Gets the print preview |data|. |index| is zero-based, and can be
45 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to get the entire preview 44 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to get the entire preview
46 // document. 45 // document.
47 void GetPrintPreviewDataForIndex(int index, 46 void GetPrintPreviewDataForIndex(
48 scoped_refptr<base::RefCountedBytes>* data); 47 int index,
48 scoped_refptr<base::RefCountedBytes>* data) const;
49 49
50 // Sets the print preview |data|. |index| is zero-based, and can be 50 // Sets the print preview |data|. |index| is zero-based, and can be
51 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview 51 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview
52 // document. 52 // document.
53 void SetPrintPreviewDataForIndex(int index, 53 void SetPrintPreviewDataForIndex(int index,
54 scoped_refptr<base::RefCountedBytes> data); 54 scoped_refptr<base::RefCountedBytes> data);
55 55
56 // Clear the existing print preview data. 56 // Clear the existing print preview data.
57 void ClearAllPreviewData(); 57 void ClearAllPreviewData();
58 58
59 // Returns the available draft page count. 59 // Returns the available draft page count.
60 int GetAvailableDraftPageCount(); 60 int GetAvailableDraftPageCount() const;
61 61
62 // Setters 62 // Setters
63 void SetInitiatorTitle(const base::string16& initiator_title); 63 void SetInitiatorTitle(const base::string16& initiator_title);
64 64
65 base::string16 initiator_title() { return initiator_title_; } 65 const base::string16& initiator_title() const { return initiator_title_; }
66 66
67 bool source_is_modifiable() { return source_is_modifiable_; } 67 bool source_is_modifiable() const { return source_is_modifiable_; }
68 68
69 bool source_has_selection() { return source_has_selection_; } 69 bool source_has_selection() const { return source_has_selection_; }
70 70
71 bool print_selection_only() { return print_selection_only_; } 71 bool print_selection_only() const { return print_selection_only_; }
72 72
73 // Set initial settings for PrintPreviewUI. 73 // Set initial settings for PrintPreviewUI.
74 static void SetInitialParams( 74 static void SetInitialParams(
75 content::WebContents* print_preview_dialog, 75 content::WebContents* print_preview_dialog,
76 const PrintHostMsg_RequestPrintPreview_Params& params); 76 const PrintHostMsg_RequestPrintPreview_Params& params);
77 77
78 // Determines whether to cancel a print preview request based on 78 // Determines whether to cancel a print preview request based on
79 // |preview_ui_id| and |request_id|. 79 // |preview_ui_id| and |request_id|.
80 // Can be called from any thread. 80 // Can be called from any thread.
81 static void GetCurrentPrintPreviewStatus(int32_t preview_ui_id, 81 static void GetCurrentPrintPreviewStatus(int32_t preview_ui_id,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // the printing without having to click a button on the print preview dialog. 155 // the printing without having to click a button on the print preview dialog.
156 void SetSelectedFileForTesting(const base::FilePath& path); 156 void SetSelectedFileForTesting(const base::FilePath& path);
157 157
158 // Passes |closure| to PrintPreviewHandler::SetPdfSavedClosureForTesting(). 158 // Passes |closure| to PrintPreviewHandler::SetPdfSavedClosureForTesting().
159 void SetPdfSavedClosureForTesting(const base::Closure& closure); 159 void SetPdfSavedClosureForTesting(const base::Closure& closure);
160 160
161 private: 161 private:
162 FRIEND_TEST_ALL_PREFIXES(PrintPreviewDialogControllerUnitTest, 162 FRIEND_TEST_ALL_PREFIXES(PrintPreviewDialogControllerUnitTest,
163 TitleAfterReload); 163 TitleAfterReload);
164 164
165 // Returns the Singleton instance of the PrintPreviewDataService.
166 PrintPreviewDataService* print_preview_data_service();
167
168 base::TimeTicks initial_preview_start_time_; 165 base::TimeTicks initial_preview_start_time_;
169 166
170 // The unique ID for this class instance. Stored here to avoid calling 167 // The unique ID for this class instance. Stored here to avoid calling
171 // GetIDForPrintPreviewUI() everywhere. 168 // GetIDForPrintPreviewUI() everywhere.
172 const int32_t id_; 169 const int32_t id_;
173 170
174 // Weak pointer to the WebUI handler. 171 // Weak pointer to the WebUI handler.
175 PrintPreviewHandler* handler_; 172 PrintPreviewHandler* handler_;
176 173
177 // Indicates whether the source document can be modified. 174 // Indicates whether the source document can be modified.
178 bool source_is_modifiable_; 175 bool source_is_modifiable_;
179 176
180 // Indicates whether the source document has selection. 177 // Indicates whether the source document has selection.
181 bool source_has_selection_; 178 bool source_has_selection_;
182 179
183 // Indicates whether only the selection should be printed. 180 // Indicates whether only the selection should be printed.
184 bool print_selection_only_; 181 bool print_selection_only_;
185 182
186 // Store the initiator title, used for populating the print preview dialog 183 // Store the initiator title, used for populating the print preview dialog
187 // title. 184 // title.
188 base::string16 initiator_title_; 185 base::string16 initiator_title_;
189 186
190 // Keeps track of whether OnClosePrintPreviewDialog() has been called or not. 187 // Keeps track of whether OnClosePrintPreviewDialog() has been called or not.
191 bool dialog_closed_; 188 bool dialog_closed_;
192 189
193 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); 190 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI);
194 }; 191 };
195 192
196 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_ 193 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698