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

Unified Diff: chrome/renderer/blocked_plugin.cc

Issue 2967007: Disable outdated plugins, block non-sandboxed plugins. (Closed)
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
index 00eae32fa4de8df42b26316c581ce634a6f87c4b..f4dddb7bc46aa0488a38206022ac3770c06cc7d1 100644
--- a/chrome/renderer/blocked_plugin.cc
+++ b/chrome/renderer/blocked_plugin.cc
@@ -6,8 +6,12 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/file_path.h"
#include "base/string_piece.h"
#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/notification_service.h"
+#include "chrome/common/plugin_group.h"
+#include "chrome/common/render_messages.h"
#include "chrome/renderer/render_view.h"
#include "grit/generated_resources.h"
#include "grit/renderer_resources.h"
@@ -30,7 +34,8 @@ static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/";
BlockedPlugin::BlockedPlugin(RenderView* render_view,
WebFrame* frame,
- const WebPluginParams& params)
+ const WebPluginParams& params,
+ PluginGroup* group)
: render_view_(render_view),
frame_(frame),
plugin_params_(params) {
@@ -46,40 +51,79 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view,
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));
+ DictionaryValue values;
+ values.SetString(L"loadPlugin", l10n_util::GetString(IDS_PLUGIN_LOAD));
+ values.SetString(L"updatePlugin", l10n_util::GetString(IDS_PLUGIN_UPDATE));
+ if (group)
+ values.Set(L"pluginGroup", group->GetDataForUI());
// "t" is the id of the templates root node.
std::string htmlData = jstemplate_builder::GetTemplatesHtml(
- template_html, &localized_strings, "t");
+ template_html, &values, "t");
web_view->mainFrame()->loadHTMLString(htmlData,
GURL(kBlockedPluginDataURL));
+
+ registrar_.Add(this,
+ NotificationType::SHOULD_LOAD_PLUGINS,
+ NotificationService::AllSources());
}
void BlockedPlugin::BindWebFrame(WebFrame* frame) {
BindToJavascript(frame, L"plugin");
BindMethod("load", &BlockedPlugin::Load);
+ BindMethod("update", &BlockedPlugin::Update);
}
void BlockedPlugin::WillDestroyPlugin() {
delete this;
}
+void BlockedPlugin::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::SHOULD_LOAD_PLUGINS) {
+ LoadPlugin();
+ } else {
+ NOTREACHED();
+ }
+}
+
void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) {
LoadPlugin();
}
+void BlockedPlugin::Update(const CppArgumentList& args, CppVariant* result) {
+ if (args.size() > 0) {
+ CppVariant arg(args[0]);
+ if (arg.isString()) {
+ GURL url(arg.ToString());
+ OpenURL(url);
+ }
+ }
+}
+
+void BlockedPlugin::OpenURL(GURL& url) {
+ render_view_->Send(new ViewHostMsg_OpenURL(render_view_->routing_id(),
+ url,
+ GURL(),
+ CURRENT_TAB));
+}
+
void BlockedPlugin::LoadPlugin() {
CHECK(plugin_);
WebPluginContainer* container = plugin_->container();
WebPlugin* new_plugin =
- render_view_->CreatePluginInternal(frame_, plugin_params_);
+ render_view_->CreateNPAPIPlugin(frame_,
+ plugin_params_,
+ NULL,
+ std::string());
if (new_plugin && new_plugin->initialize(container)) {
container->setPlugin(new_plugin);
container->invalidate();
container->reportGeometry();
plugin_->destroy();
+ render_view_->Send(
+ new ViewHostMsg_BlockedPluginLoaded(render_view_->routing_id()));
}
}
« 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