OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/plugins/npapi/plugin_group.h" | 5 #include "webkit/plugins/npapi/plugin_group.h" |
6 | 6 |
7 #include "base/linked_ptr.h" | 7 #include "base/linked_ptr.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 policy_disabled_plugin_patterns_->begin()); | 39 policy_disabled_plugin_patterns_->begin()); |
40 while (pattern != policy_disabled_plugin_patterns_->end()) { | 40 while (pattern != policy_disabled_plugin_patterns_->end()) { |
41 if (MatchPattern(plugin_name, *pattern)) | 41 if (MatchPattern(plugin_name, *pattern)) |
42 return true; | 42 return true; |
43 ++pattern; | 43 ++pattern; |
44 } | 44 } |
45 | 45 |
46 return false; | 46 return false; |
47 } | 47 } |
48 | 48 |
49 /*static*/ | |
50 bool PluginGroup::IsPluginPathDisabledByPolicy(const FilePath& plugin_path) { | |
51 std::vector<WebPluginInfo> plugins; | |
52 PluginList::Singleton()->GetPlugins(false, &plugins); | |
53 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); | |
54 it != plugins.end(); | |
55 ++it) { | |
56 if (FilePath::CompareEqualIgnoreCase(it->path.value(), | |
57 plugin_path.value()) && IsPluginNameDisabledByPolicy(it->name)) { | |
58 return true; | |
59 } | |
60 } | |
61 return false; | |
62 } | |
63 | |
64 VersionRange::VersionRange(VersionRangeDefinition definition) | 49 VersionRange::VersionRange(VersionRangeDefinition definition) |
65 : low_str(definition.version_matcher_low), | 50 : low_str(definition.version_matcher_low), |
66 high_str(definition.version_matcher_high), | 51 high_str(definition.version_matcher_high), |
67 min_str(definition.min_version) { | 52 min_str(definition.min_version) { |
68 if (!low_str.empty()) | 53 if (!low_str.empty()) |
69 low.reset(Version::GetVersionFromString(low_str)); | 54 low.reset(Version::GetVersionFromString(low_str)); |
70 if (!high_str.empty()) | 55 if (!high_str.empty()) |
71 high.reset(Version::GetVersionFromString(high_str)); | 56 high.reset(Version::GetVersionFromString(high_str)); |
72 if (!min_str.empty()) | 57 if (!min_str.empty()) |
73 min.reset(Version::GetVersionFromString(min_str)); | 58 min.reset(Version::GetVersionFromString(min_str)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void PluginGroup::InitFrom(const PluginGroup& other) { | 93 void PluginGroup::InitFrom(const PluginGroup& other) { |
109 identifier_ = other.identifier_; | 94 identifier_ = other.identifier_; |
110 group_name_ = other.group_name_; | 95 group_name_ = other.group_name_; |
111 name_matcher_ = other.name_matcher_; | 96 name_matcher_ = other.name_matcher_; |
112 description_ = other.description_; | 97 description_ = other.description_; |
113 update_url_ = other.update_url_; | 98 update_url_ = other.update_url_; |
114 enabled_ = other.enabled_; | 99 enabled_ = other.enabled_; |
115 version_ranges_ = other.version_ranges_; | 100 version_ranges_ = other.version_ranges_; |
116 version_.reset(other.version_->Clone()); | 101 version_.reset(other.version_->Clone()); |
117 web_plugin_infos_ = other.web_plugin_infos_; | 102 web_plugin_infos_ = other.web_plugin_infos_; |
118 web_plugin_positions_ = other.web_plugin_positions_; | 103 web_plugin_priority_ = other.web_plugin_priority_; |
| 104 is_plugin_placeholder_ = other.is_plugin_placeholder_; |
119 } | 105 } |
120 | 106 |
121 PluginGroup::PluginGroup(const PluginGroup& other) { | 107 PluginGroup::PluginGroup(const PluginGroup& other) { |
122 InitFrom(other); | 108 InitFrom(other); |
123 } | 109 } |
124 | 110 |
125 PluginGroup& PluginGroup::operator=(const PluginGroup& other) { | 111 PluginGroup& PluginGroup::operator=(const PluginGroup& other) { |
126 InitFrom(other); | 112 InitFrom(other); |
127 return *this; | 113 return *this; |
128 } | 114 } |
(...skipping 30 matching lines...) Expand all Loading... |
159 #endif | 145 #endif |
160 } | 146 } |
161 | 147 |
162 /*static*/ | 148 /*static*/ |
163 PluginGroup* PluginGroup::FromWebPluginInfo(const WebPluginInfo& wpi) { | 149 PluginGroup* PluginGroup::FromWebPluginInfo(const WebPluginInfo& wpi) { |
164 // Create a matcher from the name of this plugin. | 150 // Create a matcher from the name of this plugin. |
165 return new PluginGroup(wpi.name, wpi.name, std::string(), | 151 return new PluginGroup(wpi.name, wpi.name, std::string(), |
166 GetIdentifier(wpi)); | 152 GetIdentifier(wpi)); |
167 } | 153 } |
168 | 154 |
| 155 /*static*/ |
| 156 PluginGroup* PluginGroup::CreateEmptyGroup(const string16& name) { |
| 157 // Create a matcher from the name of this plugin. |
| 158 return new PluginGroup(name, name, std::string(), std::string()); |
| 159 } |
| 160 |
169 bool PluginGroup::Match(const WebPluginInfo& plugin) const { | 161 bool PluginGroup::Match(const WebPluginInfo& plugin) const { |
170 if (name_matcher_.empty()) { | 162 if (name_matcher_.empty()) { |
171 return false; | 163 return false; |
172 } | 164 } |
173 | 165 |
174 // Look for the name matcher anywhere in the plugin name. | 166 // Look for the name matcher anywhere in the plugin name. |
175 if (plugin.name.find(name_matcher_) == string16::npos) { | 167 if (plugin.name.find(name_matcher_) == string16::npos) { |
176 return false; | 168 return false; |
177 } | 169 } |
178 | 170 |
(...skipping 27 matching lines...) Expand all Loading... |
206 RemoveChars(version, L") ", &version); | 198 RemoveChars(version, L") ", &version); |
207 std::replace(version.begin(), version.end(), 'r', '.'); | 199 std::replace(version.begin(), version.end(), 'r', '.'); |
208 std::replace(version.begin(), version.end(), ',', '.'); | 200 std::replace(version.begin(), version.end(), ',', '.'); |
209 std::replace(version.begin(), version.end(), '(', '.'); | 201 std::replace(version.begin(), version.end(), '(', '.'); |
210 | 202 |
211 return Version::GetVersionFromString(version); | 203 return Version::GetVersionFromString(version); |
212 } | 204 } |
213 | 205 |
214 void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) { | 206 void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) { |
215 // A group is enabled if any of the files are enabled. | 207 // A group is enabled if any of the files are enabled. |
216 if (plugin.enabled) { | 208 if (WebPluginInfoUtils::IsEnabled(plugin)) { |
217 if (!enabled_) { | 209 if (!enabled_) { |
218 // If this is the first enabled plugin, use its description. | 210 // If this is the first enabled plugin, use its description. |
219 enabled_ = true; | 211 enabled_ = true; |
220 UpdateDescriptionAndVersion(plugin); | 212 UpdateDescriptionAndVersion(plugin); |
221 } | 213 } |
222 } else { | 214 } else { |
223 // If this is the first plugin and it's disabled, | 215 // If this is the first plugin and it's disabled, |
224 // use its description for now. | 216 // use its description for now. |
225 if (description_.empty()) | 217 if (description_.empty()) |
226 UpdateDescriptionAndVersion(plugin); | 218 UpdateDescriptionAndVersion(plugin); |
227 } | 219 } |
228 } | 220 } |
229 | 221 |
230 void PluginGroup::UpdateDescriptionAndVersion(const WebPluginInfo& plugin) { | 222 void PluginGroup::UpdateDescriptionAndVersion(const WebPluginInfo& plugin) { |
231 description_ = plugin.desc; | 223 description_ = plugin.desc; |
232 if (Version* new_version = CreateVersionFromString(plugin.version)) | 224 if (Version* new_version = CreateVersionFromString(plugin.version)) |
233 version_.reset(new_version); | 225 version_.reset(new_version); |
234 else | 226 else |
235 version_.reset(Version::GetVersionFromString("0")); | 227 version_.reset(Version::GetVersionFromString("0")); |
236 } | 228 } |
237 | 229 |
238 void PluginGroup::AddPlugin(const WebPluginInfo& plugin, int position) { | 230 bool PluginGroup::AddPlugin(const WebPluginInfo& plugin, int priority) { |
239 // Check if this group already contains this plugin. | 231 // Check if this group already contains this plugin. |
240 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { | 232 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
241 if (web_plugin_infos_[i].name == plugin.name && | 233 if (web_plugin_infos_[i].name == plugin.name && |
242 web_plugin_infos_[i].version == plugin.version && | 234 (!web_plugin_infos_[i].version.length() || |
| 235 web_plugin_infos_[i].version == plugin.version) && |
243 FilePath::CompareEqualIgnoreCase(web_plugin_infos_[i].path.value(), | 236 FilePath::CompareEqualIgnoreCase(web_plugin_infos_[i].path.value(), |
244 plugin.path.value())) { | 237 plugin.path.value())) { |
245 return; | 238 // If no version info present or placeholder flag is set update this |
| 239 // one. This was a placeholder put here by a disabled/removed plugin. |
| 240 if (is_plugin_placeholder_[i]) { |
| 241 // Preserve enabled flag and reason. |
| 242 bool enabled = web_plugin_infos_[i].enabled; |
| 243 int reason = web_plugin_infos_[i].reason; |
| 244 web_plugin_infos_[i] = plugin; |
| 245 web_plugin_priority_[i] = priority; |
| 246 web_plugin_infos_[i].reason = reason; |
| 247 web_plugin_infos_[i].enabled = enabled; |
| 248 is_plugin_placeholder_[i] = false; |
| 249 return true; |
| 250 } |
| 251 return false; |
246 } | 252 } |
247 } | 253 } |
248 web_plugin_infos_.push_back(plugin); | 254 web_plugin_infos_.push_back(plugin); |
249 // The position of this plugin relative to the global list of plugins. | 255 // The position of this plugin relative to the global list of plugins. |
250 web_plugin_positions_.push_back(position); | 256 web_plugin_priority_.push_back(priority); |
251 UpdateActivePlugin(plugin); | 257 // Placeholders have only name and path and are used to enforce plugin state |
| 258 // before the plugin has been loaded. |
| 259 is_plugin_placeholder_.push_back(!plugin.desc.length()); |
| 260 UpdateActivePlugin(web_plugin_infos_.back()); |
| 261 return true; |
252 } | 262 } |
253 | 263 |
254 bool PluginGroup::IsEmpty() const { | 264 bool PluginGroup::EnablePlugin(const FilePath& filename) { |
255 return web_plugin_infos_.empty(); | 265 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
| 266 if (web_plugin_infos_[i].path == filename) { |
| 267 bool did_enable = |
| 268 WebPluginInfoUtils::Enable(&web_plugin_infos_[i], |
| 269 WebPluginInfo::USER); |
| 270 RefreshEnabledState(); |
| 271 return did_enable; |
| 272 } |
| 273 } |
| 274 return false; |
| 275 } |
| 276 |
| 277 bool PluginGroup::DisablePlugin(const FilePath& filename) { |
| 278 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
| 279 if (web_plugin_infos_[i].path == filename) { |
| 280 bool did_disable = WebPluginInfoUtils::Disable( |
| 281 &web_plugin_infos_[i], |
| 282 IsPluginNameDisabledByPolicy(web_plugin_infos_[i].name) ? |
| 283 WebPluginInfo::MANAGED : WebPluginInfo::USER); |
| 284 RefreshEnabledState(); |
| 285 return did_disable; |
| 286 } |
| 287 } |
| 288 return false; |
256 } | 289 } |
257 | 290 |
258 string16 PluginGroup::GetGroupName() const { | 291 string16 PluginGroup::GetGroupName() const { |
259 if (!group_name_.empty()) | 292 if (!group_name_.empty()) |
260 return group_name_; | 293 return group_name_; |
261 DCHECK_EQ(1u, web_plugin_infos_.size()); | 294 DCHECK_EQ(1u, web_plugin_infos_.size()); |
262 FilePath::StringType path = | 295 FilePath::StringType path = |
263 web_plugin_infos_[0].path.BaseName().RemoveExtension().value(); | 296 web_plugin_infos_.front().path.BaseName().RemoveExtension().value(); |
264 #if defined(OS_POSIX) | 297 #if defined(OS_POSIX) |
265 return UTF8ToUTF16(path); | 298 return UTF8ToUTF16(path); |
266 #elif defined(OS_WIN) | 299 #elif defined(OS_WIN) |
267 return WideToUTF16(path); | 300 return WideToUTF16(path); |
268 #endif | 301 #endif |
269 } | 302 } |
270 | 303 |
| 304 const std::vector<WebPluginInfo>& PluginGroup::GetPlugins() const { |
| 305 return web_plugin_infos_; |
| 306 } |
| 307 |
| 308 bool PluginGroup::ContainsPlugin(const FilePath& path) const { |
| 309 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
| 310 if (web_plugin_infos_[i].path == path) |
| 311 return true; |
| 312 } |
| 313 return false; |
| 314 } |
| 315 |
| 316 |
271 DictionaryValue* PluginGroup::GetSummary() const { | 317 DictionaryValue* PluginGroup::GetSummary() const { |
272 DictionaryValue* result = new DictionaryValue(); | 318 DictionaryValue* result = new DictionaryValue(); |
273 result->SetString("name", GetGroupName()); | 319 result->SetString("name", GetGroupName()); |
274 result->SetBoolean("enabled", enabled_); | 320 result->SetBoolean("enabled", enabled_); |
275 return result; | 321 return result; |
276 } | 322 } |
277 | 323 |
278 DictionaryValue* PluginGroup::GetDataForUI() const { | 324 DictionaryValue* PluginGroup::GetDataForUI() const { |
279 string16 name = GetGroupName(); | 325 string16 name = GetGroupName(); |
280 DictionaryValue* result = new DictionaryValue(); | 326 DictionaryValue* result = new DictionaryValue(); |
281 result->SetString("name", name); | 327 result->SetString("name", name); |
282 result->SetString("description", description_); | 328 result->SetString("description", description_); |
283 result->SetString("version", version_->GetString()); | 329 result->SetString("version", version_->GetString()); |
284 result->SetString("update_url", update_url_); | 330 result->SetString("update_url", update_url_); |
285 result->SetBoolean("critical", IsVulnerable()); | 331 result->SetBoolean("critical", IsVulnerable()); |
286 | 332 |
287 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(name); | 333 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(name); |
288 ListValue* plugin_files = new ListValue(); | 334 ListValue* plugin_files = new ListValue(); |
289 bool all_plugins_disabled_by_policy = true; | 335 bool all_plugins_disabled_by_policy = true; |
290 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { | 336 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
291 const WebPluginInfo& web_plugin = web_plugin_infos_[i]; | 337 int priority = web_plugin_priority_[i]; |
292 int priority = web_plugin_positions_[i]; | |
293 DictionaryValue* plugin_file = new DictionaryValue(); | 338 DictionaryValue* plugin_file = new DictionaryValue(); |
294 plugin_file->SetString("name", web_plugin.name); | 339 plugin_file->SetString("name", web_plugin_infos_[i].name); |
295 plugin_file->SetString("description", web_plugin.desc); | 340 plugin_file->SetString("description", web_plugin_infos_[i].desc); |
296 plugin_file->SetString("path", web_plugin.path.value()); | 341 plugin_file->SetString("path", web_plugin_infos_[i].path.value()); |
297 plugin_file->SetString("version", web_plugin.version); | 342 plugin_file->SetString("version", web_plugin_infos_[i].version); |
298 bool plugin_disabled_by_policy = group_disabled_by_policy || | 343 bool plugin_disabled_by_policy = group_disabled_by_policy || |
299 IsPluginNameDisabledByPolicy(web_plugin.name); | 344 WebPluginInfoUtils::IsManaged(web_plugin_infos_[i]); |
300 if (plugin_disabled_by_policy) { | 345 if (plugin_disabled_by_policy) { |
301 plugin_file->SetString("enabledMode", "disabledByPolicy"); | 346 plugin_file->SetString("enabledMode", "disabledByPolicy"); |
302 } else { | 347 } else { |
303 all_plugins_disabled_by_policy = false; | 348 all_plugins_disabled_by_policy = false; |
304 plugin_file->SetString("enabledMode", | 349 plugin_file->SetString( |
305 web_plugin.enabled ? "enabled" : "disabledByUser"); | 350 "enabledMode", WebPluginInfoUtils::IsEnabled(web_plugin_infos_[i]) ? |
| 351 "enabled" : "disabledByUser"); |
306 } | 352 } |
307 plugin_file->SetInteger("priority", priority); | 353 plugin_file->SetInteger("priority", priority); |
308 | 354 |
309 ListValue* mime_types = new ListValue(); | 355 ListValue* mime_types = new ListValue(); |
310 for (std::vector<WebPluginMimeType>::const_iterator type_it = | 356 const std::vector<WebPluginMimeType>& plugin_mime_types = |
311 web_plugin.mime_types.begin(); | 357 web_plugin_infos_[i].mime_types; |
312 type_it != web_plugin.mime_types.end(); | 358 for (size_t j = 0; j < plugin_mime_types.size(); ++j) { |
313 ++type_it) { | |
314 DictionaryValue* mime_type = new DictionaryValue(); | 359 DictionaryValue* mime_type = new DictionaryValue(); |
315 mime_type->SetString("mimeType", type_it->mime_type); | 360 mime_type->SetString("mimeType", plugin_mime_types[j].mime_type); |
316 mime_type->SetString("description", type_it->description); | 361 mime_type->SetString("description", plugin_mime_types[j].description); |
317 | 362 |
318 ListValue* file_extensions = new ListValue(); | 363 ListValue* file_extensions = new ListValue(); |
319 for (std::vector<std::string>::const_iterator ext_it = | 364 const std::vector<std::string>& mime_file_extensions = |
320 type_it->file_extensions.begin(); | 365 plugin_mime_types[j].file_extensions; |
321 ext_it != type_it->file_extensions.end(); | 366 for (size_t k = 0; k < mime_file_extensions.size(); ++k) |
322 ++ext_it) { | 367 file_extensions->Append(new StringValue(mime_file_extensions[k])); |
323 file_extensions->Append(new StringValue(*ext_it)); | |
324 } | |
325 mime_type->Set("fileExtensions", file_extensions); | 368 mime_type->Set("fileExtensions", file_extensions); |
326 | 369 |
327 mime_types->Append(mime_type); | 370 mime_types->Append(mime_type); |
328 } | 371 } |
329 plugin_file->Set("mimeTypes", mime_types); | 372 plugin_file->Set("mimeTypes", mime_types); |
330 | 373 |
331 plugin_files->Append(plugin_file); | 374 plugin_files->Append(plugin_file); |
332 } | 375 } |
333 | 376 |
334 if (group_disabled_by_policy || all_plugins_disabled_by_policy) { | 377 if (group_disabled_by_policy || all_plugins_disabled_by_policy) { |
(...skipping 30 matching lines...) Expand all Loading... |
365 | 408 |
366 // Returns true if the latest version of this plugin group is vulnerable. | 409 // Returns true if the latest version of this plugin group is vulnerable. |
367 bool PluginGroup::IsVulnerable() const { | 410 bool PluginGroup::IsVulnerable() const { |
368 for (size_t i = 0; i < version_ranges_.size(); ++i) { | 411 for (size_t i = 0; i < version_ranges_.size(); ++i) { |
369 if (IsPluginOutdated(*version_, version_ranges_[i])) | 412 if (IsPluginOutdated(*version_, version_ranges_[i])) |
370 return true; | 413 return true; |
371 } | 414 } |
372 return false; | 415 return false; |
373 } | 416 } |
374 | 417 |
| 418 bool PluginGroup::IsEmpty() const { |
| 419 if (web_plugin_infos_.size() == 0) |
| 420 return true; |
| 421 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
| 422 if (!is_plugin_placeholder_[i]) |
| 423 return false; |
| 424 } |
| 425 return true; |
| 426 } |
| 427 |
| 428 void PluginGroup::SetPluginIsPlaceholder(const WebPluginInfo& plugin, |
| 429 bool status) { |
| 430 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) |
| 431 if (web_plugin_infos_[i].path == plugin.path) |
| 432 is_plugin_placeholder_[i] = status; |
| 433 } |
| 434 |
| 435 bool PluginGroup::IsPluginPlaceholder(const WebPluginInfo& plugin) { |
| 436 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) |
| 437 if (web_plugin_infos_[i].path == plugin.path) |
| 438 return is_plugin_placeholder_[i]; |
| 439 // We shouldn't call be this function for unknown plugins. |
| 440 NOTREACHED(); |
| 441 return false; |
| 442 } |
| 443 |
375 void PluginGroup::DisableOutdatedPlugins() { | 444 void PluginGroup::DisableOutdatedPlugins() { |
376 description_ = string16(); | 445 bool first_enabled = true; |
377 enabled_ = false; | |
378 | 446 |
379 for (std::vector<WebPluginInfo>::iterator it = | 447 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
380 web_plugin_infos_.begin(); | 448 scoped_ptr<Version> version( |
381 it != web_plugin_infos_.end(); ++it) { | 449 CreateVersionFromString(web_plugin_infos_[i].version)); |
382 scoped_ptr<Version> version(CreateVersionFromString(it->version)); | |
383 if (version.get()) { | 450 if (version.get()) { |
384 for (size_t i = 0; i < version_ranges_.size(); ++i) { | 451 bool plugin_is_outdated = false; |
385 if (IsPluginOutdated(*version, version_ranges_[i])) { | 452 for (size_t j = 0; j < version_ranges_.size(); ++j) { |
386 it->enabled = false; | 453 if (IsPluginOutdated(*version, version_ranges_[j])) { |
387 PluginList::Singleton()->DisablePlugin(it->path); | 454 WebPluginInfoUtils::Disable(&web_plugin_infos_[i], |
| 455 WebPluginInfo::USER); |
| 456 plugin_is_outdated = true; |
| 457 break; |
388 } | 458 } |
389 } | 459 } |
| 460 if (!plugin_is_outdated && first_enabled) { |
| 461 first_enabled = false; |
| 462 UpdateDescriptionAndVersion(web_plugin_infos_[i]); |
| 463 } |
390 } | 464 } |
391 UpdateActivePlugin(*it); | |
392 } | 465 } |
393 } | 466 } |
394 | 467 |
395 void PluginGroup::Enable(bool enable) { | 468 bool PluginGroup::EnableGroup(bool enable) { |
396 bool enabled_plugin_exists = false; | 469 bool enabled_plugin_exists = false; |
397 for (std::vector<WebPluginInfo>::iterator it = | 470 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(group_name_); |
398 web_plugin_infos_.begin(); | 471 // We can't enable groups disabled by policy |
399 it != web_plugin_infos_.end(); ++it) { | 472 if (group_disabled_by_policy && enable) |
400 if (enable && !IsPluginNameDisabledByPolicy(it->name)) { | 473 return false; |
401 PluginList::Singleton()->EnablePlugin(it->path); | 474 |
402 it->enabled = true; | 475 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
| 476 bool policy_disabled = |
| 477 IsPluginNameDisabledByPolicy(web_plugin_infos_[i].name); |
| 478 if (enable && !policy_disabled) { |
| 479 WebPluginInfoUtils::Enable(&web_plugin_infos_[i], WebPluginInfo::USER); |
403 enabled_plugin_exists = true; | 480 enabled_plugin_exists = true; |
404 } else { | 481 } else { |
405 it->enabled = false; | 482 WebPluginInfoUtils::Disable( |
406 PluginList::Singleton()->DisablePlugin(it->path); | 483 &web_plugin_infos_[i], policy_disabled || group_disabled_by_policy ? |
| 484 WebPluginInfo::MANAGED : WebPluginInfo::USER); |
407 } | 485 } |
408 } | 486 } |
409 enabled_ = enabled_plugin_exists; | 487 enabled_ = enabled_plugin_exists; |
| 488 return enabled_ == enable; |
| 489 } |
| 490 |
| 491 void PluginGroup::RefreshEnabledState() { |
| 492 bool enabled_plugin_exists = false; |
| 493 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
| 494 if (WebPluginInfoUtils::IsEnabled(web_plugin_infos_[i])) { |
| 495 enabled_plugin_exists = true; |
| 496 break; |
| 497 } |
| 498 } |
| 499 enabled_ = enabled_plugin_exists; |
410 } | 500 } |
411 | 501 |
412 } // namespace npapi | 502 } // namespace npapi |
413 } // namespace webkit | 503 } // namespace webkit |
OLD | NEW |