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

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

Issue 7621087: Print Preview: Go from event driven print preview back to print preview with sync messages. The s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove requested_page Created 9 years, 4 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) 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void OnPrintForSystemDialog(); 134 void OnPrintForSystemDialog();
135 135
136 // Initiate print preview. 136 // Initiate print preview.
137 void OnInitiatePrintPreview(); 137 void OnInitiatePrintPreview();
138 138
139 // Start the process of generating a print preview using |settings|. 139 // Start the process of generating a print preview using |settings|.
140 void OnPrintPreview(const base::DictionaryValue& settings); 140 void OnPrintPreview(const base::DictionaryValue& settings);
141 // Initialize the print preview document. 141 // Initialize the print preview document.
142 bool CreatePreviewDocument(); 142 bool CreatePreviewDocument();
143 143
144 // Continue generating the print preview. |requested_preview_page_index|
145 // specifies the browser requested preview page index. It is 1-based or
146 // |printing::INVALID_PAGE_INDEX| to continue with next page.
147 void OnContinuePreview(int requested_preview_page_index);
148 // Renders a print preview page. |page_number| is 0-based. 144 // Renders a print preview page. |page_number| is 0-based.
149 void RenderPreviewPage(int page_number); 145 // Returns true if print preview should continue, false on
146 // cancellation / failure.
147 bool RenderPreviewPage(int page_number);
148
150 // Finalize the print preview document. 149 // Finalize the print preview document.
151 bool FinalizePreviewDocument(); 150 bool FinalizePreviewDocument();
152 151
153 // Abort the preview to put |print_preview_context_| into the 'UNINITIALIZED'
154 // state.
155 void OnAbortPreview();
156
157 // Print / preview the node under the context menu. 152 // Print / preview the node under the context menu.
158 void OnPrintNodeUnderContextMenu(); 153 void OnPrintNodeUnderContextMenu();
159 154
160 // Print the pages for print preview. Do not display the native print dialog 155 // Print the pages for print preview. Do not display the native print dialog
161 // for user settings. |job_settings| has new print job settings values. 156 // for user settings. |job_settings| has new print job settings values.
162 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); 157 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
163 158
164 void OnPrintingDone(bool success); 159 void OnPrintingDone(bool success);
165 160
166 // Main printing code ------------------------------------------------------- 161 // Main printing code -------------------------------------------------------
167 162
168 void Print(WebKit::WebFrame* frame, WebKit::WebNode* node); 163 void Print(WebKit::WebFrame* frame, WebKit::WebNode* node);
169 164
170 enum PrintingResult { 165 enum PrintingResult {
171 OK, 166 OK,
172 FAIL_PRINT, 167 FAIL_PRINT,
173 FAIL_PREVIEW, 168 FAIL_PREVIEW,
174 ABORT_PREVIEW,
175 }; 169 };
176 170
177 // Notification when printing is done - signal tear-down/free resources. 171 // Notification when printing is done - signal tear-down/free resources.
178 void DidFinishPrinting(PrintingResult result); 172 void DidFinishPrinting(PrintingResult result);
179 173
180 // Print Settings ----------------------------------------------------------- 174 // Print Settings -----------------------------------------------------------
181 175
182 // Initialize print page settings with default settings. 176 // Initialize print page settings with default settings.
183 bool InitPrintSettings(WebKit::WebFrame* frame, WebKit::WebNode* node); 177 bool InitPrintSettings(WebKit::WebFrame* frame, WebKit::WebNode* node);
184 178
185 // Initialize print page settings with default settings and prepare the frame 179 // Initialize print page settings with default settings and prepare the frame
186 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the 180 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the
187 // request and is filled into the |prepare| argument. 181 // request and is filled into the |prepare| argument.
188 bool InitPrintSettingsAndPrepareFrame( 182 bool InitPrintSettingsAndPrepareFrame(
189 WebKit::WebFrame* frame, 183 WebKit::WebFrame* frame,
190 WebKit::WebNode* node, 184 WebKit::WebNode* node,
191 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); 185 scoped_ptr<PrepareFrameAndViewForPrint>* prepare);
192 186
193 // Parse the request id out of |job_settings| and store it in |params|.
194 // Returns false on failure.
195 bool UpdatePrintSettingsRequestId(const base::DictionaryValue& job_settings,
196 PrintMsg_Print_Params* params);
197
198 // Update the current print settings with new |job_settings|. |job_settings| 187 // Update the current print settings with new |job_settings|. |job_settings|
199 // dictionary contains print job details such as printer name, number of 188 // dictionary contains print job details such as printer name, number of
200 // copies, page range, etc. 189 // copies, page range, etc.
201 bool UpdatePrintSettings(const base::DictionaryValue& job_settings); 190 bool UpdatePrintSettings(const base::DictionaryValue& job_settings);
202 191
203 // Get final print settings from the user. 192 // Get final print settings from the user.
204 // Return false if the user cancels or on error. 193 // Return false if the user cancels or on error.
205 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, 194 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame,
206 int expected_pages_count, 195 int expected_pages_count,
207 bool use_browser_overlays); 196 bool use_browser_overlays);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 289
301 // Increment the counter for script initiated printing. 290 // Increment the counter for script initiated printing.
302 // Scripted printing will be blocked for a limited amount of time. 291 // Scripted printing will be blocked for a limited amount of time.
303 void IncrementScriptedPrintCount(); 292 void IncrementScriptedPrintCount();
304 293
305 // Displays the print job error message to the user. 294 // Displays the print job error message to the user.
306 void DisplayPrintJobError(); 295 void DisplayPrintJobError();
307 296
308 void RequestPrintPreview(); 297 void RequestPrintPreview();
309 298
310 // Notify the browser a print preview page has been rendered. 299 // Notifies the browser a print preview page has been rendered.
311 // |page_number| is 0-based or |printing::INVALID_PAGE_INDEX| to check 300 // |page_number| is 0-based or |printing::INVALID_PAGE_INDEX| to check
312 // for pending preview requests. 301 // for pending preview requests.
313 void PreviewPageRendered(int page_number, printing::Metafile* metafile); 302 // For a valid |page_number|, |metafile| is the rendered page.
kmadhusu 2011/08/19 19:51:03 For a valid |page_number|, If the initiator is mod
Lei Zhang 2011/08/19 22:50:28 Done.
303 // Returns true if print preview should continue, false on
304 // cancellation / failure.
305 bool PreviewPageRendered(int page_number, printing::Metafile* metafile);
314 306
315 WebKit::WebView* print_web_view_; 307 WebKit::WebView* print_web_view_;
316 308
317 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 309 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
318 bool is_preview_; 310 bool is_preview_;
319 311
320 // Used for scripted initiated printing blocking. 312 // Used for scripted initiated printing blocking.
321 base::Time last_cancelled_script_print_; 313 base::Time last_cancelled_script_print_;
322 int user_cancelled_scripted_print_count_; 314 int user_cancelled_scripted_print_count_;
323 315
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 347
356 // Finalizes the print preview document. 348 // Finalizes the print preview document.
357 void FinalizePreviewDocument(); 349 void FinalizePreviewDocument();
358 350
359 // Cleanup after print preview finishes. 351 // Cleanup after print preview finishes.
360 void Finished(); 352 void Finished();
361 353
362 // Cleanup after print preview fails. 354 // Cleanup after print preview fails.
363 void Failed(); 355 void Failed();
364 356
365 // Abort the print preview.
366 void Abort();
367
368 // Helper functions 357 // Helper functions
369 int GetNextPageNumber(); 358 int GetNextPageNumber();
370 bool IsReadyToRender() const; 359 bool IsReadyToRender() const;
371 bool IsBusy() const;
372 bool IsModifiable() const; 360 bool IsModifiable() const;
373 361
374 // Getters 362 // Getters
375 WebKit::WebFrame* frame() const; 363 WebKit::WebFrame* frame() const;
376 WebKit::WebNode* node() const; 364 WebKit::WebNode* node() const;
377 int total_page_count() const; 365 int total_page_count() const;
378 printing::PreviewMetafile* metafile() const; 366 printing::PreviewMetafile* metafile() const;
379 const PrintMsg_Print_Params& print_params() const; 367 const PrintMsg_Print_Params& print_params() const;
380 const gfx::Size& GetPrintCanvasSize() const; 368 const gfx::Size& GetPrintCanvasSize() const;
381 369
(...skipping 16 matching lines...) Expand all
398 scoped_ptr<printing::PreviewMetafile> metafile_; 386 scoped_ptr<printing::PreviewMetafile> metafile_;
399 scoped_ptr<PrintMsg_Print_Params> print_params_; 387 scoped_ptr<PrintMsg_Print_Params> print_params_;
400 388
401 // Total page count in the renderer. 389 // Total page count in the renderer.
402 int total_page_count_; 390 int total_page_count_;
403 391
404 // Number of pages to render. 392 // Number of pages to render.
405 int actual_page_count_; 393 int actual_page_count_;
406 394
407 // The current page to render. 395 // The current page to render.
408 int current_page_number_; 396 int current_page_index_;
409 397
410 // |rendered_pages_| tracks which pages need to be printed as well as 398 std::vector<int> pages_to_render_;
411 // the page slot it should be printed in. See GetPageSlotForPage.
412 typedef std::pair<bool, int> PreviewPageInfo;
413 std::vector<PreviewPageInfo> rendered_pages_;
414 399
415 base::TimeDelta document_render_time_; 400 base::TimeDelta document_render_time_;
416 base::TimeTicks begin_time_; 401 base::TimeTicks begin_time_;
417 402
418 State state_; 403 State state_;
419 }; 404 };
420 405
421 PrintPreviewContext print_preview_context_; 406 PrintPreviewContext print_preview_context_;
422 407
423 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 408 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
424 }; 409 };
425 410
426 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 411 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698