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

Side by Side Diff: chrome/browser/ui/webui/print_preview_handler.h

Issue 8564040: Revert 110035 - Print Preview: Making margin selection sticky (part 2/2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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) 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_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_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/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/shell_dialogs.h" 16 #include "chrome/browser/ui/shell_dialogs.h"
17 #include "content/browser/webui/web_ui.h" 17 #include "content/browser/webui/web_ui.h"
18 #include "printing/print_job_constants.h" 18 #include "printing/print_job_constants.h"
19 19
20 class FilePath; 20 class FilePath;
21 class PrintSystemTaskProxy; 21 class PrintSystemTaskProxy;
22 class TabContentsWrapper; 22 class TabContentsWrapper;
23 23
24 namespace base { 24 namespace base {
25 class DictionaryValue; 25 class DictionaryValue;
26 class StringValue; 26 class StringValue;
27 } 27 }
28 28
29 namespace printing { 29 namespace printing {
30 struct PageSizeMargins;
31 class PrintBackend; 30 class PrintBackend;
32 } 31 }
33 32
34 // The handler for Javascript messages related to the print preview dialog. 33 // The handler for Javascript messages related to the print preview dialog.
35 class PrintPreviewHandler : public WebUIMessageHandler, 34 class PrintPreviewHandler : public WebUIMessageHandler,
36 public base::SupportsWeakPtr<PrintPreviewHandler>, 35 public base::SupportsWeakPtr<PrintPreviewHandler>,
37 public SelectFileDialog::Listener, 36 public SelectFileDialog::Listener,
38 public printing::PrintViewManagerObserver { 37 public printing::PrintViewManagerObserver {
39 public: 38 public:
40 PrintPreviewHandler(); 39 PrintPreviewHandler();
(...skipping 20 matching lines...) Expand all
61 void OnTabDestroyed(); 60 void OnTabDestroyed();
62 61
63 // Called when print preview failed. 62 // Called when print preview failed.
64 void OnPrintPreviewFailed(); 63 void OnPrintPreviewFailed();
65 64
66 // Called when the user press ctrl+shift+p to display the native system 65 // Called when the user press ctrl+shift+p to display the native system
67 // dialog. 66 // dialog.
68 void ShowSystemDialog(); 67 void ShowSystemDialog();
69 68
70 private: 69 private:
71 friend class PrintPreviewHandlerTest;
72 friend class PrintSystemTaskProxy; 70 friend class PrintSystemTaskProxy;
73 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsCustom);
74 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, StickyMarginsDefault);
75 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest,
76 StickyMarginsCustomThenDefault);
77 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest,
78 GetLastUsedMarginSettingsCustom);
79 FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest,
80 GetLastUsedMarginSettingsDefault);
81 71
82 TabContentsWrapper* preview_tab_wrapper() const; 72 TabContentsWrapper* preview_tab_wrapper() const;
83 TabContents* preview_tab() const; 73 TabContents* preview_tab() const;
84 74
75 // Gets the default printer. |args| is unused.
76 void HandleGetDefaultPrinter(const base::ListValue* args);
77
85 // Gets the list of printers. |args| is unused. 78 // Gets the list of printers. |args| is unused.
86 void HandleGetPrinters(const base::ListValue* args); 79 void HandleGetPrinters(const base::ListValue* args);
87 80
88 // Asks the initiator renderer to generate a preview. First element of |args| 81 // Asks the initiator renderer to generate a preview. First element of |args|
89 // is a job settings JSON string. 82 // is a job settings JSON string.
90 void HandleGetPreview(const base::ListValue* args); 83 void HandleGetPreview(const base::ListValue* args);
91 84
92 // Gets the job settings from Web UI and initiate printing. First element of 85 // Gets the job settings from Web UI and initiate printing. First element of
93 // |args| is a job settings JSON string. 86 // |args| is a job settings JSON string.
94 void HandlePrint(const base::ListValue* args); 87 void HandlePrint(const base::ListValue* args);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Asks the browser to show the native printer management dialog. 124 // Asks the browser to show the native printer management dialog.
132 // |args| is unused. 125 // |args| is unused.
133 void HandleManagePrinters(const base::ListValue* args); 126 void HandleManagePrinters(const base::ListValue* args);
134 127
135 // Asks the browser to show the cloud print dialog. 128 // Asks the browser to show the cloud print dialog.
136 void HandlePrintWithCloudPrint(); 129 void HandlePrintWithCloudPrint();
137 130
138 // Asks the browser to close the preview tab. |args| is unused. 131 // Asks the browser to close the preview tab. |args| is unused.
139 void HandleClosePreviewTab(const base::ListValue* args); 132 void HandleClosePreviewTab(const base::ListValue* args);
140 133
141 // Asks the browser for several settings that are needed before the first 134 // Asks the browser for the title of the initiator tab.
142 // preview is displayed. 135 // |args| is unused.
143 void HandleGetInitialSettings(const base::ListValue* args); 136 void HandleGetInitiatorTabTitle(const base::ListValue* args);
144 137
145 void SendInitialSettings( 138 // Asks the browser for the number formatting and measurement system according
146 const std::string& default_printer, 139 // to the current locale.
147 const std::string& cloud_print_data); 140 void HandleGetNumberFormatAndMeasurementSystem(const base::ListValue* args);
148 141
149 // Sends the printer capabilities to the Web UI. |settings_info| contains 142 // Sends the printer capabilities to the Web UI. |settings_info| contains
150 // printer capabilities information. 143 // printer capabilities information.
151 void SendPrinterCapabilities(const base::DictionaryValue& settings_info); 144 void SendPrinterCapabilities(const base::DictionaryValue& settings_info);
152 145
146 // Sends the default printer to the Web UI.
147 void SendDefaultPrinter(const base::StringValue& default_printer,
148 const base::StringValue& cloud_print_data);
149
153 // Send the list of printers to the Web UI. 150 // Send the list of printers to the Web UI.
154 void SetupPrinterList(const base::ListValue& printers); 151 void SetupPrinterList(const base::ListValue& printers);
155 152
156 // Send whether cloud print integration should be enabled. 153 // Send whether cloud print integration should be enabled.
157 void SendCloudPrintEnabled(); 154 void SendCloudPrintEnabled();
158 155
159 // Send the PDF data to the cloud to print. 156 // Send the PDF data to the cloud to print.
160 void SendCloudPrintJob(const base::DictionaryValue& settings, 157 void SendCloudPrintJob(const base::DictionaryValue& settings,
161 std::string print_ticket); 158 std::string print_ticket);
162 159
(...skipping 11 matching lines...) Expand all
174 171
175 // Hides the preview tab for printing. 172 // Hides the preview tab for printing.
176 void HidePreviewTab(); 173 void HidePreviewTab();
177 174
178 // Clears initiator tab details for this preview tab. 175 // Clears initiator tab details for this preview tab.
179 void ClearInitiatorTabDetails(); 176 void ClearInitiatorTabDetails();
180 177
181 // Posts a task to save to pdf at |print_to_pdf_path_|. 178 // Posts a task to save to pdf at |print_to_pdf_path_|.
182 void PostPrintToPdfTask(); 179 void PostPrintToPdfTask();
183 180
184 // Populates |settings| according to the current locale.
185 void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings);
186
187 // Populates |last_used_custom_margins| according to the last used margin
188 // settings.
189 void GetLastUsedMarginSettings(
190 base::DictionaryValue* last_used_custom_margins);
191
192 // Pointer to current print system. 181 // Pointer to current print system.
193 scoped_refptr<printing::PrintBackend> print_backend_; 182 scoped_refptr<printing::PrintBackend> print_backend_;
194 183
195 // The underlying dialog object. 184 // The underlying dialog object.
196 scoped_refptr<SelectFileDialog> select_file_dialog_; 185 scoped_refptr<SelectFileDialog> select_file_dialog_;
197 186
198 static FilePath* last_saved_path_; 187 static FilePath* last_saved_path_;
199 static std::string* last_used_printer_cloud_print_data_; 188 static std::string* last_used_printer_cloud_print_data_;
200 static std::string* last_used_printer_name_; 189 static std::string* last_used_printer_name_;
201 static printing::ColorModels last_used_color_model_; 190 static printing::ColorModels last_used_color_model_;
202 static printing::MarginType last_used_margins_type_; 191 static printing::MarginType last_used_margins_type_;
203 static printing::PageSizeMargins* last_used_page_size_margins_;
204 192
205 // A count of how many requests received to regenerate preview data. 193 // A count of how many requests received to regenerate preview data.
206 // Initialized to 0 then incremented and emitted to a histogram. 194 // Initialized to 0 then incremented and emitted to a histogram.
207 int regenerate_preview_request_count_; 195 int regenerate_preview_request_count_;
208 196
209 // A count of how many requests received to show manage printers dialog. 197 // A count of how many requests received to show manage printers dialog.
210 int manage_printers_dialog_request_count_; 198 int manage_printers_dialog_request_count_;
211 199
212 // Whether we have already logged a failed print preview. 200 // Whether we have already logged a failed print preview.
213 bool reported_failed_preview_; 201 bool reported_failed_preview_;
214 202
215 // Whether we have already logged the number of printers this session. 203 // Whether we have already logged the number of printers this session.
216 bool has_logged_printers_count_; 204 bool has_logged_printers_count_;
217 205
218 // Holds the path to the print to pdf request. It is empty if no such request 206 // Holds the path to the print to pdf request. It is empty if no such request
219 // exists. 207 // exists.
220 scoped_ptr<FilePath> print_to_pdf_path_; 208 scoped_ptr<FilePath> print_to_pdf_path_;
221 209
222 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); 210 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler);
223 }; 211 };
224 212
225 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_ 213 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | chrome/browser/ui/webui/print_preview_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698