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_metadata.h" | 5 #include "chrome/browser/plugins/plugin_metadata.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "webkit/plugins/webplugininfo.h" | 11 #include "content/public/common/webplugininfo.h" |
12 | 12 |
13 // static | 13 // static |
14 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; | 14 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; |
15 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; | 15 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; |
16 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; | 16 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; |
17 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; | 17 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; |
18 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer"; | 18 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer"; |
19 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight"; | 19 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight"; |
20 const char PluginMetadata::kWindowsMediaPlayerGroupName[] = | 20 const char PluginMetadata::kWindowsMediaPlayerGroupName[] = |
21 "Windows Media Player"; | 21 "Windows Media Player"; |
(...skipping 29 matching lines...) Expand all Loading... |
51 | 51 |
52 void PluginMetadata::AddMatchingMimeType(const std::string& mime_type) { | 52 void PluginMetadata::AddMatchingMimeType(const std::string& mime_type) { |
53 matching_mime_types_.push_back(mime_type); | 53 matching_mime_types_.push_back(mime_type); |
54 } | 54 } |
55 | 55 |
56 bool PluginMetadata::HasMimeType(const std::string& mime_type) const { | 56 bool PluginMetadata::HasMimeType(const std::string& mime_type) const { |
57 return std::find(all_mime_types_.begin(), all_mime_types_.end(), mime_type) != | 57 return std::find(all_mime_types_.begin(), all_mime_types_.end(), mime_type) != |
58 all_mime_types_.end(); | 58 all_mime_types_.end(); |
59 } | 59 } |
60 | 60 |
61 bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin) { | 61 bool PluginMetadata::MatchesPlugin(const content::WebPluginInfo& plugin) { |
62 for (size_t i = 0; i < matching_mime_types_.size(); ++i) { | 62 for (size_t i = 0; i < matching_mime_types_.size(); ++i) { |
63 // To have a match, every one of the |matching_mime_types_| | 63 // To have a match, every one of the |matching_mime_types_| |
64 // must be handled by the plug-in. | 64 // must be handled by the plug-in. |
65 size_t j = 0; | 65 size_t j = 0; |
66 for (; j < plugin.mime_types.size(); ++j) { | 66 for (; j < plugin.mime_types.size(); ++j) { |
67 if (plugin.mime_types[j].mime_type == matching_mime_types_[i]) | 67 if (plugin.mime_types[j].mime_type == matching_mime_types_[i]) |
68 break; | 68 break; |
69 } | 69 } |
70 if (j == plugin.mime_types.size()) | 70 if (j == plugin.mime_types.size()) |
71 return false; | 71 return false; |
(...skipping 12 matching lines...) Expand all Loading... |
84 *status = SECURITY_STATUS_OUT_OF_DATE; | 84 *status = SECURITY_STATUS_OUT_OF_DATE; |
85 else if (status_str == "requires_authorization") | 85 else if (status_str == "requires_authorization") |
86 *status = SECURITY_STATUS_REQUIRES_AUTHORIZATION; | 86 *status = SECURITY_STATUS_REQUIRES_AUTHORIZATION; |
87 else | 87 else |
88 return false; | 88 return false; |
89 | 89 |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 PluginMetadata::SecurityStatus PluginMetadata::GetSecurityStatus( | 93 PluginMetadata::SecurityStatus PluginMetadata::GetSecurityStatus( |
94 const webkit::WebPluginInfo& plugin) const { | 94 const content::WebPluginInfo& plugin) const { |
95 if (versions_.empty()) { | 95 if (versions_.empty()) { |
96 #if defined(OS_LINUX) | 96 #if defined(OS_LINUX) |
97 // On Linux, unknown plugins require authorization. | 97 // On Linux, unknown plugins require authorization. |
98 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; | 98 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; |
99 #else | 99 #else |
100 return SECURITY_STATUS_UP_TO_DATE; | 100 return SECURITY_STATUS_UP_TO_DATE; |
101 #endif | 101 #endif |
102 } | 102 } |
103 | 103 |
104 Version version; | 104 Version version; |
105 webkit::WebPluginInfo::CreateVersionFromString(plugin.version, &version); | 105 content::WebPluginInfo::CreateVersionFromString(plugin.version, &version); |
106 if (!version.IsValid()) | 106 if (!version.IsValid()) |
107 version = Version("0"); | 107 version = Version("0"); |
108 | 108 |
109 // |lower_bound| returns the latest version that is not newer than |version|. | 109 // |lower_bound| returns the latest version that is not newer than |version|. |
110 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it = | 110 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it = |
111 versions_.lower_bound(version); | 111 versions_.lower_bound(version); |
112 // If there is at least one version defined, everything older than the oldest | 112 // If there is at least one version defined, everything older than the oldest |
113 // defined version is considered out-of-date. | 113 // defined version is considered out-of-date. |
114 if (it == versions_.end()) | 114 if (it == versions_.end()) |
115 return SECURITY_STATUS_OUT_OF_DATE; | 115 return SECURITY_STATUS_OUT_OF_DATE; |
(...skipping 11 matching lines...) Expand all Loading... |
127 PluginMetadata* copy = new PluginMetadata(identifier_, | 127 PluginMetadata* copy = new PluginMetadata(identifier_, |
128 name_, | 128 name_, |
129 url_for_display_, | 129 url_for_display_, |
130 plugin_url_, | 130 plugin_url_, |
131 help_url_, | 131 help_url_, |
132 group_name_matcher_, | 132 group_name_matcher_, |
133 language_); | 133 language_); |
134 copy->versions_ = versions_; | 134 copy->versions_ = versions_; |
135 return make_scoped_ptr(copy); | 135 return make_scoped_ptr(copy); |
136 } | 136 } |
OLD | NEW |