| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/plugins/blocked_plugin.h" | 5 #include "chrome/renderer/plugins/blocked_plugin.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 BlockedPlugin::~BlockedPlugin() { | 96 BlockedPlugin::~BlockedPlugin() { |
| 97 } | 97 } |
| 98 | 98 |
| 99 void BlockedPlugin::BindWebFrame(WebFrame* frame) { | 99 void BlockedPlugin::BindWebFrame(WebFrame* frame) { |
| 100 PluginPlaceholder::BindWebFrame(frame); | 100 PluginPlaceholder::BindWebFrame(frame); |
| 101 BindCallback("load", base::Bind(&BlockedPlugin::LoadCallback, | 101 BindCallback("load", base::Bind(&BlockedPlugin::LoadCallback, |
| 102 base::Unretained(this))); | 102 base::Unretained(this))); |
| 103 BindCallback("hide", base::Bind(&BlockedPlugin::HideCallback, | 103 BindCallback("hide", base::Bind(&BlockedPlugin::HideCallback, |
| 104 base::Unretained(this))); | 104 base::Unretained(this))); |
| 105 BindCallback("openURL", base::Bind(&BlockedPlugin::OpenUrlCallback, | 105 BindCallback("openAboutPlugins", |
| 106 base::Unretained(this))); | 106 base::Bind(&BlockedPlugin::OpenAboutPluginsCallback, |
| 107 base::Unretained(this))); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) { | 110 void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) { |
| 110 WebContextMenuData menu_data; | 111 WebContextMenuData menu_data; |
| 111 | 112 |
| 112 size_t num_items = name_.empty() ? 2u : 4u; | 113 size_t num_items = name_.empty() ? 2u : 4u; |
| 113 WebVector<WebMenuItemInfo> custom_items(num_items); | 114 WebVector<WebMenuItemInfo> custom_items(num_items); |
| 114 | 115 |
| 115 size_t i = 0; | 116 size_t i = 0; |
| 116 if (!name_.empty()) { | 117 if (!name_.empty()) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 RenderThread::Get()->RecordUserMetrics("Plugin_Load_Click"); | 213 RenderThread::Get()->RecordUserMetrics("Plugin_Load_Click"); |
| 213 LoadPlugin(); | 214 LoadPlugin(); |
| 214 } | 215 } |
| 215 | 216 |
| 216 void BlockedPlugin::HideCallback(const CppArgumentList& args, | 217 void BlockedPlugin::HideCallback(const CppArgumentList& args, |
| 217 CppVariant* result) { | 218 CppVariant* result) { |
| 218 RenderThread::Get()->RecordUserMetrics("Plugin_Hide_Click"); | 219 RenderThread::Get()->RecordUserMetrics("Plugin_Hide_Click"); |
| 219 HidePlugin(); | 220 HidePlugin(); |
| 220 } | 221 } |
| 221 | 222 |
| 222 void BlockedPlugin::OpenUrlCallback(const CppArgumentList& args, | 223 void BlockedPlugin::OpenAboutPluginsCallback(const CppArgumentList& args, |
| 223 CppVariant* result) { | 224 CppVariant* result) { |
| 224 if (args.size() < 1) { | 225 RenderThread::Get()->Send( |
| 225 NOTREACHED(); | 226 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); |
| 226 return; | |
| 227 } | |
| 228 if (!args[0].isString()) { | |
| 229 NOTREACHED(); | |
| 230 return; | |
| 231 } | |
| 232 | |
| 233 GURL url(args[0].ToString()); | |
| 234 WebURLRequest request; | |
| 235 request.initialize(); | |
| 236 request.setURL(url); | |
| 237 render_view()->LoadURLExternally( | |
| 238 frame(), request, WebKit::WebNavigationPolicyNewForegroundTab); | |
| 239 } | 227 } |
| 240 | 228 |
| 241 void BlockedPlugin::HidePlugin() { | 229 void BlockedPlugin::HidePlugin() { |
| 242 hidden_ = true; | 230 hidden_ = true; |
| 243 HidePluginInternal(); | 231 HidePluginInternal(); |
| 244 } | 232 } |
| OLD | NEW |