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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 const PageSizeMargins& page_layout, | 515 const PageSizeMargins& page_layout, |
516 const PrintMsg_Print_Params& params) { | 516 const PrintMsg_Print_Params& params) { |
517 SkAutoCanvasRestore auto_restore(canvas, true); | 517 SkAutoCanvasRestore auto_restore(canvas, true); |
518 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); | 518 canvas->scale(1 / webkit_scale_factor, 1 / webkit_scale_factor); |
519 | 519 |
520 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + | 520 blink::WebSize page_size(page_layout.margin_left + page_layout.margin_right + |
521 page_layout.content_width, | 521 page_layout.content_width, |
522 page_layout.margin_top + page_layout.margin_bottom + | 522 page_layout.margin_top + page_layout.margin_bottom + |
523 page_layout.content_height); | 523 page_layout.content_height); |
524 | 524 |
525 blink::WebView* web_view = blink::WebView::create(NULL); | 525 blink::WebView* web_view = |
| 526 blink::WebView::create(nullptr, blink::WebPageVisibilityStateVisible); |
526 web_view->settings()->setJavaScriptEnabled(true); | 527 web_view->settings()->setJavaScriptEnabled(true); |
527 | 528 |
528 blink::WebLocalFrame* frame = | 529 blink::WebLocalFrame* frame = |
529 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, NULL); | 530 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, NULL); |
530 web_view->setMainFrame(frame); | 531 web_view->setMainFrame(frame); |
531 | 532 |
532 base::StringValue html(ResourceBundle::GetSharedInstance().GetLocalizedString( | 533 base::StringValue html(ResourceBundle::GetSharedInstance().GetLocalizedString( |
533 IDR_PRINT_PREVIEW_PAGE)); | 534 IDR_PRINT_PREVIEW_PAGE)); |
534 // Load page with script to avoid async operations. | 535 // Load page with script to avoid async operations. |
535 ExecuteScript(frame, kPageLoadScriptFormat, html); | 536 ExecuteScript(frame, kPageLoadScriptFormat, html); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 std::string url_str = "data:text/html;charset=utf-8,"; | 733 std::string url_str = "data:text/html;charset=utf-8,"; |
733 url_str.append( | 734 url_str.append( |
734 net::EscapeQueryParamValue(frame()->selectionAsMarkup().utf8(), false)); | 735 net::EscapeQueryParamValue(frame()->selectionAsMarkup().utf8(), false)); |
735 RestoreSize(); | 736 RestoreSize(); |
736 // Create a new WebView with the same settings as the current display one. | 737 // Create a new WebView with the same settings as the current display one. |
737 // Except that we disable javascript (don't want any active content running | 738 // Except that we disable javascript (don't want any active content running |
738 // on the page). | 739 // on the page). |
739 WebPreferences prefs = preferences; | 740 WebPreferences prefs = preferences; |
740 prefs.javascript_enabled = false; | 741 prefs.javascript_enabled = false; |
741 | 742 |
742 blink::WebView* web_view = blink::WebView::create(this); | 743 blink::WebView* web_view = |
| 744 blink::WebView::create(this, blink::WebPageVisibilityStateVisible); |
743 owns_web_view_ = true; | 745 owns_web_view_ = true; |
744 content::RenderView::ApplyWebPreferences(prefs, web_view); | 746 content::RenderView::ApplyWebPreferences(prefs, web_view); |
745 web_view->setMainFrame( | 747 web_view->setMainFrame( |
746 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this)); | 748 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this)); |
747 frame_.Reset(web_view->mainFrame()->toWebLocalFrame()); | 749 frame_.Reset(web_view->mainFrame()->toWebLocalFrame()); |
748 node_to_print_.reset(); | 750 node_to_print_.reset(); |
749 | 751 |
750 // When loading is done this will call didStopLoading() and that will do the | 752 // When loading is done this will call didStopLoading() and that will do the |
751 // actual printing. | 753 // actual printing. |
752 frame()->loadRequest(blink::WebURLRequest(GURL(url_str))); | 754 frame()->loadRequest(blink::WebURLRequest(GURL(url_str))); |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2250 blink::WebConsoleMessage::LevelWarning, message)); | 2252 blink::WebConsoleMessage::LevelWarning, message)); |
2251 return false; | 2253 return false; |
2252 } | 2254 } |
2253 | 2255 |
2254 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2256 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2255 // Reset counter on successful print. | 2257 // Reset counter on successful print. |
2256 count_ = 0; | 2258 count_ = 0; |
2257 } | 2259 } |
2258 | 2260 |
2259 } // namespace printing | 2261 } // namespace printing |
OLD | NEW |