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

Unified Diff: chrome/renderer/blocked_plugin.cc

Issue 2862031: Add click-to-load functionality for blocked plugins. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/blocked_plugin.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/blocked_plugin.cc
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc
new file mode 100644
index 0000000000000000000000000000000000000000..00eae32fa4de8df42b26316c581ce634a6f87c4b
--- /dev/null
+++ b/chrome/renderer/blocked_plugin.cc
@@ -0,0 +1,85 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/blocked_plugin.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/string_piece.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "chrome/renderer/render_view.h"
+#include "grit/generated_resources.h"
+#include "grit/renderer_resources.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
+#include "webkit/glue/plugins/webview_plugin.h"
+
+using WebKit::WebCursorInfo;
+using WebKit::WebFrame;
+using WebKit::WebPlugin;
+using WebKit::WebPluginContainer;
+using WebKit::WebPluginParams;
+using WebKit::WebURL;
+using WebKit::WebView;
+
+static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/";
+
+BlockedPlugin::BlockedPlugin(RenderView* render_view,
+ WebFrame* frame,
+ const WebPluginParams& params)
+ : render_view_(render_view),
+ frame_(frame),
+ plugin_params_(params) {
+ plugin_ = new WebViewPlugin(this);
+
+ WebView* web_view = plugin_->web_view();
+ web_view->mainFrame()->setCanHaveScrollbars(false);
+
+ int resource_id = IDR_BLOCKED_PLUGIN_HTML;
+ const base::StringPiece template_html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
+
+ DCHECK(!template_html.empty()) << "unable to load template. ID: "
+ << resource_id;
+
+ DictionaryValue localized_strings;
+ localized_strings.SetString(L"loadPlugin",
+ l10n_util::GetString(IDS_PLUGIN_LOAD));
+
+ // "t" is the id of the templates root node.
+ std::string htmlData = jstemplate_builder::GetTemplatesHtml(
+ template_html, &localized_strings, "t");
+
+ web_view->mainFrame()->loadHTMLString(htmlData,
+ GURL(kBlockedPluginDataURL));
+}
+
+void BlockedPlugin::BindWebFrame(WebFrame* frame) {
+ BindToJavascript(frame, L"plugin");
+ BindMethod("load", &BlockedPlugin::Load);
+}
+
+void BlockedPlugin::WillDestroyPlugin() {
+ delete this;
+}
+
+void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) {
+ LoadPlugin();
+}
+
+void BlockedPlugin::LoadPlugin() {
+ CHECK(plugin_);
+ WebPluginContainer* container = plugin_->container();
+ WebPlugin* new_plugin =
+ render_view_->CreatePluginInternal(frame_, plugin_params_);
+ if (new_plugin && new_plugin->initialize(container)) {
+ container->setPlugin(new_plugin);
+ container->invalidate();
+ container->reportGeometry();
+ plugin_->destroy();
+ }
+}
« no previous file with comments | « chrome/renderer/blocked_plugin.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698