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

Side by Side Diff: components/printing/renderer/print_web_view_helper.cc

Issue 1991273003: Fire visibilityChange event on out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments Created 4 years, 6 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
OLDNEW
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
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
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 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 blink::WebConsoleMessage::LevelWarning, message)); 2251 blink::WebConsoleMessage::LevelWarning, message));
2250 return false; 2252 return false;
2251 } 2253 }
2252 2254
2253 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2255 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2254 // Reset counter on successful print. 2256 // Reset counter on successful print.
2255 count_ = 0; 2257 count_ = 0;
2256 } 2258 }
2257 2259
2258 } // namespace printing 2260 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698