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/browser/renderer_host/plugin_info_message_filter.h" | 5 #include "chrome/browser/renderer_host/plugin_info_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/chrome_plugin_service_filter.h" |
11 #include "chrome/browser/content_settings/content_settings_utils.h" | 12 #include "chrome/browser/content_settings/content_settings_utils.h" |
12 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
13 #include "chrome/browser/plugins/plugin_finder.h" | 14 #include "chrome/browser/plugins/plugin_finder.h" |
14 #include "chrome/browser/plugins/plugin_metadata.h" | 15 #include "chrome/browser/plugins/plugin_metadata.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
18 #include "chrome/common/content_settings.h" | 19 #include "chrome/common/content_settings.h" |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 &plugin_metadata)) { | 126 &plugin_metadata)) { |
126 context_.DecidePluginStatus(params, output.plugin, plugin_metadata.get(), | 127 context_.DecidePluginStatus(params, output.plugin, plugin_metadata.get(), |
127 &output.status); | 128 &output.status); |
128 } | 129 } |
129 | 130 |
130 if (plugin_metadata) { | 131 if (plugin_metadata) { |
131 output.group_identifier = plugin_metadata->identifier(); | 132 output.group_identifier = plugin_metadata->identifier(); |
132 output.group_name = plugin_metadata->name(); | 133 output.group_name = plugin_metadata->name(); |
133 } | 134 } |
134 | 135 |
| 136 context_.GrantAccess(output.status, output.plugin.path); |
| 137 |
135 ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output); | 138 ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output); |
136 Send(reply_msg); | 139 Send(reply_msg); |
137 } | 140 } |
138 | 141 |
139 void PluginInfoMessageFilter::Context::DecidePluginStatus( | 142 void PluginInfoMessageFilter::Context::DecidePluginStatus( |
140 const GetPluginInfo_Params& params, | 143 const GetPluginInfo_Params& params, |
141 const WebPluginInfo& plugin, | 144 const WebPluginInfo& plugin, |
142 const PluginMetadata* plugin_metadata, | 145 const PluginMetadata* plugin_metadata, |
143 ChromeViewHostMsg_GetPluginInfo_Status* status) const { | 146 ChromeViewHostMsg_GetPluginInfo_Status* status) const { |
144 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 url, mime_type, allow_wildcard, &matching_plugins, &mime_types); | 221 url, mime_type, allow_wildcard, &matching_plugins, &mime_types); |
219 if (matching_plugins.empty()) { | 222 if (matching_plugins.empty()) { |
220 status->value = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; | 223 status->value = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; |
221 return false; | 224 return false; |
222 } | 225 } |
223 | 226 |
224 content::PluginServiceFilter* filter = | 227 content::PluginServiceFilter* filter = |
225 PluginService::GetInstance()->GetFilter(); | 228 PluginService::GetInstance()->GetFilter(); |
226 size_t i = 0; | 229 size_t i = 0; |
227 for (; i < matching_plugins.size(); ++i) { | 230 for (; i < matching_plugins.size(); ++i) { |
228 if (!filter || filter->ShouldUsePlugin(render_process_id_, | 231 if (!filter || filter->IsPluginEnabled(render_process_id_, |
229 render_view_id, | 232 render_view_id, |
230 resource_context_, | 233 resource_context_, |
231 url, | 234 url, |
232 top_origin_url, | 235 top_origin_url, |
233 &matching_plugins[i])) { | 236 &matching_plugins[i])) { |
234 break; | 237 break; |
235 } | 238 } |
236 } | 239 } |
237 | 240 |
238 // If we broke out of the loop, we have found an enabled plug-in. | 241 // If we broke out of the loop, we have found an enabled plug-in. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), | 285 policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), |
283 &info)); | 286 &info)); |
284 } | 287 } |
285 } | 288 } |
286 *setting = content_settings::ValueToContentSetting(value.get()); | 289 *setting = content_settings::ValueToContentSetting(value.get()); |
287 *uses_default_content_setting = | 290 *uses_default_content_setting = |
288 !uses_plugin_specific_setting && | 291 !uses_plugin_specific_setting && |
289 info.primary_pattern == ContentSettingsPattern::Wildcard() && | 292 info.primary_pattern == ContentSettingsPattern::Wildcard() && |
290 info.secondary_pattern == ContentSettingsPattern::Wildcard(); | 293 info.secondary_pattern == ContentSettingsPattern::Wildcard(); |
291 } | 294 } |
| 295 |
| 296 void PluginInfoMessageFilter::Context::GrantAccess( |
| 297 const ChromeViewHostMsg_GetPluginInfo_Status& status, |
| 298 const FilePath& path) const { |
| 299 if (status.value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed || |
| 300 status.value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay) { |
| 301 ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( |
| 302 render_process_id_, path); |
| 303 } |
| 304 } |
| 305 |
OLD | NEW |