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/plugins/plugin_info_message_filter.h" | 5 #include "chrome/browser/plugins/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" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 &plugin_metadata)) { | 126 &plugin_metadata)) { |
127 context_.DecidePluginStatus(params, output.plugin, plugin_metadata.get(), | 127 context_.DecidePluginStatus(params, output.plugin, plugin_metadata.get(), |
128 &output.status); | 128 &output.status); |
129 } | 129 } |
130 | 130 |
131 if (plugin_metadata) { | 131 if (plugin_metadata) { |
132 output.group_identifier = plugin_metadata->identifier(); | 132 output.group_identifier = plugin_metadata->identifier(); |
133 output.group_name = plugin_metadata->name(); | 133 output.group_name = plugin_metadata->name(); |
134 } | 134 } |
135 | 135 |
136 context_.GrantAccess(output.status, output.plugin.path); | 136 context_.MaybeGrantAccess(output.status, output.plugin.path); |
137 | 137 |
138 ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output); | 138 ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output); |
139 Send(reply_msg); | 139 Send(reply_msg); |
140 } | 140 } |
141 | 141 |
142 void PluginInfoMessageFilter::Context::DecidePluginStatus( | 142 void PluginInfoMessageFilter::Context::DecidePluginStatus( |
143 const GetPluginInfo_Params& params, | 143 const GetPluginInfo_Params& params, |
144 const WebPluginInfo& plugin, | 144 const WebPluginInfo& plugin, |
145 const PluginMetadata* plugin_metadata, | 145 const PluginMetadata* plugin_metadata, |
146 ChromeViewHostMsg_GetPluginInfo_Status* status) const { | 146 ChromeViewHostMsg_GetPluginInfo_Status* status) const { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 url, mime_type, allow_wildcard, &matching_plugins, &mime_types); | 221 url, mime_type, allow_wildcard, &matching_plugins, &mime_types); |
222 if (matching_plugins.empty()) { | 222 if (matching_plugins.empty()) { |
223 status->value = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; | 223 status->value = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; |
224 return false; | 224 return false; |
225 } | 225 } |
226 | 226 |
227 content::PluginServiceFilter* filter = | 227 content::PluginServiceFilter* filter = |
228 PluginService::GetInstance()->GetFilter(); | 228 PluginService::GetInstance()->GetFilter(); |
229 size_t i = 0; | 229 size_t i = 0; |
230 for (; i < matching_plugins.size(); ++i) { | 230 for (; i < matching_plugins.size(); ++i) { |
231 if (!filter || filter->IsPluginEnabled(render_process_id_, | 231 if (!filter || filter->IsPluginAvailable(render_process_id_, |
232 render_view_id, | 232 render_view_id, |
233 resource_context_, | 233 resource_context_, |
234 url, | 234 url, |
235 top_origin_url, | 235 top_origin_url, |
236 &matching_plugins[i])) { | 236 &matching_plugins[i])) { |
237 break; | 237 break; |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 // 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. |
242 bool enabled = i < matching_plugins.size(); | 242 bool enabled = i < matching_plugins.size(); |
243 if (!enabled) { | 243 if (!enabled) { |
244 // Otherwise, we only found disabled plug-ins, so we take the first one. | 244 // Otherwise, we only found disabled plug-ins, so we take the first one. |
245 i = 0; | 245 i = 0; |
246 status->value = ChromeViewHostMsg_GetPluginInfo_Status::kDisabled; | 246 status->value = ChromeViewHostMsg_GetPluginInfo_Status::kDisabled; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 &info)); | 286 &info)); |
287 } | 287 } |
288 } | 288 } |
289 *setting = content_settings::ValueToContentSetting(value.get()); | 289 *setting = content_settings::ValueToContentSetting(value.get()); |
290 *uses_default_content_setting = | 290 *uses_default_content_setting = |
291 !uses_plugin_specific_setting && | 291 !uses_plugin_specific_setting && |
292 info.primary_pattern == ContentSettingsPattern::Wildcard() && | 292 info.primary_pattern == ContentSettingsPattern::Wildcard() && |
293 info.secondary_pattern == ContentSettingsPattern::Wildcard(); | 293 info.secondary_pattern == ContentSettingsPattern::Wildcard(); |
294 } | 294 } |
295 | 295 |
296 void PluginInfoMessageFilter::Context::GrantAccess( | 296 void PluginInfoMessageFilter::Context::MaybeGrantAccess( |
297 const ChromeViewHostMsg_GetPluginInfo_Status& status, | 297 const ChromeViewHostMsg_GetPluginInfo_Status& status, |
298 const FilePath& path) const { | 298 const FilePath& path) const { |
299 if (status.value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed || | 299 if (status.value == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed || |
300 status.value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay) { | 300 status.value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay) { |
301 ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( | 301 ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( |
302 render_process_id_, path); | 302 render_process_id_, path); |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
OLD | NEW |