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

Side by Side Diff: chrome/renderer/print_web_view_helper.h

Issue 7747033: Merge 97702, 97820, 97976 (Closed) Base URL: svn://chrome-svn/chrome/branches/835/src/
Patch Set: Created 9 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
« no previous file with comments | « chrome/renderer/mock_render_thread.cc ('k') | chrome/renderer/print_web_view_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void OnPrintForSystemDialog(); 128 void OnPrintForSystemDialog();
129 129
130 // Initiate print preview. 130 // Initiate print preview.
131 void OnInitiatePrintPreview(); 131 void OnInitiatePrintPreview();
132 132
133 // Start the process of generating a print preview using |settings|. 133 // Start the process of generating a print preview using |settings|.
134 void OnPrintPreview(const base::DictionaryValue& settings); 134 void OnPrintPreview(const base::DictionaryValue& settings);
135 // Initialize the print preview document. 135 // Initialize the print preview document.
136 bool CreatePreviewDocument(); 136 bool CreatePreviewDocument();
137 137
138 // Continue generating the print preview. |requested_preview_page_index|
139 // specifies the browser requested preview page index. It is 1-based or
140 // |printing::INVALID_PAGE_INDEX| to continue with next page.
141 void OnContinuePreview(int requested_preview_page_index);
142 // Renders a print preview page. |page_number| is 0-based. 138 // Renders a print preview page. |page_number| is 0-based.
143 void RenderPreviewPage(int page_number); 139 // Returns true if print preview should continue, false on failure.
140 bool RenderPreviewPage(int page_number);
141
144 // Finalize the print preview document. 142 // Finalize the print preview document.
145 bool FinalizePreviewDocument(); 143 bool FinalizePreviewDocument();
146 144
147 // Abort the preview to put |print_preview_context_| into the 'UNINITIALIZED'
148 // state.
149 void OnAbortPreview();
150
151 // Print / preview the node under the context menu. 145 // Print / preview the node under the context menu.
152 void OnPrintNodeUnderContextMenu(); 146 void OnPrintNodeUnderContextMenu();
153 147
154 // Print the pages for print preview. Do not display the native print dialog 148 // Print the pages for print preview. Do not display the native print dialog
155 // for user settings. |job_settings| has new print job settings values. 149 // for user settings. |job_settings| has new print job settings values.
156 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); 150 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
157 151
158 void OnPrintingDone(bool success); 152 void OnPrintingDone(bool success);
159 153
160 // Main printing code ------------------------------------------------------- 154 // Main printing code -------------------------------------------------------
161 155
162 void Print(WebKit::WebFrame* frame, WebKit::WebNode* node); 156 void Print(WebKit::WebFrame* frame, WebKit::WebNode* node);
163 157
164 enum PrintingResult { 158 enum PrintingResult {
165 OK, 159 OK,
166 FAIL_PRINT, 160 FAIL_PRINT,
167 FAIL_PREVIEW, 161 FAIL_PREVIEW,
168 ABORT_PREVIEW,
169 }; 162 };
170 163
171 // Notification when printing is done - signal tear-down/free resources. 164 // Notification when printing is done - signal tear-down/free resources.
172 void DidFinishPrinting(PrintingResult result); 165 void DidFinishPrinting(PrintingResult result);
173 166
174 // Print Settings ----------------------------------------------------------- 167 // Print Settings -----------------------------------------------------------
175 168
176 // Initialize print page settings with default settings. 169 // Initialize print page settings with default settings.
177 bool InitPrintSettings(WebKit::WebFrame* frame, WebKit::WebNode* node); 170 bool InitPrintSettings(WebKit::WebFrame* frame, WebKit::WebNode* node);
178 171
179 // Initialize print page settings with default settings and prepare the frame 172 // Initialize print page settings with default settings and prepare the frame
180 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the 173 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the
181 // request and is filled into the |prepare| argument. 174 // request and is filled into the |prepare| argument.
182 bool InitPrintSettingsAndPrepareFrame( 175 bool InitPrintSettingsAndPrepareFrame(
183 WebKit::WebFrame* frame, 176 WebKit::WebFrame* frame,
184 WebKit::WebNode* node, 177 WebKit::WebNode* node,
185 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); 178 scoped_ptr<PrepareFrameAndViewForPrint>* prepare);
186 179
187 // Parse the request id out of |job_settings| and store it in |params|.
188 // Returns false on failure.
189 bool UpdatePrintSettingsRequestId(const base::DictionaryValue& job_settings,
190 PrintMsg_Print_Params* params);
191
192 // Update the current print settings with new |job_settings|. |job_settings| 180 // Update the current print settings with new |job_settings|. |job_settings|
193 // dictionary contains print job details such as printer name, number of 181 // dictionary contains print job details such as printer name, number of
194 // copies, page range, etc. 182 // copies, page range, etc.
195 bool UpdatePrintSettings(const base::DictionaryValue& job_settings); 183 bool UpdatePrintSettings(const base::DictionaryValue& job_settings,
184 bool is_preview);
196 185
197 // Get final print settings from the user. 186 // Get final print settings from the user.
198 // Return false if the user cancels or on error. 187 // Return false if the user cancels or on error.
199 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, 188 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame,
200 int expected_pages_count, 189 int expected_pages_count,
201 bool use_browser_overlays); 190 bool use_browser_overlays);
202 191
203 // Page Printing / Rendering ------------------------------------------------ 192 // Page Printing / Rendering ------------------------------------------------
204 193
205 // Prints all the pages listed in |params|. 194 // Prints all the pages listed in |params|.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 265
277 // Increment the counter for script initiated printing. 266 // Increment the counter for script initiated printing.
278 // Scripted printing will be blocked for a limited amount of time. 267 // Scripted printing will be blocked for a limited amount of time.
279 void IncrementScriptedPrintCount(); 268 void IncrementScriptedPrintCount();
280 269
281 // Displays the print job error message to the user. 270 // Displays the print job error message to the user.
282 void DisplayPrintJobError(); 271 void DisplayPrintJobError();
283 272
284 void RequestPrintPreview(); 273 void RequestPrintPreview();
285 274
286 // Notify the browser a print preview page has been rendered. 275 // Checks whether print preview should continue or not.
287 // |page_number| is 0-based or |printing::INVALID_PAGE_INDEX| to check 276 // Returns true if cancelling, false if continuing.
288 // for pending preview requests. 277 bool CheckForCancel();
289 void PreviewPageRendered(int page_number, printing::Metafile* metafile); 278
279 // Notifies the browser a print preview page has been rendered.
280 // |page_number| is 0-based.
281 // For a valid |page_number| with modifiable content,
282 // |metafile| is the rendered page. Otherwise |metafile| is NULL.
283 // Returns true if print preview should continue, false on failure.
284 bool PreviewPageRendered(int page_number, printing::Metafile* metafile);
290 285
291 WebKit::WebView* print_web_view_; 286 WebKit::WebView* print_web_view_;
292 287
293 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 288 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
294 bool is_preview_; 289 bool is_preview_;
295 290
296 // Used for scripted initiated printing blocking. 291 // Used for scripted initiated printing blocking.
297 base::Time last_cancelled_script_print_; 292 base::Time last_cancelled_script_print_;
298 int user_cancelled_scripted_print_count_; 293 int user_cancelled_scripted_print_count_;
299 294
(...skipping 27 matching lines...) Expand all
327 322
328 // Finalizes the print preview document. 323 // Finalizes the print preview document.
329 void FinalizePreviewDocument(); 324 void FinalizePreviewDocument();
330 325
331 // Cleanup after print preview finishes. 326 // Cleanup after print preview finishes.
332 void Finished(); 327 void Finished();
333 328
334 // Cleanup after print preview fails. 329 // Cleanup after print preview fails.
335 void Failed(); 330 void Failed();
336 331
337 // Abort the print preview.
338 void Abort();
339
340 // Helper functions 332 // Helper functions
341 int GetNextPageNumber(); 333 int GetNextPageNumber();
342 bool IsReadyToRender() const; 334 bool IsReadyToRender() const;
343 bool IsBusy() const;
344 bool IsModifiable() const; 335 bool IsModifiable() const;
345 336
346 // Getters 337 // Getters
347 WebKit::WebFrame* frame() const; 338 WebKit::WebFrame* frame() const;
348 WebKit::WebNode* node() const; 339 WebKit::WebNode* node() const;
349 int total_page_count() const; 340 int total_page_count() const;
350 printing::Metafile* metafile() const; 341 printing::Metafile* metafile() const;
351 const PrintMsg_Print_Params& print_params() const; 342 const PrintMsg_Print_Params& print_params() const;
352 const gfx::Size& GetPrintCanvasSize() const; 343 const gfx::Size& GetPrintCanvasSize() const;
353 344
(...skipping 16 matching lines...) Expand all
370 scoped_ptr<printing::Metafile> metafile_; 361 scoped_ptr<printing::Metafile> metafile_;
371 scoped_ptr<PrintMsg_Print_Params> print_params_; 362 scoped_ptr<PrintMsg_Print_Params> print_params_;
372 363
373 // Total page count in the renderer. 364 // Total page count in the renderer.
374 int total_page_count_; 365 int total_page_count_;
375 366
376 // Number of pages to render. 367 // Number of pages to render.
377 int actual_page_count_; 368 int actual_page_count_;
378 369
379 // The current page to render. 370 // The current page to render.
380 int current_page_number_; 371 int current_page_index_;
381 372
382 // |rendered_pages_| tracks which pages need to be printed as well as 373 std::vector<int> pages_to_render_;
383 // the page slot it should be printed in. See GetPageSlotForPage.
384 typedef std::pair<bool, int> PreviewPageInfo;
385 std::vector<PreviewPageInfo> rendered_pages_;
386 374
387 base::TimeDelta document_render_time_; 375 base::TimeDelta document_render_time_;
388 base::TimeTicks begin_time_; 376 base::TimeTicks begin_time_;
389 377
390 State state_; 378 State state_;
391 }; 379 };
392 380
393 PrintPreviewContext print_preview_context_; 381 PrintPreviewContext print_preview_context_;
394 382
395 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 383 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
396 }; 384 };
397 385
398 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 386 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/mock_render_thread.cc ('k') | chrome/renderer/print_web_view_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698