summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/default_plugin_uitest.cc7
-rw-r--r--chrome/browser/renderer_host/chrome_render_message_filter.cc98
-rw-r--r--chrome/browser/renderer_host/chrome_render_message_filter.h26
-rw-r--r--chrome/common/default_plugin.cc7
-rw-r--r--chrome/common/render_messages.h35
-rw-r--r--chrome/renderer/blocked_plugin.cc31
-rw-r--r--chrome/renderer/blocked_plugin.h2
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc116
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h5
-rw-r--r--content/browser/plugin_service.cc12
-rw-r--r--content/browser/plugin_service.h12
-rw-r--r--content/common/view_messages.h21
-rw-r--r--content/common/webkit_param_traits.cc64
-rw-r--r--content/common/webkit_param_traits.h17
-rw-r--r--ipc/ipc_message_utils.h31
16 files changed, 391 insertions, 96 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 1f617c5..fa77a13 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4728,6 +4728,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_PLUGIN_NOT_AUTHORIZED" desc="The placeholder text for a plug-in that requires user permission to run.">
The <ph name="PLUGIN_NAME">$1<ex>Java</ex></ph> plug-in needs your permission to run.
</message>
+ <message name="IDS_PLUGIN_NOT_FOUND" desc="The placeholder text for a plug-in that is not installed.">
+ No plug-in available to display this content.
+ </message>
<!-- Session Crashed Info Bar-->
<message name="IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON" desc="Title of the restore button in the session crashed view.">
diff --git a/chrome/browser/default_plugin_uitest.cc b/chrome/browser/default_plugin_uitest.cc
index 5c61531..e0edc6e 100644
--- a/chrome/browser/default_plugin_uitest.cc
+++ b/chrome/browser/default_plugin_uitest.cc
@@ -17,11 +17,7 @@ class DefaultPluginUITest : public UITest {
};
#if defined(OS_WIN)
-#define MAYBE_DefaultPluginLoadTest DefaultPluginLoadTest
-#else
-#define MAYBE_DefaultPluginLoadTest DefaultPluginLoadTest
-#endif
-TEST_F(DefaultPluginUITest, MAYBE_DefaultPluginLoadTest) {
+TEST_F(DefaultPluginUITest, DefaultPluginLoadTest) {
// Open page with default plugin.
FilePath test_file(test_data_directory_);
test_file = test_file.AppendASCII("default_plugin.html");
@@ -36,3 +32,4 @@ TEST_F(DefaultPluginUITest, MAYBE_DefaultPluginLoadTest) {
L"document.getElementById('result').innerHTML)", &out));
ASSERT_EQ(L"DONE", out);
}
+#endif
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index 0b15023..ef3b3e1 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/automation/automation_resource_message_filter.h"
@@ -26,12 +27,15 @@
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
+#include "content/browser/plugin_service.h"
+#include "content/browser/plugin_service_filter.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "webkit/plugins/npapi/plugin_list.h"
#if defined(USE_TCMALLOC)
#include "chrome/browser/browser_about_handler.h"
@@ -83,6 +87,7 @@ ChromeRenderMessageFilter::ChromeRenderMessageFilter(
profile_(profile),
request_context_(request_context),
extension_info_map_(profile->GetExtensionInfoMap()),
+ resource_context_(profile->GetResourceContext()),
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated,
profile_->GetPrefs(), NULL);
@@ -134,6 +139,8 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetPluginContentSetting,
OnGetPluginContentSetting)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetPluginInfo,
+ OnGetPluginInfo)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardRead,
OnCanTriggerClipboardRead)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardWrite,
@@ -491,6 +498,97 @@ void ChromeRenderMessageFilter::OnGetPluginContentSetting(
resource);
}
+struct ChromeRenderMessageFilter::GetPluginInfo_Params {
+ int render_view_id;
+ GURL url;
+ GURL top_origin_url;
+ std::string mime_type;
+};
+
+void ChromeRenderMessageFilter::OnGetPluginInfo(
+ int render_view_id,
+ const GURL& url,
+ const GURL& top_origin_url,
+ const std::string& mime_type,
+ IPC::Message* reply_msg) {
+ GetPluginInfo_Params params = {
+ render_view_id,
+ url,
+ top_origin_url,
+ mime_type
+ };
+ PluginService::GetInstance()->GetPlugins(
+ base::Bind(&ChromeRenderMessageFilter::PluginsLoaded, this,
+ params, reply_msg));
+}
+
+void ChromeRenderMessageFilter::PluginsLoaded(
+ const GetPluginInfo_Params& params,
+ IPC::Message* reply_msg,
+ const std::vector<webkit::WebPluginInfo>& plugins) {
+ ChromeViewHostMsg_GetPluginInfo_Status status;
+ webkit::WebPluginInfo plugin;
+ std::string actual_mime_type;
+ GetPluginInfo(params.render_view_id, params.url, params.top_origin_url,
+ params.mime_type, &status, &plugin, &actual_mime_type);
+ ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(
+ reply_msg, status, plugin, actual_mime_type);
+ Send(reply_msg);
+}
+
+void ChromeRenderMessageFilter::GetPluginInfo(
+ int render_view_id,
+ const GURL& url,
+ const GURL& top_origin_url,
+ const std::string& mime_type,
+ ChromeViewHostMsg_GetPluginInfo_Status* status,
+ webkit::WebPluginInfo* plugin,
+ std::string* actual_mime_type) {
+ bool allow_wildcard = true;
+ std::vector<webkit::WebPluginInfo> matching_plugins;
+ std::vector<std::string> mime_types;
+ PluginService::GetInstance()->GetPluginInfoArray(
+ url, mime_type, allow_wildcard, &matching_plugins, &mime_types);
+ if (matching_plugins.empty()) {
+ status->value = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound;
+ return;
+ }
+
+ if (matching_plugins.size() > 1 &&
+ matching_plugins.back().path ==
+ FilePath(webkit::npapi::kDefaultPluginLibraryName)) {
+ // If there is at least one plug-in handling the required MIME type (apart
+ // from the default plug-in), we don't need the default plug-in.
+ matching_plugins.pop_back();
+ }
+
+ content::PluginServiceFilter* filter = PluginService::GetInstance()->filter();
+ bool allowed = false;
+ for (size_t i = 0; i < matching_plugins.size(); ++i) {
+ if (!filter || filter->ShouldUsePlugin(render_process_id_,
+ render_view_id,
+ &resource_context_,
+ url,
+ top_origin_url,
+ &matching_plugins[i])) {
+ *plugin = matching_plugins[i];
+ *actual_mime_type = mime_types[i];
+ allowed = true;
+ break;
+ } else if (i == 0) {
+ *plugin = matching_plugins[i];
+ *actual_mime_type = mime_types[i];
+ }
+ }
+
+ if (!allowed) {
+ status->value = ChromeViewHostMsg_GetPluginInfo_Status::kDisabled;
+ return;
+ }
+
+ status->value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
+}
+
void ChromeRenderMessageFilter::OnCanTriggerClipboardRead(const GURL& url,
bool* allowed) {
const Extension* extension =
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h
index adfcf44..d84d9be 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.h
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.h
@@ -14,6 +14,7 @@
#include "content/common/dom_storage_common.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
+struct ChromeViewHostMsg_GetPluginInfo_Status;
struct ExtensionHostMsg_Request_Params;
class ExtensionInfoMap;
class FilePath;
@@ -24,6 +25,10 @@ namespace net {
class URLRequestContextGetter;
}
+namespace webkit {
+struct WebPluginInfo;
+}
+
// This class filters out incoming Chrome-specific IPC messages for the renderer
// process on the IPC thread.
class ChromeRenderMessageFilter : public BrowserMessageFilter {
@@ -43,6 +48,8 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter {
friend class BrowserThread;
friend class DeleteTask<ChromeRenderMessageFilter>;
+ struct GetPluginInfo_Params;
+
virtual ~ChromeRenderMessageFilter();
void OnLaunchNaCl(const std::wstring& url,
@@ -117,6 +124,23 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter {
void OnGetPluginContentSetting(const GURL& policy_url,
const std::string& resource,
ContentSetting* setting);
+ void OnGetPluginInfo(int render_view_id,
+ const GURL& url,
+ const GURL& top_origin_url,
+ const std::string& mime_type,
+ IPC::Message* reply_msg);
+ // |params| wraps the parameters passed to |OnGetPluginInfo|, because
+ // |base::Bind| doesn't support the required arity <http://crbug.com/98542>.
+ void PluginsLoaded(const GetPluginInfo_Params& params,
+ IPC::Message* reply_msg,
+ const std::vector<webkit::WebPluginInfo>& plugins);
+ void GetPluginInfo(int render_view_id,
+ const GURL& url,
+ const GURL& top_origin_url,
+ const std::string& mime_type,
+ ChromeViewHostMsg_GetPluginInfo_Status* status,
+ webkit::WebPluginInfo* plugin,
+ std::string* actual_mime_type);
void OnCanTriggerClipboardRead(const GURL& url, bool* allowed);
void OnCanTriggerClipboardWrite(const GURL& url, bool* allowed);
void OnGetCookies(const GURL& url,
@@ -137,6 +161,8 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter {
// Used to look up permissions at database creation time.
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
+ const content::ResourceContext& resource_context_;
+
BooleanPrefMember allow_outdated_plugins_;
BooleanPrefMember always_authorize_plugins_;
diff --git a/chrome/common/default_plugin.cc b/chrome/common/default_plugin.cc
index 61bbc87..4acc6b7 100644
--- a/chrome/common/default_plugin.cc
+++ b/chrome/common/default_plugin.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -10,6 +10,10 @@
namespace chrome {
void RegisterInternalDefaultPlugin() {
+#if defined(OS_WIN)
+ // TODO(bauerb): On Windows the default plug-in can download and install
+ // missing plug-ins, which we don't support in the browser yet, so keep
+ // using the default plug-in on Windows until we do.
const webkit::npapi::PluginEntryPoints entry_points = {
#if !defined(OS_POSIX) || defined(OS_MACOSX)
default_plugin::NP_GetEntryPoints,
@@ -24,6 +28,7 @@ void RegisterInternalDefaultPlugin() {
"Provides functionality for installing third-party plug-ins",
"*",
entry_points);
+#endif // defined OS(WIN)
}
} // namespace chrome
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 6bd830a..7e09b6e 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -25,6 +25,7 @@
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/translate_errors.h"
#include "content/common/common_param_traits.h"
+#include "content/common/webkit_param_traits.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -50,6 +51,22 @@ enum ViewHostMsg_JavaScriptStressTestControl_Commands {
kJavaScriptStressTestPrepareStressRun = 1,
};
+// This enum is inside a struct so that we can forward-declare the struct in
+// others headers without having to include this one.
+struct ChromeViewHostMsg_GetPluginInfo_Status {
+ // TODO(bauerb): Add more status values (blocked, click-to-play, out of date,
+ // requires authorization).
+ enum Value {
+ kAllowed,
+ kDisabled,
+ kNotFound,
+ };
+
+ ChromeViewHostMsg_GetPluginInfo_Status() : value(kAllowed) {}
+
+ Value value;
+};
+
namespace IPC {
#if defined(OS_POSIX) && !defined(USE_AURA)
@@ -91,12 +108,17 @@ struct ParamTraits<ContentSettings> {
#define IPC_MESSAGE_START ChromeMsgStart
+IPC_ENUM_TRAITS(ChromeViewHostMsg_GetPluginInfo_Status::Value)
IPC_ENUM_TRAITS(InstantCompleteBehavior)
IPC_ENUM_TRAITS(search_provider::OSDDType)
IPC_ENUM_TRAITS(search_provider::InstallState)
IPC_ENUM_TRAITS(TranslateErrors::Type)
IPC_ENUM_TRAITS(WebKit::WebConsoleMessage::Level)
+IPC_STRUCT_TRAITS_BEGIN(ChromeViewHostMsg_GetPluginInfo_Status)
+IPC_STRUCT_TRAITS_MEMBER(value)
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(ThumbnailScore)
IPC_STRUCT_TRAITS_MEMBER(boring_score)
IPC_STRUCT_TRAITS_MEMBER(good_clipping)
@@ -384,6 +406,19 @@ IPC_SYNC_MESSAGE_CONTROL2_1(ChromeViewHostMsg_GetPluginContentSetting,
std::string /* resource */,
ContentSetting /* setting */)
+// Return information about a plugin for the given URL and MIME type.
+// In contrast to ViewHostMsg_GetPluginInfo in content/, this IPC call knows
+// about specific reasons why a plug-in can't be used, for example because it's
+// disabled.
+IPC_SYNC_MESSAGE_CONTROL4_3(ChromeViewHostMsg_GetPluginInfo,
+ int /* render_view_id */,
+ GURL /* url */,
+ GURL /* top origin url */,
+ std::string /* mime_type */,
+ ChromeViewHostMsg_GetPluginInfo_Status /* status */,
+ webkit::WebPluginInfo /* plugin */,
+ std::string /* actual_mime_type */)
+
// Specifies the URL as the first parameter (a wstring) and thumbnail as
// binary data as the second parameter.
IPC_MESSAGE_ROUTED3(ChromeViewHostMsg_Thumbnail,
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc
index 1a6a750..4582c8e 100644
--- a/chrome/renderer/blocked_plugin.cc
+++ b/chrome/renderer/blocked_plugin.cc
@@ -56,16 +56,17 @@ static const BlockedPlugin* g_last_active_menu;
BlockedPlugin::BlockedPlugin(RenderView* render_view,
WebFrame* frame,
- const webkit::npapi::PluginGroup& info,
const WebPluginParams& params,
const WebPreferences& preferences,
int template_id,
+ const string16& name,
const string16& message,
bool is_blocked_for_prerendering,
bool allow_loading)
: content::RenderViewObserver(render_view),
frame_(frame),
plugin_params_(params),
+ name_(name),
is_blocked_for_prerendering_(is_blocked_for_prerendering),
hidden_(false),
allow_loading_(allow_loading) {
@@ -77,7 +78,6 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view,
DictionaryValue values;
values.SetString("message", message);
- name_ = info.GetGroupName();
values.SetString("name", name_);
values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE));
@@ -106,17 +106,22 @@ void BlockedPlugin::WillDestroyPlugin() {
void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) {
WebContextMenuData menu_data;
- WebVector<WebMenuItemInfo> custom_items(static_cast<size_t>(4));
- WebMenuItemInfo name_item;
- name_item.label = name_;
- name_item.hasTextDirectionOverride = false;
- name_item.textDirection = WebKit::WebTextDirectionDefault;
- custom_items[0] = name_item;
+ size_t num_items = name_.empty() ? 2u : 4u;
+ WebVector<WebMenuItemInfo> custom_items(num_items);
- WebMenuItemInfo separator_item;
- separator_item.type = WebMenuItemInfo::Separator;
- custom_items[1] = separator_item;
+ size_t i = 0;
+ if (!name_.empty()) {
+ WebMenuItemInfo name_item;
+ name_item.label = name_;
+ name_item.hasTextDirectionOverride = false;
+ name_item.textDirection = WebKit::WebTextDirectionDefault;
+ custom_items[i++] = name_item;
+
+ WebMenuItemInfo separator_item;
+ separator_item.type = WebMenuItemInfo::Separator;
+ custom_items[i++] = separator_item;
+ }
WebMenuItemInfo run_item;
run_item.action = kMenuActionLoad;
@@ -126,7 +131,7 @@ void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) {
l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_RUN).c_str());
run_item.hasTextDirectionOverride = false;
run_item.textDirection = WebKit::WebTextDirectionDefault;
- custom_items[2] = run_item;
+ custom_items[i++] = run_item;
WebMenuItemInfo hide_item;
hide_item.action = kMenuActionRemove;
@@ -135,7 +140,7 @@ void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) {
l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_HIDE).c_str());
hide_item.hasTextDirectionOverride = false;
hide_item.textDirection = WebKit::WebTextDirectionDefault;
- custom_items[3] = hide_item;
+ custom_items[i++] = hide_item;
menu_data.customItems.swap(custom_items);
menu_data.mousePosition = WebPoint(event.windowX, event.windowY);
diff --git a/chrome/renderer/blocked_plugin.h b/chrome/renderer/blocked_plugin.h
index 0d94f16..26f2c7f 100644
--- a/chrome/renderer/blocked_plugin.h
+++ b/chrome/renderer/blocked_plugin.h
@@ -29,10 +29,10 @@ class BlockedPlugin : public content::RenderViewObserver,
public:
BlockedPlugin(RenderView* render_view,
WebKit::WebFrame* frame,
- const webkit::npapi::PluginGroup& info,
const WebKit::WebPluginParams& params,
const WebPreferences& settings,
int template_id,
+ const string16& name,
const string16& message,
bool is_blocked_for_prerendering,
bool allow_loading);
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 9ec1ceb..a92ad3b 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -267,39 +267,43 @@ std::string ChromeContentRendererClient::GetDefaultEncoding() {
}
bool ChromeContentRendererClient::OverrideCreatePlugin(
- RenderView* render_view,
- WebFrame* frame,
- const WebPluginParams& params,
- WebKit::WebPlugin** plugin) {
- bool is_default_plugin;
- *plugin = CreatePlugin(render_view, frame, params, &is_default_plugin);
- if (!*plugin || is_default_plugin)
- MissingPluginReporter::GetInstance()->ReportPluginMissing(
- params.mimeType.utf8(), params.url);
+ RenderView* render_view,
+ WebFrame* frame,
+ const WebPluginParams& params,
+ WebKit::WebPlugin** plugin) {
+ *plugin = CreatePlugin(render_view, frame, params);
return true;
}
WebPlugin* ChromeContentRendererClient::CreatePlugin(
- RenderView* render_view,
- WebFrame* frame,
- const WebPluginParams& original_params,
- bool* is_default_plugin) {
- *is_default_plugin = false;
+ RenderView* render_view,
+ WebFrame* frame,
+ const WebPluginParams& original_params) {
CommandLine* cmd = CommandLine::ForCurrentProcess();
- webkit::WebPluginInfo info;
GURL url(original_params.url);
std::string orig_mime_type = original_params.mimeType.utf8();
+ ChromeViewHostMsg_GetPluginInfo_Status status;
+ webkit::WebPluginInfo plugin;
std::string actual_mime_type;
+ render_view->Send(new ChromeViewHostMsg_GetPluginInfo(
+ render_view->routing_id(), url, frame->top()->document().url(),
+ orig_mime_type, &status, &plugin, &actual_mime_type));
- bool found = render_view->GetPluginInfo(
- url, frame->top()->document().url(), orig_mime_type, &info,
- &actual_mime_type);
-
- if (!found)
- return NULL;
+ if (status.value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) {
+ MissingPluginReporter::GetInstance()->ReportPluginMissing(
+ orig_mime_type, url);
+ return CreatePluginPlaceholder(
+ render_view, frame, original_params, NULL, IDR_BLOCKED_PLUGIN_HTML,
+ IDS_PLUGIN_NOT_FOUND, false, false);
+ } else if (status.value ==
+ ChromeViewHostMsg_GetPluginInfo_Status::kDisabled) {
+ return NULL; // TODO(bauerb): Show a placeholder for a disabled plug-in.
+ }
- *is_default_plugin =
- info.path.value() == webkit::npapi::kDefaultPluginLibraryName;
+ if (plugin.path.value() == webkit::npapi::kDefaultPluginLibraryName) {
+ MissingPluginReporter::GetInstance()->ReportPluginMissing(
+ orig_mime_type, url);
+ }
if (orig_mime_type == actual_mime_type) {
UMA_HISTOGRAM_ENUMERATION(kPluginTypeMismatch,
@@ -327,7 +331,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
}
scoped_ptr<webkit::npapi::PluginGroup> group(
- webkit::npapi::PluginList::Singleton()->GetPluginGroup(info));
+ webkit::npapi::PluginList::Singleton()->GetPluginGroup(plugin));
ContentSettingsType content_type = CONTENT_SETTINGS_TYPE_PLUGINS;
ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
@@ -339,10 +343,10 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
WebPluginParams params(original_params);
- for (size_t i = 0; i < info.mime_types.size(); ++i) {
- if (info.mime_types[i].mime_type == actual_mime_type) {
- AppendParams(info.mime_types[i].additional_param_names,
- info.mime_types[i].additional_param_values,
+ for (size_t i = 0; i < plugin.mime_types.size(); ++i) {
+ if (plugin.mime_types[i].mime_type == actual_mime_type) {
+ AppendParams(plugin.mime_types[i].additional_param_names,
+ plugin.mime_types[i].additional_param_values,
&params.attributeNames,
&params.attributeValues);
break;
@@ -351,14 +355,15 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
ContentSetting outdated_policy = CONTENT_SETTING_ASK;
ContentSetting authorize_policy = CONTENT_SETTING_ASK;
- if (group->IsVulnerable(info) || group->RequiresAuthorization(info)) {
+ if (group->IsVulnerable(plugin) ||
+ group->RequiresAuthorization(plugin)) {
// These policies are dynamic and can changed at runtime, so they aren't
// cached here.
render_view->Send(new ChromeViewHostMsg_GetPluginPolicies(
&outdated_policy, &authorize_policy));
}
- if (group->IsVulnerable(info)) {
+ if (group->IsVulnerable(plugin)) {
if (outdated_policy == CONTENT_SETTING_ASK ||
outdated_policy == CONTENT_SETTING_BLOCK) {
if (outdated_policy == CONTENT_SETTING_ASK) {
@@ -367,7 +372,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
GURL(group->GetUpdateURL())));
}
return CreatePluginPlaceholder(
- render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML,
+ render_view, frame, params, group.get(), IDR_BLOCKED_PLUGIN_HTML,
IDS_PLUGIN_OUTDATED, false, outdated_policy == CONTENT_SETTING_ASK);
} else {
DCHECK(outdated_policy == CONTENT_SETTING_ALLOW);
@@ -378,7 +383,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
ContentSetting host_setting =
observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS);
- if (group->RequiresAuthorization(info) &&
+ if (group->RequiresAuthorization(plugin) &&
authorize_policy == CONTENT_SETTING_ASK &&
(plugin_setting == CONTENT_SETTING_ALLOW ||
plugin_setting == CONTENT_SETTING_ASK) &&
@@ -386,13 +391,13 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin(
render_view->routing_id(), group->GetGroupName(), GURL()));
return CreatePluginPlaceholder(
- render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML,
+ render_view, frame, params, group.get(), IDR_BLOCKED_PLUGIN_HTML,
IDS_PLUGIN_NOT_AUTHORIZED, false, true);
}
// Treat Native Client invocations like Javascript.
- bool is_nacl_plugin =
- info.name == ASCIIToUTF16(ChromeContentClient::kNaClPluginName);
+ bool is_nacl_plugin = plugin.name ==
+ ASCIIToUTF16(ChromeContentClient::kNaClPluginName);
if (is_nacl_plugin) {
content_type = CONTENT_SETTINGS_TYPE_JAVASCRIPT;
plugin_setting =
@@ -401,12 +406,12 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
if (plugin_setting == CONTENT_SETTING_ALLOW ||
host_setting == CONTENT_SETTING_ALLOW ||
- info.path.value() == webkit::npapi::kDefaultPluginLibraryName) {
+ plugin.path.value() == webkit::npapi::kDefaultPluginLibraryName) {
// Delay loading plugins if prerendering.
if (prerender::PrerenderHelper::IsPrerendering(render_view)) {
return CreatePluginPlaceholder(
- render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML,
- IDS_PLUGIN_LOAD, true, true);
+ render_view, frame, params, group.get(),
+ IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD, true, true);
}
// Enforce the Chrome WebStore restriction on the Native Client plugin.
@@ -423,10 +428,10 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
// Content type handling NaCl plugin; the "nacl" param on the
// MIME type holds the nexe URL.
string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute);
- for (size_t i = 0; i < info.mime_types.size(); ++i) {
- if (info.mime_types[i].mime_type == actual_mime_type) {
+ for (size_t i = 0; i < plugin.mime_types.size(); ++i) {
+ if (plugin.mime_types[i].mime_type == actual_mime_type) {
const webkit::WebPluginMimeType& content_type =
- info.mime_types[i];
+ plugin.mime_types[i];
for (size_t i = 0;
i < content_type.additional_param_names.size(); ++i) {
if (content_type.additional_param_names[i] == nacl_attr) {
@@ -454,7 +459,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
// TODO(bbudge) Webkit will crash if this is a full-frame plug-in and
// we return NULL. Prepare a patch to fix that, and return NULL here.
return CreatePluginPlaceholder(
- render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML,
+ render_view, frame, params, group.get(), IDR_BLOCKED_PLUGIN_HTML,
IDS_PLUGIN_BLOCKED, false, false);
}
}
@@ -462,29 +467,29 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
bool pepper_plugin_was_registered = false;
scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
render_view->pepper_delegate()->CreatePepperPluginModule(
- info, &pepper_plugin_was_registered));
+ plugin, &pepper_plugin_was_registered));
if (pepper_plugin_was_registered) {
if (pepper_module) {
return render_view->CreatePepperPlugin(
- frame, params, info.path, pepper_module.get());
+ frame, params, plugin.path, pepper_module.get());
}
return NULL;
}
return render_view->CreateNPAPIPlugin(
- frame, params, info.path, actual_mime_type);
+ frame, params, plugin.path, actual_mime_type);
}
observer->DidBlockContentType(content_type, resource);
if (plugin_setting == CONTENT_SETTING_ASK) {
RenderThread::RecordUserMetrics("Plugin_ClickToPlay");
return CreatePluginPlaceholder(
- render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML,
+ render_view, frame, params, group.get(), IDR_CLICK_TO_PLAY_PLUGIN_HTML,
IDS_PLUGIN_LOAD, false, true);
} else {
RenderThread::RecordUserMetrics("Plugin_Blocked");
return CreatePluginPlaceholder(
- render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML,
+ render_view, frame, params, group.get(), IDR_BLOCKED_PLUGIN_HTML,
IDS_PLUGIN_BLOCKED, false, true);
}
}
@@ -493,22 +498,30 @@ WebPlugin* ChromeContentRendererClient::CreatePluginPlaceholder(
RenderView* render_view,
WebFrame* frame,
const WebPluginParams& params,
- const webkit::npapi::PluginGroup& group,
+ const webkit::npapi::PluginGroup* group,
int resource_id,
int message_id,
bool is_blocked_for_prerendering,
bool allow_loading) {
// |blocked_plugin| will delete itself when the WebViewPlugin
// is destroyed.
+ string16 name;
+ string16 message;
+ if (group) {
+ name = group->GetGroupName();
+ message = l10n_util::GetStringFUTF16(message_id, name);
+ } else {
+ message = l10n_util::GetStringUTF16(message_id);
+ }
+
BlockedPlugin* blocked_plugin =
new BlockedPlugin(render_view,
frame,
- group,
params,
render_view->webkit_preferences(),
resource_id,
- l10n_util::GetStringFUTF16(message_id,
- group.GetGroupName()),
+ name,
+ message,
is_blocked_for_prerendering,
allow_loading);
return blocked_plugin->plugin();
@@ -710,7 +723,6 @@ bool ChromeContentRendererClient::IsProtocolSupportedForMedia(
return url.SchemeIs(chrome::kExtensionScheme);
}
-
void ChromeContentRendererClient::SetExtensionDispatcher(
ExtensionDispatcher* extension_dispatcher) {
extension_dispatcher_.reset(extension_dispatcher);
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index 7931318..a3f39be 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -98,14 +98,13 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
WebKit::WebPlugin* CreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
- const WebKit::WebPluginParams& params,
- bool* is_default_plugin);
+ const WebKit::WebPluginParams& params);
WebKit::WebPlugin* CreatePluginPlaceholder(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params,
- const webkit::npapi::PluginGroup& group,
+ const webkit::npapi::PluginGroup* group,
int resource_id,
int message_id,
bool is_blocked_for_prerendering,
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index f6d61d6..8e62fbf 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -472,6 +472,18 @@ void PluginService::FinishOpenChannelToPlugin(
}
}
+bool PluginService::GetPluginInfoArray(
+ const GURL& url,
+ const std::string& mime_type,
+ bool allow_wildcard,
+ std::vector<webkit::WebPluginInfo>* plugins,
+ std::vector<std::string>* actual_mime_types) {
+ bool use_stale = false;
+ webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
+ url, mime_type, allow_wildcard, &use_stale, plugins, actual_mime_types);
+ return use_stale;
+}
+
bool PluginService::GetPluginInfo(int render_process_id,
int render_view_id,
const content::ResourceContext& context,
diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h
index 7060fc3..54c6e41 100644
--- a/content/browser/plugin_service.h
+++ b/content/browser/plugin_service.h
@@ -120,7 +120,17 @@ class CONTENT_EXPORT PluginService
void CancelOpenChannelToNpapiPlugin(PluginProcessHost::Client* client);
// Gets the plugin in the list of plugins that matches the given url and mime
- // type. Must be called on the FILE thread if |use_stale| is NULL.
+ // type. Returns true if the data is frome a stale plugin list, false if it
+ // is up to date. This can be called from any thread.
+ bool GetPluginInfoArray(const GURL& url,
+ const std::string& mime_type,
+ bool allow_wildcard,
+ std::vector<webkit::WebPluginInfo>* info,
+ std::vector<std::string>* actual_mime_types);
+
+ // Gets plugin info for an individual plugin and filters the plugins using
+ // the |context| and renderer IDs. This will report whether the data is stale
+ // via |is_stale| and returns whether or not the plugin can be found.
bool GetPluginInfo(int render_process_id,
int render_view_id,
const content::ResourceContext& context,
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index e41e445..0063cb0 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -39,7 +39,6 @@
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webaccessibility.h"
#include "webkit/plugins/npapi/webplugin.h"
-#include "webkit/plugins/webplugininfo.h"
#if defined(OS_MACOSX)
#include "content/common/mac/font_descriptor.h"
@@ -301,23 +300,6 @@ IPC_STRUCT_TRAITS_BEGIN(webkit::npapi::WebPluginGeometry)
IPC_STRUCT_TRAITS_MEMBER(visible)
IPC_STRUCT_TRAITS_END()
-IPC_STRUCT_TRAITS_BEGIN(webkit::WebPluginMimeType)
- IPC_STRUCT_TRAITS_MEMBER(mime_type)
- IPC_STRUCT_TRAITS_MEMBER(file_extensions)
- IPC_STRUCT_TRAITS_MEMBER(description)
- IPC_STRUCT_TRAITS_MEMBER(additional_param_names)
- IPC_STRUCT_TRAITS_MEMBER(additional_param_values)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(webkit::WebPluginInfo)
- IPC_STRUCT_TRAITS_MEMBER(name)
- IPC_STRUCT_TRAITS_MEMBER(path)
- IPC_STRUCT_TRAITS_MEMBER(version)
- IPC_STRUCT_TRAITS_MEMBER(desc)
- IPC_STRUCT_TRAITS_MEMBER(mime_types)
- IPC_STRUCT_TRAITS_MEMBER(type)
-IPC_STRUCT_TRAITS_END()
-
IPC_STRUCT_TRAITS_BEGIN(media::MediaLogEvent)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_MEMBER(type)
@@ -1478,8 +1460,7 @@ IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetPlugins,
// Return information about a plugin for the given URL and MIME
// type. If there is no matching plugin, |found| is false.
// |actual_mime_type| is the actual mime type supported by the
-// plugin found that match the URL given (one for each item in
-// |info|).
+// found plugin.
IPC_SYNC_MESSAGE_CONTROL4_3(ViewHostMsg_GetPluginInfo,
int /* routing_id */,
GURL /* url */,
diff --git a/content/common/webkit_param_traits.cc b/content/common/webkit_param_traits.cc
index 634e407..bed2f26 100644
--- a/content/common/webkit_param_traits.cc
+++ b/content/common/webkit_param_traits.cc
@@ -341,6 +341,70 @@ void ParamTraits<NPIdentifier_Param>::Log(const param_type& p, std::string* l) {
}
}
+void ParamTraits<webkit::WebPluginMimeType>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, p.mime_type);
+ WriteParam(m, p.file_extensions);
+ WriteParam(m, p.description);
+ WriteParam(m, p.additional_param_names);
+ WriteParam(m, p.additional_param_values);
+}
+
+bool ParamTraits<webkit::WebPluginMimeType>::Read(const Message* m,
+ void** iter,
+ param_type* p) {
+ return
+ ReadParam(m, iter, &p->mime_type) &&
+ ReadParam(m, iter, &p->file_extensions) &&
+ ReadParam(m, iter, &p->description) &&
+ ReadParam(m, iter, &p->additional_param_names) &&
+ ReadParam(m, iter, &p->additional_param_values);
+}
+
+void ParamTraits<webkit::WebPluginMimeType>::Log(
+ const param_type& p, std::string* l) {
+ l->append("(");
+ LogParam(p.mime_type, l); l->append(", ");
+ LogParam(p.file_extensions, l); l->append(", ");
+ LogParam(p.description, l); l->append(", ");
+ LogParam(p.additional_param_names, l); l->append(", ");
+ LogParam(p.additional_param_values, l);
+ l->append(")");
+}
+
+void ParamTraits<webkit::WebPluginInfo>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, p.name);
+ WriteParam(m, p.path);
+ WriteParam(m, p.version);
+ WriteParam(m, p.desc);
+ WriteParam(m, p.mime_types);
+ WriteParam(m, p.type);
+}
+
+bool ParamTraits<webkit::WebPluginInfo>::Read(const Message* m,
+ void** iter,
+ param_type* p) {
+ return
+ ReadParam(m, iter, &p->name) &&
+ ReadParam(m, iter, &p->path) &&
+ ReadParam(m, iter, &p->version) &&
+ ReadParam(m, iter, &p->desc) &&
+ ReadParam(m, iter, &p->mime_types) &&
+ ReadParam(m, iter, &p->type);
+}
+void ParamTraits<webkit::WebPluginInfo>::Log(const param_type& p,
+ std::string* l) {
+ l->append("(");
+ LogParam(p.name, l); l->append(", ");
+ LogParam(p.path, l); l->append(", ");
+ LogParam(p.version, l); l->append(", ");
+ LogParam(p.desc, l); l->append(", ");
+ LogParam(p.mime_types, l); l->append(", ");
+ LogParam(p.type, l);
+ l->append(")");
+}
+
void ParamTraits<webkit_glue::PasswordForm>::Write(Message* m,
const param_type& p) {
WriteParam(m, p.signon_realm);
diff --git a/content/common/webkit_param_traits.h b/content/common/webkit_param_traits.h
index 8fce34e..e6f8ed4 100644
--- a/content/common/webkit_param_traits.h
+++ b/content/common/webkit_param_traits.h
@@ -26,6 +26,7 @@
#include "webkit/glue/resource_type.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/window_open_disposition.h"
+#include "webkit/plugins/webplugininfo.h"
namespace webkit_glue {
struct PasswordForm;
@@ -113,6 +114,22 @@ struct ParamTraits<NPIdentifier_Param> {
};
template <>
+struct ParamTraits<webkit::WebPluginMimeType> {
+ typedef webkit::WebPluginMimeType param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template <>
+struct ParamTraits<webkit::WebPluginInfo> {
+ typedef webkit::WebPluginInfo param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template <>
struct ParamTraits<WebCursor> {
typedef WebCursor param_type;
static void Write(Message* m, const param_type& p) {
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 8a03069..91af787 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -497,6 +497,37 @@ struct ParamTraits<std::vector<char> > {
}
};
+template <>
+struct ParamTraits<std::vector<bool> > {
+ typedef std::vector<bool> param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, static_cast<int>(p.size()));
+ for (size_t i = 0; i < p.size(); i++)
+ WriteParam(m, p[i]);
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ int size;
+ // ReadLength() checks for < 0 itself.
+ if (!m->ReadLength(iter, &size))
+ return false;
+ r->resize(size);
+ for (int i = 0; i < size; i++) {
+ bool value;
+ if (!ReadParam(m, iter, &value))
+ return false;
+ (*r)[i] = value;
+ }
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ for (size_t i = 0; i < p.size(); ++i) {
+ if (i != 0)
+ l->append(" ");
+ LogParam((p[i]), l);
+ }
+ }
+};
+
template <class P>
struct ParamTraits<std::vector<P> > {
typedef std::vector<P> param_type;