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

Unified Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 7990005: Use a placeholder instead of the default plugin for missing plug-ins on Mac and Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 3 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
Index: chrome/renderer/chrome_content_renderer_client.cc
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 88d41cf849ca5ab2506faad688bf19bb31e24276..d81e81311ab2b310f6ca87a31a45d6bf4dacfb7a 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -266,41 +266,45 @@ 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();
- std::string actual_mime_type;
-
- bool found = render_view->GetPluginInfo(
- url, frame->top()->document().url(), orig_mime_type, &info,
- &actual_mime_type);
+ ChromeViewHostMsg_GetPluginInfo_Params plugin_params;
+ render_view->Send(new ChromeViewHostMsg_GetPluginInfo(
+ render_view->routing_id(), url, frame->top()->document().url(),
+ orig_mime_type, &plugin_params));
- if (!found)
- return NULL;
+ if (plugin_params.status ==
+ 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 (plugin_params.status ==
+ 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_params.plugin.path.value() ==
+ webkit::npapi::kDefaultPluginLibraryName) {
+ MissingPluginReporter::GetInstance()->ReportPluginMissing(
+ orig_mime_type, url);
+ }
- if (orig_mime_type == actual_mime_type) {
+ if (orig_mime_type == plugin_params.actual_mime_type) {
UMA_HISTOGRAM_ENUMERATION(kPluginTypeMismatch,
PLUGIN_TYPE_MISMATCH_NONE,
PLUGIN_TYPE_MISMATCH_NUM_EVENTS);
@@ -326,7 +330,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
}
scoped_ptr<webkit::npapi::PluginGroup> group(
- webkit::npapi::PluginList::Singleton()->GetPluginGroup(info));
+ webkit::npapi::PluginList::Singleton()->GetPluginGroup(
+ plugin_params.plugin));
ContentSettingsType content_type = CONTENT_SETTINGS_TYPE_PLUGINS;
ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
@@ -338,10 +343,11 @@ 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_params.plugin.mime_types.size(); ++i) {
+ if (plugin_params.plugin.mime_types[i].mime_type ==
+ plugin_params.actual_mime_type) {
+ AppendParams(plugin_params.plugin.mime_types[i].additional_param_names,
+ plugin_params.plugin.mime_types[i].additional_param_values,
&params.attributeNames,
&params.attributeValues);
break;
@@ -350,14 +356,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_params.plugin) ||
+ group->RequiresAuthorization(plugin_params.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_params.plugin)) {
if (outdated_policy == CONTENT_SETTING_ASK ||
outdated_policy == CONTENT_SETTING_BLOCK) {
if (outdated_policy == CONTENT_SETTING_ASK) {
@@ -366,7 +373,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);
@@ -377,7 +384,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
ContentSetting host_setting =
observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS);
- if (group->RequiresAuthorization(info) &&
+ if (group->RequiresAuthorization(plugin_params.plugin) &&
authorize_policy == CONTENT_SETTING_ASK &&
(plugin_setting == CONTENT_SETTING_ALLOW ||
plugin_setting == CONTENT_SETTING_ASK) &&
@@ -385,13 +392,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_params.plugin.name ==
+ ASCIIToUTF16(ChromeContentClient::kNaClPluginName);
if (is_nacl_plugin) {
content_type = CONTENT_SETTINGS_TYPE_JAVASCRIPT;
plugin_setting =
@@ -400,12 +407,13 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
if (plugin_setting == CONTENT_SETTING_ALLOW ||
host_setting == CONTENT_SETTING_ALLOW ||
- info.path.value() == webkit::npapi::kDefaultPluginLibraryName) {
+ plugin_params.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.
@@ -416,16 +424,17 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
const char* kNaClPluginManifestAttribute = "nacl";
GURL nexe_url;
- if (actual_mime_type == kNaClPluginMimeType) {
+ if (plugin_params.actual_mime_type == kNaClPluginMimeType) {
nexe_url = url; // Normal embedded NaCl plugin.
} else {
// 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_params.plugin.mime_types.size(); ++i) {
+ if (plugin_params.plugin.mime_types[i].mime_type ==
+ plugin_params.actual_mime_type) {
const webkit::WebPluginMimeType& content_type =
- info.mime_types[i];
+ plugin_params.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) {
@@ -453,7 +462,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);
}
}
@@ -461,29 +470,30 @@ 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_params.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_params.plugin.path, pepper_module.get());
}
return NULL;
}
return render_view->CreateNPAPIPlugin(
- frame, params, info.path, actual_mime_type);
+ frame, params, plugin_params.plugin.path,
+ plugin_params.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);
}
}
@@ -492,22 +502,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();
@@ -716,7 +734,6 @@ bool ChromeContentRendererClient::IsProtocolSupportedForMedia(
return url.SchemeIs(chrome::kExtensionScheme);
}
-
void ChromeContentRendererClient::SetExtensionDispatcher(
ExtensionDispatcher* extension_dispatcher) {
extension_dispatcher_.reset(extension_dispatcher);

Powered by Google App Engine
This is Rietveld 408576698