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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "base/version.h" | 12 #include "base/version.h" |
13 #include "webkit/plugins/npapi/plugin_list.h" | 13 #include "webkit/plugins/npapi/plugin_list.h" |
14 #include "webkit/plugins/npapi/webplugininfo.h" | 14 #include "webkit/plugins/npapi/webplugininfo.h" |
15 | 15 |
16 namespace webkit { | 16 namespace webkit { |
17 namespace npapi { | 17 namespace npapi { |
18 | 18 |
19 const char* PluginGroup::kAdobeReaderGroupName = "Adobe Reader"; | 19 const char* PluginGroup::kAdobeReaderGroupName = "Adobe Reader"; |
20 const char* PluginGroup::kAdobeReaderUpdateURL = "http://get.adobe.com/reader/"; | 20 const char* PluginGroup::kAdobeReaderUpdateURL = "http://get.adobe.com/reader/"; |
| 21 const char* PluginGroup::kJavaGroupName = "Java"; |
| 22 const char* PluginGroup::kQuickTimeGroupName = "QuickTime"; |
| 23 const char* PluginGroup::kShockwaveGroupName = "Shockwave"; |
21 | 24 |
22 /*static*/ | 25 /*static*/ |
23 std::set<string16>* PluginGroup::policy_disabled_plugin_patterns_; | 26 std::set<string16>* PluginGroup::policy_disabled_plugin_patterns_; |
24 | 27 |
25 /*static*/ | 28 /*static*/ |
26 void PluginGroup::SetPolicyDisabledPluginPatterns( | 29 void PluginGroup::SetPolicyDisabledPluginPatterns( |
27 const std::set<string16>& set) { | 30 const std::set<string16>& set) { |
28 if (!policy_disabled_plugin_patterns_) | 31 if (!policy_disabled_plugin_patterns_) |
29 policy_disabled_plugin_patterns_ = new std::set<string16>(set); | 32 policy_disabled_plugin_patterns_ = new std::set<string16>(set); |
30 else | 33 else |
(...skipping 12 matching lines...) Expand all Loading... |
43 return true; | 46 return true; |
44 ++pattern; | 47 ++pattern; |
45 } | 48 } |
46 | 49 |
47 return false; | 50 return false; |
48 } | 51 } |
49 | 52 |
50 VersionRange::VersionRange(VersionRangeDefinition definition) | 53 VersionRange::VersionRange(VersionRangeDefinition definition) |
51 : low_str(definition.version_matcher_low), | 54 : low_str(definition.version_matcher_low), |
52 high_str(definition.version_matcher_high), | 55 high_str(definition.version_matcher_high), |
53 min_str(definition.min_version) { | 56 min_str(definition.min_version), |
| 57 requires_authorization(definition.requires_authorization) { |
54 if (!low_str.empty()) | 58 if (!low_str.empty()) |
55 low.reset(Version::GetVersionFromString(low_str)); | 59 low.reset(Version::GetVersionFromString(low_str)); |
56 if (!high_str.empty()) | 60 if (!high_str.empty()) |
57 high.reset(Version::GetVersionFromString(high_str)); | 61 high.reset(Version::GetVersionFromString(high_str)); |
58 if (!min_str.empty()) | 62 if (!min_str.empty()) |
59 min.reset(Version::GetVersionFromString(min_str)); | 63 min.reset(Version::GetVersionFromString(min_str)); |
60 } | 64 } |
61 | 65 |
62 VersionRange::VersionRange(const VersionRange& other) { | 66 VersionRange::VersionRange(const VersionRange& other) { |
63 InitFrom(other); | 67 InitFrom(other); |
64 } | 68 } |
65 | 69 |
66 VersionRange& VersionRange::operator=(const VersionRange& other) { | 70 VersionRange& VersionRange::operator=(const VersionRange& other) { |
67 InitFrom(other); | 71 InitFrom(other); |
68 return *this; | 72 return *this; |
69 } | 73 } |
70 | 74 |
71 VersionRange::~VersionRange() {} | 75 VersionRange::~VersionRange() {} |
72 | 76 |
73 void VersionRange::InitFrom(const VersionRange& other) { | 77 void VersionRange::InitFrom(const VersionRange& other) { |
74 low_str = other.low_str; | 78 low_str = other.low_str; |
75 high_str = other.high_str; | 79 high_str = other.high_str; |
76 min_str = other.min_str; | 80 min_str = other.min_str; |
77 low.reset(Version::GetVersionFromString(other.low_str)); | 81 low.reset(Version::GetVersionFromString(other.low_str)); |
78 high.reset(Version::GetVersionFromString(other.high_str)); | 82 high.reset(Version::GetVersionFromString(other.high_str)); |
79 min.reset(Version::GetVersionFromString(other.min_str)); | 83 min.reset(Version::GetVersionFromString(other.min_str)); |
| 84 requires_authorization = other.requires_authorization; |
80 } | 85 } |
81 | 86 |
82 PluginGroup::PluginGroup(const string16& group_name, | 87 PluginGroup::PluginGroup(const string16& group_name, |
83 const string16& name_matcher, | 88 const string16& name_matcher, |
84 const std::string& update_url, | 89 const std::string& update_url, |
85 const std::string& identifier) | 90 const std::string& identifier) |
86 : identifier_(identifier), | 91 : identifier_(identifier), |
87 group_name_(group_name), | 92 group_name_(group_name), |
88 name_matcher_(name_matcher), | 93 name_matcher_(name_matcher), |
89 update_url_(update_url), | 94 update_url_(update_url), |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 399 |
395 // Returns true if the latest version of this plugin group is vulnerable. | 400 // Returns true if the latest version of this plugin group is vulnerable. |
396 bool PluginGroup::IsVulnerable() const { | 401 bool PluginGroup::IsVulnerable() const { |
397 for (size_t i = 0; i < version_ranges_.size(); ++i) { | 402 for (size_t i = 0; i < version_ranges_.size(); ++i) { |
398 if (IsPluginOutdated(*version_, version_ranges_[i])) | 403 if (IsPluginOutdated(*version_, version_ranges_[i])) |
399 return true; | 404 return true; |
400 } | 405 } |
401 return false; | 406 return false; |
402 } | 407 } |
403 | 408 |
| 409 bool PluginGroup::RequiresAuthorization() const { |
| 410 for (size_t i = 0; i < version_ranges_.size(); ++i) { |
| 411 if (IsVersionInRange(*version_, version_ranges_[i]) && |
| 412 version_ranges_[i].requires_authorization) |
| 413 return true; |
| 414 } |
| 415 return false; |
| 416 } |
| 417 |
404 bool PluginGroup::IsEmpty() const { | 418 bool PluginGroup::IsEmpty() const { |
405 return web_plugin_infos_.size() == 0; | 419 return web_plugin_infos_.size() == 0; |
406 } | 420 } |
407 | 421 |
408 void PluginGroup::DisableOutdatedPlugins() { | 422 void PluginGroup::DisableOutdatedPlugins() { |
409 bool first_enabled = true; | 423 bool first_enabled = true; |
410 | 424 |
411 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { | 425 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
412 scoped_ptr<Version> version( | 426 scoped_ptr<Version> version( |
413 CreateVersionFromString(web_plugin_infos_[i].version)); | 427 CreateVersionFromString(web_plugin_infos_[i].version)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // Only changeable if not managed. | 535 // Only changeable if not managed. |
522 if (plugin->enabled & WebPluginInfo::MANAGED_MASK) | 536 if (plugin->enabled & WebPluginInfo::MANAGED_MASK) |
523 return false; | 537 return false; |
524 plugin->enabled = new_reason; | 538 plugin->enabled = new_reason; |
525 } | 539 } |
526 return true; | 540 return true; |
527 } | 541 } |
528 | 542 |
529 } // namespace npapi | 543 } // namespace npapi |
530 } // namespace webkit | 544 } // namespace webkit |
OLD | NEW |