OLD | NEW |
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_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 5 #ifndef CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 bool GetPrintFrame(blink::WebLocalFrame** frame); | 287 bool GetPrintFrame(blink::WebLocalFrame** frame); |
288 | 288 |
289 // Script Initiated Printing ------------------------------------------------ | 289 // Script Initiated Printing ------------------------------------------------ |
290 | 290 |
291 // Return true if script initiated printing is currently | 291 // Return true if script initiated printing is currently |
292 // allowed. |user_initiated| should be true when a user event triggered the | 292 // allowed. |user_initiated| should be true when a user event triggered the |
293 // script, most likely by pressing a print button on the page. | 293 // script, most likely by pressing a print button on the page. |
294 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, | 294 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, |
295 bool user_initiated); | 295 bool user_initiated); |
296 | 296 |
297 // Returns true if script initiated printing occurs too often. | 297 // Shows scripted print preview when options from plugin are available. |
298 bool IsScriptInitiatedPrintTooFrequent(blink::WebFrame* frame); | |
299 | |
300 // Reset the counter for script initiated printing. | |
301 // Scripted printing will be allowed to continue. | |
302 void ResetScriptedPrintCount(); | |
303 | |
304 // Increment the counter for script initiated printing. | |
305 // Scripted printing will be blocked for a limited amount of time. | |
306 void IncrementScriptedPrintCount(); | |
307 | |
308 // Shows scripted print preview when options from plugin are availible. | |
309 void ShowScriptedPrintPreview(); | 298 void ShowScriptedPrintPreview(); |
310 | 299 |
311 void RequestPrintPreview(PrintPreviewRequestType type); | 300 void RequestPrintPreview(PrintPreviewRequestType type); |
312 | 301 |
313 // Checks whether print preview should continue or not. | 302 // Checks whether print preview should continue or not. |
314 // Returns true if cancelling, false if continuing. | 303 // Returns true if canceling, false if continuing. |
315 bool CheckForCancel(); | 304 bool CheckForCancel(); |
316 | 305 |
317 // Notifies the browser a print preview page has been rendered. | 306 // Notifies the browser a print preview page has been rendered. |
318 // |page_number| is 0-based. | 307 // |page_number| is 0-based. |
319 // For a valid |page_number| with modifiable content, | 308 // For a valid |page_number| with modifiable content, |
320 // |metafile| is the rendered page. Otherwise |metafile| is NULL. | 309 // |metafile| is the rendered page. Otherwise |metafile| is NULL. |
321 // Returns true if print preview should continue, false on failure. | 310 // Returns true if print preview should continue, false on failure. |
322 bool PreviewPageRendered(int page_number, Metafile* metafile); | 311 bool PreviewPageRendered(int page_number, Metafile* metafile); |
323 | 312 |
324 void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings); | 313 void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings); |
325 | 314 |
326 // WebView used only to print the selection. | 315 // WebView used only to print the selection. |
327 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 316 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
328 bool reset_prep_frame_view_; | 317 bool reset_prep_frame_view_; |
329 | 318 |
330 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; | 319 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; |
331 bool is_preview_enabled_; | |
332 bool is_scripted_print_throttling_disabled_; | |
333 bool is_print_ready_metafile_sent_; | 320 bool is_print_ready_metafile_sent_; |
334 bool ignore_css_margins_; | 321 bool ignore_css_margins_; |
335 | |
336 // Used for scripted initiated printing blocking. | 322 // Used for scripted initiated printing blocking. |
337 base::Time last_cancelled_script_print_; | |
338 int user_cancelled_scripted_print_count_; | |
339 bool is_scripted_printing_blocked_; | 323 bool is_scripted_printing_blocked_; |
340 | 324 |
341 // Let the browser process know of a printing failure. Only set to false when | 325 // Let the browser process know of a printing failure. Only set to false when |
342 // the failure came from the browser in the first place. | 326 // the failure came from the browser in the first place. |
343 bool notify_browser_of_print_failure_; | 327 bool notify_browser_of_print_failure_; |
344 | 328 |
345 // True, when printing from print preview. | 329 // True, when printing from print preview. |
346 bool print_for_preview_; | 330 bool print_for_preview_; |
347 | 331 |
348 // Strings generated by the browser process to be printed as headers and | 332 // Strings generated by the browser process to be printed as headers and |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // hangs because RequestPrintPreview is called before DidStopLoading() is | 452 // hangs because RequestPrintPreview is called before DidStopLoading() is |
469 // called. This is a store for the RequestPrintPreview() call and its | 453 // called. This is a store for the RequestPrintPreview() call and its |
470 // parameters so that it can be invoked after DidStopLoading. | 454 // parameters so that it can be invoked after DidStopLoading. |
471 base::Closure on_stop_loading_closure_; | 455 base::Closure on_stop_loading_closure_; |
472 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 456 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
473 }; | 457 }; |
474 | 458 |
475 } // namespace printing | 459 } // namespace printing |
476 | 460 |
477 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 461 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |