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 #include "chrome/renderer/printing/print_web_view_helper.h" | 5 #include "chrome/renderer/printing/print_web_view_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 SkAutoCanvasRestore auto_restore(canvas, true); | 457 SkAutoCanvasRestore auto_restore(canvas, true); |
458 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); | 458 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); |
459 | 459 |
460 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + | 460 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + |
461 page_layout.content_width, | 461 page_layout.content_width, |
462 page_layout.margin_top + page_layout.margin_bottom + | 462 page_layout.margin_top + page_layout.margin_bottom + |
463 page_layout.content_height); | 463 page_layout.content_height); |
464 | 464 |
465 blink::WebView* web_view = blink::WebView::create(NULL); | 465 blink::WebView* web_view = blink::WebView::create(NULL); |
466 web_view->settings()->setJavaScriptEnabled(true); | 466 web_view->settings()->setJavaScriptEnabled(true); |
467 blink::WebFrame* frame = blink::WebFrame::create(NULL); | 467 |
| 468 // We don't need to use the frame ID for this frame, so we pass 0 for it. |
| 469 blink::WebFrame* frame = blink::WebFrame::create(NULL, 0); |
468 web_view->setMainFrame(frame); | 470 web_view->setMainFrame(frame); |
469 | 471 |
470 base::StringValue html( | 472 base::StringValue html( |
471 ResourceBundle::GetSharedInstance().GetLocalizedString( | 473 ResourceBundle::GetSharedInstance().GetLocalizedString( |
472 IDR_PRINT_PREVIEW_PAGE)); | 474 IDR_PRINT_PREVIEW_PAGE)); |
473 // Load page with script to avoid async operations. | 475 // Load page with script to avoid async operations. |
474 ExecuteScript(frame, kPageLoadScriptFormat, html); | 476 ExecuteScript(frame, kPageLoadScriptFormat, html); |
475 | 477 |
476 scoped_ptr<base::DictionaryValue> options(header_footer_info.DeepCopy()); | 478 scoped_ptr<base::DictionaryValue> options(header_footer_info.DeepCopy()); |
477 options->SetDouble("width", page_size.width); | 479 options->SetDouble("width", page_size.width); |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 } | 1998 } |
1997 | 1999 |
1998 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 2000 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
1999 prep_frame_view_.reset(); | 2001 prep_frame_view_.reset(); |
2000 metafile_.reset(); | 2002 metafile_.reset(); |
2001 pages_to_render_.clear(); | 2003 pages_to_render_.clear(); |
2002 error_ = PREVIEW_ERROR_NONE; | 2004 error_ = PREVIEW_ERROR_NONE; |
2003 } | 2005 } |
2004 | 2006 |
2005 } // namespace printing | 2007 } // namespace printing |
OLD | NEW |