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

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

Issue 1161923004: Reland: Plugin Placeholders: Refactor for platforms that don't support plugins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove some enable_plugins that are no longer needed Created 5 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
« no previous file with comments | « components/plugins/renderer/webview_plugin.h ('k') | content/content_shell.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "content/public/common/web_preferences.h" 10 #include "content/public/common/web_preferences.h"
11 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
12 #include "gin/converter.h"
12 #include "skia/ext/platform_canvas.h" 13 #include "skia/ext/platform_canvas.h"
13 #include "third_party/WebKit/public/platform/WebSize.h" 14 #include "third_party/WebKit/public/platform/WebSize.h"
14 #include "third_party/WebKit/public/platform/WebURL.h" 15 #include "third_party/WebKit/public/platform/WebURL.h"
15 #include "third_party/WebKit/public/platform/WebURLRequest.h" 16 #include "third_party/WebKit/public/platform/WebURLRequest.h"
16 #include "third_party/WebKit/public/platform/WebURLResponse.h" 17 #include "third_party/WebKit/public/platform/WebURLResponse.h"
17 #include "third_party/WebKit/public/web/WebDocument.h" 18 #include "third_party/WebKit/public/web/WebDocument.h"
18 #include "third_party/WebKit/public/web/WebElement.h" 19 #include "third_party/WebKit/public/web/WebElement.h"
19 #include "third_party/WebKit/public/web/WebInputEvent.h" 20 #include "third_party/WebKit/public/web/WebInputEvent.h"
20 #include "third_party/WebKit/public/web/WebLocalFrame.h" 21 #include "third_party/WebKit/public/web/WebLocalFrame.h"
21 #include "third_party/WebKit/public/web/WebPluginContainer.h" 22 #include "third_party/WebKit/public/web/WebPluginContainer.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 content::RenderView::ApplyWebPreferences(preferences, web_view_); 55 content::RenderView::ApplyWebPreferences(preferences, web_view_);
55 web_frame_ = WebLocalFrame::create(blink::WebTreeScopeType::Document, this); 56 web_frame_ = WebLocalFrame::create(blink::WebTreeScopeType::Document, this);
56 web_view_->setMainFrame(web_frame_); 57 web_view_->setMainFrame(web_frame_);
57 } 58 }
58 59
59 // static 60 // static
60 WebViewPlugin* WebViewPlugin::Create(WebViewPlugin::Delegate* delegate, 61 WebViewPlugin* WebViewPlugin::Create(WebViewPlugin::Delegate* delegate,
61 const WebPreferences& preferences, 62 const WebPreferences& preferences,
62 const std::string& html_data, 63 const std::string& html_data,
63 const GURL& url) { 64 const GURL& url) {
65 DCHECK(url.is_valid()) << "Blink requires the WebView to have a valid URL.";
64 WebViewPlugin* plugin = new WebViewPlugin(delegate, preferences); 66 WebViewPlugin* plugin = new WebViewPlugin(delegate, preferences);
65 plugin->web_view()->mainFrame()->loadHTMLString(html_data, url); 67 plugin->web_view()->mainFrame()->loadHTMLString(html_data, url);
66 return plugin; 68 return plugin;
67 } 69 }
68 70
69 WebViewPlugin::~WebViewPlugin() { 71 WebViewPlugin::~WebViewPlugin() {
70 web_view_->close(); 72 web_view_->close();
71 web_frame_->close(); 73 web_frame_->close();
72 } 74 }
73 75
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) { 259 void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) {
258 current_cursor_ = cursor; 260 current_cursor_ = cursor;
259 } 261 }
260 262
261 void WebViewPlugin::scheduleAnimation() { 263 void WebViewPlugin::scheduleAnimation() {
262 if (container_) 264 if (container_)
263 container_->setNeedsLayout(); 265 container_->setNeedsLayout();
264 } 266 }
265 267
266 void WebViewPlugin::didClearWindowObject(WebLocalFrame* frame) { 268 void WebViewPlugin::didClearWindowObject(WebLocalFrame* frame) {
267 if (delegate_) 269 if (!delegate_)
268 delegate_->BindWebFrame(frame); 270 return;
271
272 v8::Isolate* isolate = blink::mainThreadIsolate();
273 v8::HandleScope handle_scope(isolate);
274 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
275 DCHECK(!context.IsEmpty());
276
277 v8::Context::Scope context_scope(context);
278 v8::Local<v8::Object> global = context->Global();
279
280 global->Set(gin::StringToV8(isolate, "plugin"),
281 delegate_->GetV8Handle(isolate));
269 } 282 }
270 283
271 void WebViewPlugin::didReceiveResponse(WebLocalFrame* frame, 284 void WebViewPlugin::didReceiveResponse(WebLocalFrame* frame,
272 unsigned identifier, 285 unsigned identifier,
273 const WebURLResponse& response) { 286 const WebURLResponse& response) {
274 WebFrameClient::didReceiveResponse(frame, identifier, response); 287 WebFrameClient::didReceiveResponse(frame, identifier, response);
275 } 288 }
OLDNEW
« no previous file with comments | « components/plugins/renderer/webview_plugin.h ('k') | content/content_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698