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

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

Issue 2651583007: Plumbing blink::Interface{Provider|Registry} through WebLocalFrame's constructor. (Closed)
Patch Set: Rebasing... Created 3 years, 11 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 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 page_layout.content_width, 580 page_layout.content_width,
581 page_layout.margin_top + page_layout.margin_bottom + 581 page_layout.margin_top + page_layout.margin_bottom +
582 page_layout.content_height); 582 page_layout.content_height);
583 583
584 blink::WebView* web_view = 584 blink::WebView* web_view =
585 blink::WebView::create(nullptr, blink::WebPageVisibilityStateVisible); 585 blink::WebView::create(nullptr, blink::WebPageVisibilityStateVisible);
586 web_view->settings()->setJavaScriptEnabled(true); 586 web_view->settings()->setJavaScriptEnabled(true);
587 587
588 blink::WebFrameClient frame_client; 588 blink::WebFrameClient frame_client;
589 blink::WebLocalFrame* frame = blink::WebLocalFrame::create( 589 blink::WebLocalFrame* frame = blink::WebLocalFrame::create(
590 blink::WebTreeScopeType::Document, &frame_client); 590 blink::WebTreeScopeType::Document, &frame_client, nullptr, nullptr);
591 web_view->setMainFrame(frame); 591 web_view->setMainFrame(frame);
592 blink::WebFrameWidget::create(nullptr, web_view, frame); 592 blink::WebFrameWidget::create(nullptr, web_view, frame);
593 593
594 base::StringValue html(ResourceBundle::GetSharedInstance().GetLocalizedString( 594 base::StringValue html(ResourceBundle::GetSharedInstance().GetLocalizedString(
595 IDR_PRINT_PREVIEW_PAGE)); 595 IDR_PRINT_PREVIEW_PAGE));
596 // Load page with script to avoid async operations. 596 // Load page with script to avoid async operations.
597 ExecuteScript(frame, kPageLoadScriptFormat, html); 597 ExecuteScript(frame, kPageLoadScriptFormat, html);
598 598
599 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue()); 599 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue());
600 options.reset(new base::DictionaryValue()); 600 options.reset(new base::DictionaryValue());
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 // Create a new WebView with the same settings as the current display one. 802 // Create a new WebView with the same settings as the current display one.
803 // Except that we disable javascript (don't want any active content running 803 // Except that we disable javascript (don't want any active content running
804 // on the page). 804 // on the page).
805 WebPreferences prefs = preferences; 805 WebPreferences prefs = preferences;
806 prefs.javascript_enabled = false; 806 prefs.javascript_enabled = false;
807 807
808 blink::WebView* web_view = 808 blink::WebView* web_view =
809 blink::WebView::create(this, blink::WebPageVisibilityStateVisible); 809 blink::WebView::create(this, blink::WebPageVisibilityStateVisible);
810 owns_web_view_ = true; 810 owns_web_view_ = true;
811 content::RenderView::ApplyWebPreferences(prefs, web_view); 811 content::RenderView::ApplyWebPreferences(prefs, web_view);
812 blink::WebLocalFrame* main_frame = 812 blink::WebLocalFrame* main_frame = blink::WebLocalFrame::create(
813 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this); 813 blink::WebTreeScopeType::Document, this, nullptr, nullptr);
814 web_view->setMainFrame(main_frame); 814 web_view->setMainFrame(main_frame);
815 blink::WebFrameWidget::create(this, web_view, main_frame); 815 blink::WebFrameWidget::create(this, web_view, main_frame);
816 frame_.Reset(web_view->mainFrame()->toWebLocalFrame()); 816 frame_.Reset(web_view->mainFrame()->toWebLocalFrame());
817 node_to_print_.reset(); 817 node_to_print_.reset();
818 818
819 // When loading is done this will call didStopLoading() and that will do the 819 // When loading is done this will call didStopLoading() and that will do the
820 // actual printing. 820 // actual printing.
821 blink::WebURLRequest request = blink::WebURLRequest(GURL(url_str)); 821 blink::WebURLRequest request = blink::WebURLRequest(GURL(url_str));
822 frame()->loadRequest(request); 822 frame()->loadRequest(request);
823 } 823 }
(...skipping 11 matching lines...) Expand all
835 weak_ptr_factory_.GetWeakPtr())); 835 weak_ptr_factory_.GetWeakPtr()));
836 } 836 }
837 837
838 blink::WebLocalFrame* PrepareFrameAndViewForPrint::createChildFrame( 838 blink::WebLocalFrame* PrepareFrameAndViewForPrint::createChildFrame(
839 blink::WebLocalFrame* parent, 839 blink::WebLocalFrame* parent,
840 blink::WebTreeScopeType scope, 840 blink::WebTreeScopeType scope,
841 const blink::WebString& name, 841 const blink::WebString& name,
842 const blink::WebString& unique_name, 842 const blink::WebString& unique_name,
843 blink::WebSandboxFlags sandbox_flags, 843 blink::WebSandboxFlags sandbox_flags,
844 const blink::WebFrameOwnerProperties& frame_owner_properties) { 844 const blink::WebFrameOwnerProperties& frame_owner_properties) {
845 blink::WebLocalFrame* frame = blink::WebLocalFrame::create(scope, this); 845 blink::WebLocalFrame* frame =
846 blink::WebLocalFrame::create(scope, this, nullptr, nullptr);
846 parent->appendChild(frame); 847 parent->appendChild(frame);
847 return frame; 848 return frame;
848 } 849 }
849 850
850 void PrepareFrameAndViewForPrint::CallOnReady() { 851 void PrepareFrameAndViewForPrint::CallOnReady() {
851 return on_ready_.Run(); // Can delete |this|. 852 return on_ready_.Run(); // Can delete |this|.
852 } 853 }
853 854
854 void PrepareFrameAndViewForPrint::RestoreSize() { 855 void PrepareFrameAndViewForPrint::RestoreSize() {
855 if (!frame()) 856 if (!frame())
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 blink::WebConsoleMessage::LevelWarning, message)); 2349 blink::WebConsoleMessage::LevelWarning, message));
2349 return false; 2350 return false;
2350 } 2351 }
2351 2352
2352 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2353 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2353 // Reset counter on successful print. 2354 // Reset counter on successful print.
2354 count_ = 0; 2355 count_ = 0;
2355 } 2356 }
2356 2357
2357 } // namespace printing 2358 } // namespace printing
OLDNEW
« no previous file with comments | « components/plugins/renderer/webview_plugin.cc ('k') | content/renderer/media/android/media_info_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698