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

Side by Side Diff: components/plugins/renderer/webview_plugin.cc

Issue 2389493002: Revert of Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/plugins/renderer/webview_plugin.h" 5 #include "components/plugins/renderer/webview_plugin.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 container_(nullptr), 55 container_(nullptr),
56 web_view_(WebView::create(this, blink::WebPageVisibilityStateVisible)), 56 web_view_(WebView::create(this, blink::WebPageVisibilityStateVisible)),
57 focused_(false), 57 focused_(false),
58 is_painting_(false), 58 is_painting_(false),
59 is_resizing_(false), 59 is_resizing_(false),
60 web_frame_client_(this), 60 web_frame_client_(this),
61 weak_factory_(this) { 61 weak_factory_(this) {
62 // ApplyWebPreferences before making a WebLocalFrame so that the frame sees a 62 // ApplyWebPreferences before making a WebLocalFrame so that the frame sees a
63 // consistent view of our preferences. 63 // consistent view of our preferences.
64 content::RenderView::ApplyWebPreferences(preferences, web_view_); 64 content::RenderView::ApplyWebPreferences(preferences, web_view_);
65 WebLocalFrame* web_frame = WebLocalFrame::create( 65 WebLocalFrame* web_local_frame = WebLocalFrame::create(
66 blink::WebTreeScopeType::Document, &web_frame_client_); 66 blink::WebTreeScopeType::Document, &web_frame_client_);
67 web_view_->setMainFrame(web_frame); 67 web_frame_ = web_local_frame;
68 web_view_->setMainFrame(web_frame_);
68 // TODO(dcheng): The main frame widget currently has a special case. 69 // TODO(dcheng): The main frame widget currently has a special case.
69 // Eliminate this once WebView is no longer a WebWidget. 70 // Eliminate this once WebView is no longer a WebWidget.
70 WebFrameWidget::create(this, web_view_, web_frame); 71 web_frame_widget_ = WebFrameWidget::create(this, web_view_, web_local_frame);
71 } 72 }
72 73
73 // static 74 // static
74 WebViewPlugin* WebViewPlugin::Create(content::RenderView* render_view, 75 WebViewPlugin* WebViewPlugin::Create(content::RenderView* render_view,
75 WebViewPlugin::Delegate* delegate, 76 WebViewPlugin::Delegate* delegate,
76 const WebPreferences& preferences, 77 const WebPreferences& preferences,
77 const std::string& html_data, 78 const std::string& html_data,
78 const GURL& url) { 79 const GURL& url) {
79 DCHECK(url.is_valid()) << "Blink requires the WebView to have a valid URL."; 80 DCHECK(url.is_valid()) << "Blink requires the WebView to have a valid URL.";
80 WebViewPlugin* plugin = new WebViewPlugin(render_view, delegate, preferences); 81 WebViewPlugin* plugin = new WebViewPlugin(render_view, delegate, preferences);
81 plugin->web_view()->mainFrame()->loadHTMLString(html_data, url); 82 plugin->web_view()->mainFrame()->loadHTMLString(html_data, url);
82 return plugin; 83 return plugin;
83 } 84 }
84 85
85 WebViewPlugin::~WebViewPlugin() { 86 WebViewPlugin::~WebViewPlugin() {
86 DCHECK(!weak_factory_.HasWeakPtrs()); 87 DCHECK(!weak_factory_.HasWeakPtrs());
88 web_frame_widget_->close();
87 web_view_->close(); 89 web_view_->close();
90 web_frame_->close();
88 } 91 }
89 92
90 WebPluginContainer* WebViewPlugin::container() const { return container_; } 93 WebPluginContainer* WebViewPlugin::container() const { return container_; }
91 94
92 bool WebViewPlugin::initialize(WebPluginContainer* container) { 95 bool WebViewPlugin::initialize(WebPluginContainer* container) {
93 DCHECK(container); 96 DCHECK(container);
94 DCHECK_EQ(this, container->plugin()); 97 DCHECK_EQ(this, container->plugin());
95 container_ = container; 98 container_ = container;
96 99
97 // We must call layout again here to ensure that the container is laid 100 // We must call layout again here to ensure that the container is laid
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (!delegate_) 313 if (!delegate_)
311 return; 314 return;
312 315
313 // The delegate may instantiate a new plugin. 316 // The delegate may instantiate a new plugin.
314 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect)); 317 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
315 // The delegate may have dirtied style and layout of the WebView. 318 // The delegate may have dirtied style and layout of the WebView.
316 // See for example the resizePoster function in plugin_poster.html. 319 // See for example the resizePoster function in plugin_poster.html.
317 // Run the lifecycle now so that it is clean. 320 // Run the lifecycle now so that it is clean.
318 web_view_->updateAllLifecyclePhases(); 321 web_view_->updateAllLifecyclePhases();
319 } 322 }
OLDNEW
« no previous file with comments | « components/plugins/renderer/webview_plugin.h ('k') | components/printing/renderer/print_web_view_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698