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

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

Issue 2369613003: Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: oops 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_local_frame = WebLocalFrame::create( 65 WebLocalFrame* web_frame = WebLocalFrame::create(
66 blink::WebTreeScopeType::Document, &web_frame_client_); 66 blink::WebTreeScopeType::Document, &web_frame_client_);
67 web_frame_ = web_local_frame; 67 web_view_->setMainFrame(web_frame);
68 web_view_->setMainFrame(web_frame_);
69 // TODO(dcheng): The main frame widget currently has a special case. 68 // TODO(dcheng): The main frame widget currently has a special case.
70 // Eliminate this once WebView is no longer a WebWidget. 69 // Eliminate this once WebView is no longer a WebWidget.
71 web_frame_widget_ = WebFrameWidget::create(this, web_view_, web_local_frame); 70 WebFrameWidget::create(this, web_view_, web_frame);
72 } 71 }
73 72
74 // static 73 // static
75 WebViewPlugin* WebViewPlugin::Create(content::RenderView* render_view, 74 WebViewPlugin* WebViewPlugin::Create(content::RenderView* render_view,
76 WebViewPlugin::Delegate* delegate, 75 WebViewPlugin::Delegate* delegate,
77 const WebPreferences& preferences, 76 const WebPreferences& preferences,
78 const std::string& html_data, 77 const std::string& html_data,
79 const GURL& url) { 78 const GURL& url) {
80 DCHECK(url.is_valid()) << "Blink requires the WebView to have a valid URL."; 79 DCHECK(url.is_valid()) << "Blink requires the WebView to have a valid URL.";
81 WebViewPlugin* plugin = new WebViewPlugin(render_view, delegate, preferences); 80 WebViewPlugin* plugin = new WebViewPlugin(render_view, delegate, preferences);
82 plugin->web_view()->mainFrame()->loadHTMLString(html_data, url); 81 plugin->web_view()->mainFrame()->loadHTMLString(html_data, url);
83 return plugin; 82 return plugin;
84 } 83 }
85 84
86 WebViewPlugin::~WebViewPlugin() { 85 WebViewPlugin::~WebViewPlugin() {
87 DCHECK(!weak_factory_.HasWeakPtrs()); 86 DCHECK(!weak_factory_.HasWeakPtrs());
88 web_frame_widget_->close();
89 web_view_->close(); 87 web_view_->close();
90 web_frame_->close();
91 } 88 }
92 89
93 WebPluginContainer* WebViewPlugin::container() const { return container_; } 90 WebPluginContainer* WebViewPlugin::container() const { return container_; }
94 91
95 bool WebViewPlugin::initialize(WebPluginContainer* container) { 92 bool WebViewPlugin::initialize(WebPluginContainer* container) {
96 DCHECK(container); 93 DCHECK(container);
97 DCHECK_EQ(this, container->plugin()); 94 DCHECK_EQ(this, container->plugin());
98 container_ = container; 95 container_ = container;
99 96
100 // We must call layout again here to ensure that the container is laid 97 // 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
313 if (!delegate_) 310 if (!delegate_)
314 return; 311 return;
315 312
316 // The delegate may instantiate a new plugin. 313 // The delegate may instantiate a new plugin.
317 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect)); 314 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
318 // The delegate may have dirtied style and layout of the WebView. 315 // The delegate may have dirtied style and layout of the WebView.
319 // See for example the resizePoster function in plugin_poster.html. 316 // See for example the resizePoster function in plugin_poster.html.
320 // Run the lifecycle now so that it is clean. 317 // Run the lifecycle now so that it is clean.
321 web_view_->updateAllLifecyclePhases(); 318 web_view_->updateAllLifecyclePhases();
322 } 319 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698