| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
| 22 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 23 | 23 |
| 24 struct PrintMsg_Print_Params; | 24 struct PrintMsg_Print_Params; |
| 25 struct PrintMsg_PrintPage_Params; | 25 struct PrintMsg_PrintPage_Params; |
| 26 struct PrintMsg_PrintPages_Params; | 26 struct PrintMsg_PrintPages_Params; |
| 27 | 27 |
| 28 namespace base { | 28 namespace base { |
| 29 class DictionaryValue; | 29 class DictionaryValue; |
| 30 } | 30 } |
| 31 #if defined(USE_SKIA) | |
| 32 namespace skia { | |
| 33 class VectorCanvas; | |
| 34 } | |
| 35 #endif | |
| 36 | 31 |
| 37 // Class that calls the Begin and End print functions on the frame and changes | 32 // Class that calls the Begin and End print functions on the frame and changes |
| 38 // the size of the view temporarily to support full page printing.. | 33 // the size of the view temporarily to support full page printing.. |
| 39 // Do not serve any events in the time between construction and destruction of | 34 // Do not serve any events in the time between construction and destruction of |
| 40 // this class because it will cause flicker. | 35 // this class because it will cause flicker. |
| 41 class PrepareFrameAndViewForPrint { | 36 class PrepareFrameAndViewForPrint { |
| 42 public: | 37 public: |
| 43 // Prints |frame|. If |node| is not NULL, then only that node will be | 38 // Prints |frame|. If |node| is not NULL, then only that node will be |
| 44 // printed. | 39 // printed. |
| 45 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& print_params, | 40 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& print_params, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 int page_index, | 259 int page_index, |
| 265 const PrintMsg_Print_Params& default_params, | 260 const PrintMsg_Print_Params& default_params, |
| 266 PageSizeMargins* page_layout_in_points); | 261 PageSizeMargins* page_layout_in_points); |
| 267 | 262 |
| 268 static void UpdatePrintableSizeInPrintParameters( | 263 static void UpdatePrintableSizeInPrintParameters( |
| 269 WebKit::WebFrame* frame, | 264 WebKit::WebFrame* frame, |
| 270 WebKit::WebNode* node, | 265 WebKit::WebNode* node, |
| 271 PrepareFrameAndViewForPrint* prepare, | 266 PrepareFrameAndViewForPrint* prepare, |
| 272 PrintMsg_Print_Params* params); | 267 PrintMsg_Print_Params* params); |
| 273 | 268 |
| 274 #if defined(USE_SKIA) | |
| 275 // Given the |device| and |canvas| to draw on, prints the appropriate headers | |
| 276 // and footers using strings from |header_footer_info| on to the canvas. | |
| 277 static void PrintHeaderAndFooter( | |
| 278 SkDevice* device, | |
| 279 skia::VectorCanvas* canvas, | |
| 280 int page_number, | |
| 281 int total_pages, | |
| 282 float webkit_scale_factor, | |
| 283 const PageSizeMargins& page_layout_in_points, | |
| 284 const base::DictionaryValue& header_footer_info); | |
| 285 #endif // defined(USE_SKIA) | |
| 286 | |
| 287 bool GetPrintFrame(WebKit::WebFrame** frame); | 269 bool GetPrintFrame(WebKit::WebFrame** frame); |
| 288 | 270 |
| 289 // This reports the current time - |start_time| as the time to render a page. | 271 // This reports the current time - |start_time| as the time to render a page. |
| 290 void ReportPreviewPageRenderTime(base::TimeTicks start_time); | 272 void ReportPreviewPageRenderTime(base::TimeTicks start_time); |
| 291 | 273 |
| 292 // Script Initiated Printing ------------------------------------------------ | 274 // Script Initiated Printing ------------------------------------------------ |
| 293 | 275 |
| 294 // Returns true if script initiated printing occurs too often. | 276 // Returns true if script initiated printing occurs too often. |
| 295 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); | 277 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); |
| 296 | 278 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 320 // Used for scripted initiated printing blocking. | 302 // Used for scripted initiated printing blocking. |
| 321 base::Time last_cancelled_script_print_; | 303 base::Time last_cancelled_script_print_; |
| 322 int user_cancelled_scripted_print_count_; | 304 int user_cancelled_scripted_print_count_; |
| 323 | 305 |
| 324 // Let the browser process know of a printing failure. Only set to false when | 306 // Let the browser process know of a printing failure. Only set to false when |
| 325 // the failure came from the browser in the first place. | 307 // the failure came from the browser in the first place. |
| 326 bool notify_browser_of_print_failure_; | 308 bool notify_browser_of_print_failure_; |
| 327 | 309 |
| 328 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; | 310 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; |
| 329 | 311 |
| 330 // Strings generated by the browser process to be printed as headers and | |
| 331 // footers if requested by the user. | |
| 332 scoped_ptr<base::DictionaryValue> header_footer_info_; | |
| 333 | |
| 334 // Keeps track of the state of print preview between messages. | 312 // Keeps track of the state of print preview between messages. |
| 335 class PrintPreviewContext { | 313 class PrintPreviewContext { |
| 336 public: | 314 public: |
| 337 PrintPreviewContext(); | 315 PrintPreviewContext(); |
| 338 ~PrintPreviewContext(); | 316 ~PrintPreviewContext(); |
| 339 | 317 |
| 340 // Initializes the print preview context. Need to be called to set | 318 // Initializes the print preview context. Need to be called to set |
| 341 // the |web_frame| / |web_node| to generate the print preview for. | 319 // the |web_frame| / |web_node| to generate the print preview for. |
| 342 void InitWithFrame(WebKit::WebFrame* web_frame); | 320 void InitWithFrame(WebKit::WebFrame* web_frame); |
| 343 void InitWithNode(const WebKit::WebNode& web_node); | 321 void InitWithNode(const WebKit::WebNode& web_node); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 395 |
| 418 State state_; | 396 State state_; |
| 419 }; | 397 }; |
| 420 | 398 |
| 421 PrintPreviewContext print_preview_context_; | 399 PrintPreviewContext print_preview_context_; |
| 422 | 400 |
| 423 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 401 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 424 }; | 402 }; |
| 425 | 403 |
| 426 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 404 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |