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

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

Issue 10873097: Merge 153342 - Print preview: Use an ID instead of memory pointer string in WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1229/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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 <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.h" 12 #include "base/time.h"
13 #include "chrome/browser/printing/print_preview_data_service.h"
14 #include "ui/web_dialogs/constrained_web_dialog_ui.h" 13 #include "ui/web_dialogs/constrained_web_dialog_ui.h"
15 14
16 class PrintPreviewDataService; 15 class PrintPreviewDataService;
17 class PrintPreviewHandler; 16 class PrintPreviewHandler;
18 struct PrintHostMsg_DidGetPreviewPageCount_Params; 17 struct PrintHostMsg_DidGetPreviewPageCount_Params;
19 18
20 namespace base { 19 namespace base {
21 class RefCountedBytes; 20 class RefCountedBytes;
22 } 21 }
23 22
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 57
59 string16 initiator_tab_title() { return initiator_tab_title_; } 58 string16 initiator_tab_title() { return initiator_tab_title_; }
60 59
61 bool source_is_modifiable() { return source_is_modifiable_; } 60 bool source_is_modifiable() { return source_is_modifiable_; }
62 61
63 // Set |source_is_modifiable_| for |print_preview_tab|'s PrintPreviewUI. 62 // Set |source_is_modifiable_| for |print_preview_tab|'s PrintPreviewUI.
64 static void SetSourceIsModifiable(TabContents* print_preview_tab, 63 static void SetSourceIsModifiable(TabContents* print_preview_tab,
65 bool source_is_modifiable); 64 bool source_is_modifiable);
66 65
67 // Determines whether to cancel a print preview request based on 66 // Determines whether to cancel a print preview request based on
68 // |preview_ui_addr| and |request_id|. 67 // |preview_ui_id| and |request_id|.
69 // Can be called from any thread. 68 // Can be called from any thread.
70 static void GetCurrentPrintPreviewStatus(const std::string& preview_ui_addr, 69 static void GetCurrentPrintPreviewStatus(int32 preview_ui_id,
71 int request_id, 70 int request_id,
72 bool* cancel); 71 bool* cancel);
73 72
74 // Returns a string to uniquely identify this PrintPreviewUI. 73 // Returns an id to uniquely identify this PrintPreviewUI.
75 std::string GetPrintPreviewUIAddress() const; 74 int32 GetIDForPrintPreviewUI() const;
76 75
77 // Notifies the Web UI of a print preview request with |request_id|. 76 // Notifies the Web UI of a print preview request with |request_id|.
78 void OnPrintPreviewRequest(int request_id); 77 void OnPrintPreviewRequest(int request_id);
79 78
80 // Notifies the Web UI to show the system dialog. 79 // Notifies the Web UI to show the system dialog.
81 void OnShowSystemDialog(); 80 void OnShowSystemDialog();
82 81
83 // Notifies the Web UI about the page count of the request preview. 82 // Notifies the Web UI about the page count of the request preview.
84 void OnDidGetPreviewPageCount( 83 void OnDidGetPreviewPageCount(
85 const PrintHostMsg_DidGetPreviewPageCount_Params& params); 84 const PrintHostMsg_DidGetPreviewPageCount_Params& params);
86 85
87 // Notifies the Web UI of the default page layout according to the currently 86 // Notifies the Web UI of the default page layout according to the currently
88 // selected printer and page size. 87 // selected printer and page size.
89 void OnDidGetDefaultPageLayout( 88 void OnDidGetDefaultPageLayout(const printing::PageSizeMargins& page_layout,
90 const printing::PageSizeMargins& page_layout, 89 const gfx::Rect& printable_area,
91 const gfx::Rect& printable_area, 90 bool has_custom_page_size_style);
92 bool has_custom_page_size_style);
93 91
94 // Notifies the Web UI that the 0-based page |page_number| has been rendered. 92 // Notifies the Web UI that the 0-based page |page_number| has been rendered.
95 // |preview_request_id| indicates wich request resulted in this response. 93 // |preview_request_id| indicates wich request resulted in this response.
96 void OnDidPreviewPage(int page_number, int preview_request_id); 94 void OnDidPreviewPage(int page_number, int preview_request_id);
97 95
98 // Notifies the Web UI renderer that preview data is available. 96 // Notifies the Web UI renderer that preview data is available.
99 // |expected_pages_count| specifies the total number of pages. 97 // |expected_pages_count| specifies the total number of pages.
100 // |preview_request_id| indicates which request resulted in this response. 98 // |preview_request_id| indicates which request resulted in this response.
101 void OnPreviewDataIsAvailable(int expected_pages_count, 99 void OnPreviewDataIsAvailable(int expected_pages_count,
102 int preview_request_id); 100 int preview_request_id);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, 152 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest,
155 GetLastUsedMarginSettingsDefault); 153 GetLastUsedMarginSettingsDefault);
156 FRIEND_TEST_ALL_PREFIXES(PrintPreviewTabControllerUnitTest, 154 FRIEND_TEST_ALL_PREFIXES(PrintPreviewTabControllerUnitTest,
157 TitleAfterReload); 155 TitleAfterReload);
158 156
159 // Returns the Singleton instance of the PrintPreviewDataService. 157 // Returns the Singleton instance of the PrintPreviewDataService.
160 PrintPreviewDataService* print_preview_data_service(); 158 PrintPreviewDataService* print_preview_data_service();
161 159
162 base::TimeTicks initial_preview_start_time_; 160 base::TimeTicks initial_preview_start_time_;
163 161
164 // Store the PrintPreviewUI address string. 162 // The unique ID for this class instance. Stored here to avoid calling
165 std::string preview_ui_addr_str_; 163 // GetIDForPrintPreviewUI() everywhere.
164 const int32 id_;
166 165
167 // Weak pointer to the WebUI handler. 166 // Weak pointer to the WebUI handler.
168 PrintPreviewHandler* handler_; 167 PrintPreviewHandler* handler_;
169 168
170 // Store the |initiator_url| in order to display an accurate error message 169 // Store the |initiator_url| in order to display an accurate error message
171 // when the initiator tab is closed/crashed. 170 // when the initiator tab is closed/crashed.
172 std::string initiator_url_; 171 std::string initiator_url_;
173 172
174 // Indicates whether the source document can be modified. 173 // Indicates whether the source document can be modified.
175 bool source_is_modifiable_; 174 bool source_is_modifiable_;
176 175
177 // Store the initiator tab title, used for populating the print preview tab 176 // Store the initiator tab title, used for populating the print preview tab
178 // title. 177 // title.
179 string16 initiator_tab_title_; 178 string16 initiator_tab_title_;
180 179
181 // Keeps track of whether OnClosePrintPreviewTab() has been called or not. 180 // Keeps track of whether OnClosePrintPreviewTab() has been called or not.
182 bool tab_closed_; 181 bool tab_closed_;
183 182
184 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); 183 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI);
185 }; 184 };
186 185
187 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_ 186 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698