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/glue/plugins/plugin_group.h" | 5 #include "webkit/glue/plugins/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 25 matching lines...) Expand all Loading... | |
36 policy_disabled_plugin_patterns_->begin()); | 36 policy_disabled_plugin_patterns_->begin()); |
37 while (pattern != policy_disabled_plugin_patterns_->end()) { | 37 while (pattern != policy_disabled_plugin_patterns_->end()) { |
38 if (MatchPattern(plugin_name, *pattern)) | 38 if (MatchPattern(plugin_name, *pattern)) |
39 return true; | 39 return true; |
40 ++pattern; | 40 ++pattern; |
41 } | 41 } |
42 | 42 |
43 return false; | 43 return false; |
44 } | 44 } |
45 | 45 |
46 /*static*/ | |
47 bool PluginGroup::IsPluginPathDisabledByPolicy(const FilePath& plugin_path) { | |
48 std::vector<WebPluginInfo> plugins; | |
49 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); | |
50 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); | |
51 it != plugins.end(); | |
52 ++it) { | |
53 if (FilePath::CompareEqualIgnoreCase(it->path.value(), | |
54 plugin_path.value()) && IsPluginNameDisabledByPolicy(it->name)) { | |
55 return true; | |
56 } | |
57 } | |
58 return false; | |
59 } | |
60 | |
61 VersionRange::VersionRange(VersionRangeDefinition definition) | 46 VersionRange::VersionRange(VersionRangeDefinition definition) |
62 : low_str(definition.version_matcher_low), | 47 : low_str(definition.version_matcher_low), |
63 high_str(definition.version_matcher_high), | 48 high_str(definition.version_matcher_high), |
64 min_str(definition.min_version) { | 49 min_str(definition.min_version) { |
65 if (!low_str.empty()) | 50 if (!low_str.empty()) |
66 low.reset(Version::GetVersionFromString(low_str)); | 51 low.reset(Version::GetVersionFromString(low_str)); |
67 if (!high_str.empty()) | 52 if (!high_str.empty()) |
68 high.reset(Version::GetVersionFromString(high_str)); | 53 high.reset(Version::GetVersionFromString(high_str)); |
69 if (!min_str.empty()) | 54 if (!min_str.empty()) |
70 min.reset(Version::GetVersionFromString(min_str)); | 55 min.reset(Version::GetVersionFromString(min_str)); |
(...skipping 25 matching lines...) Expand all Loading... | |
96 const std::string& identifier) | 81 const std::string& identifier) |
97 : identifier_(identifier), | 82 : identifier_(identifier), |
98 group_name_(group_name), | 83 group_name_(group_name), |
99 name_matcher_(name_matcher), | 84 name_matcher_(name_matcher), |
100 update_url_(update_url), | 85 update_url_(update_url), |
101 enabled_(false), | 86 enabled_(false), |
102 version_(Version::GetVersionFromString("0")) { | 87 version_(Version::GetVersionFromString("0")) { |
103 } | 88 } |
104 | 89 |
105 void PluginGroup::InitFrom(const PluginGroup& other) { | 90 void PluginGroup::InitFrom(const PluginGroup& other) { |
91 enabled_ = false; | |
jam
2010/12/17 19:14:45
curious why this doesn't get copied from other?
pastarmovj
2010/12/20 19:57:37
This whole function will be changed in CL 5783005
jam
2010/12/20 20:56:59
It's fine that this function will change in the fu
pastarmovj
2010/12/20 21:47:22
Actually it is better to say that this function wi
Bernhard Bauer
2010/12/20 22:30:28
So... rebase it on top of the other CL? Asking som
| |
106 identifier_ = other.identifier_; | 92 identifier_ = other.identifier_; |
107 group_name_ = other.group_name_; | 93 group_name_ = other.group_name_; |
108 name_matcher_ = other.name_matcher_; | 94 name_matcher_ = other.name_matcher_; |
109 description_ = other.description_; | |
110 update_url_ = other.update_url_; | 95 update_url_ = other.update_url_; |
111 enabled_ = other.enabled_; | |
112 for (size_t i = 0; i < other.version_ranges_.size(); ++i) | 96 for (size_t i = 0; i < other.version_ranges_.size(); ++i) |
113 version_ranges_.push_back(other.version_ranges_[i]); | 97 version_ranges_.push_back(other.version_ranges_[i]); |
114 DCHECK_EQ(other.web_plugin_infos_.size(), other.web_plugin_positions_.size()); | 98 std::vector<WebPluginInfo>::const_iterator it = |
jam
2010/12/17 19:14:45
please use size_t to iterate as before, it's much
pastarmovj
2010/12/20 19:57:37
Same as above.
jam
2010/12/20 20:56:59
ditto, I see no reason to change the existing code
pastarmovj
2010/12/20 21:47:22
Same as above no loop in the code at all :
http:
| |
115 for (size_t i = 0; i < other.web_plugin_infos_.size(); ++i) | 99 other.web_plugin_infos_.begin(); |
116 AddPlugin(other.web_plugin_infos_[i], other.web_plugin_positions_[i]); | 100 for (; it != other.web_plugin_infos_.end(); ++it) |
101 AddPlugin(*it, it->priority); | |
117 if (!version_.get()) | 102 if (!version_.get()) |
118 version_.reset(Version::GetVersionFromString("0")); | 103 version_.reset(Version::GetVersionFromString("0")); |
104 enabled_ = other.enabled_; | |
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 version_ranges_.clear(); | 112 version_ranges_.clear(); |
127 InitFrom(other); | 113 InitFrom(other); |
128 return *this; | 114 return *this; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 #endif | 146 #endif |
161 } | 147 } |
162 | 148 |
163 /*static*/ | 149 /*static*/ |
164 PluginGroup* PluginGroup::FromWebPluginInfo(const WebPluginInfo& wpi) { | 150 PluginGroup* PluginGroup::FromWebPluginInfo(const WebPluginInfo& wpi) { |
165 // Create a matcher from the name of this plugin. | 151 // Create a matcher from the name of this plugin. |
166 return new PluginGroup(wpi.name, wpi.name, std::string(), | 152 return new PluginGroup(wpi.name, wpi.name, std::string(), |
167 GetIdentifier(wpi)); | 153 GetIdentifier(wpi)); |
168 } | 154 } |
169 | 155 |
156 /*static*/ | |
157 PluginGroup* PluginGroup::CreateEmptyGroup(const string16& name) { | |
158 // Create a matcher from the name of this plugin. | |
159 return new PluginGroup(name, name, std::string(), std::string()); | |
160 } | |
161 | |
170 bool PluginGroup::Match(const WebPluginInfo& plugin) const { | 162 bool PluginGroup::Match(const WebPluginInfo& plugin) const { |
171 if (name_matcher_.empty()) { | 163 if (name_matcher_.empty()) { |
172 return false; | 164 return false; |
173 } | 165 } |
174 | 166 |
175 // Look for the name matcher anywhere in the plugin name. | 167 // Look for the name matcher anywhere in the plugin name. |
176 if (plugin.name.find(name_matcher_) == string16::npos) { | 168 if (plugin.name.find(name_matcher_) == string16::npos) { |
177 return false; | 169 return false; |
178 } | 170 } |
179 | 171 |
(...skipping 27 matching lines...) Expand all Loading... | |
207 RemoveChars(version, L") ", &version); | 199 RemoveChars(version, L") ", &version); |
208 std::replace(version.begin(), version.end(), 'r', '.'); | 200 std::replace(version.begin(), version.end(), 'r', '.'); |
209 std::replace(version.begin(), version.end(), ',', '.'); | 201 std::replace(version.begin(), version.end(), ',', '.'); |
210 std::replace(version.begin(), version.end(), '(', '.'); | 202 std::replace(version.begin(), version.end(), '(', '.'); |
211 | 203 |
212 return Version::GetVersionFromString(version); | 204 return Version::GetVersionFromString(version); |
213 } | 205 } |
214 | 206 |
215 void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) { | 207 void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) { |
216 // A group is enabled if any of the files are enabled. | 208 // A group is enabled if any of the files are enabled. |
217 if (plugin.enabled) { | 209 if (plugin.IsEnabled()) { |
218 if (!enabled_) { | 210 if (!enabled_) { |
219 // If this is the first enabled plugin, use its description. | 211 // If this is the first enabled plugin, use its description. |
220 enabled_ = true; | 212 enabled_ = true; |
221 UpdateDescriptionAndVersion(plugin); | 213 UpdateDescriptionAndVersion(plugin); |
222 } | 214 } |
223 } else { | 215 } else { |
224 // If this is the first plugin and it's disabled, | 216 // If this is the first plugin and it's disabled, |
225 // use its description for now. | 217 // use its description for now. |
226 if (description_.empty()) | 218 if (description_.empty()) |
227 UpdateDescriptionAndVersion(plugin); | 219 UpdateDescriptionAndVersion(plugin); |
228 } | 220 } |
229 } | 221 } |
230 | 222 |
231 void PluginGroup::UpdateDescriptionAndVersion(const WebPluginInfo& plugin) { | 223 void PluginGroup::UpdateDescriptionAndVersion(const WebPluginInfo& plugin) { |
232 description_ = plugin.desc; | 224 description_ = plugin.desc; |
233 if (Version* new_version = CreateVersionFromString(plugin.version)) | 225 if (Version* new_version = CreateVersionFromString(plugin.version)) |
234 version_.reset(new_version); | 226 version_.reset(new_version); |
235 else | 227 else |
236 version_.reset(Version::GetVersionFromString("0")); | 228 version_.reset(Version::GetVersionFromString("0")); |
237 } | 229 } |
238 | 230 |
239 void PluginGroup::AddPlugin(const WebPluginInfo& plugin, int position) { | 231 bool PluginGroup::AddPlugin(const WebPluginInfo& plugin, int priority) { |
240 // Check if this group already contains this plugin. | 232 // Check if this group already contains this plugin. |
241 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { | 233 for (std::vector<WebPluginInfo>::iterator it = web_plugin_infos_.begin(); |
jam
2010/12/17 19:14:45
nit: please don't switch this to an iterator
pastarmovj
2010/12/20 19:57:37
Done.
| |
242 if (web_plugin_infos_[i].name == plugin.name && | 234 it != web_plugin_infos_.end(); ++it) { |
243 web_plugin_infos_[i].version == plugin.version && | 235 if (it->name == plugin.name && |
244 FilePath::CompareEqualIgnoreCase(web_plugin_infos_[i].path.value(), | 236 (!it->HasVersion() || it->version == plugin.version) && |
237 FilePath::CompareEqualIgnoreCase(it->path.value(), | |
245 plugin.path.value())) { | 238 plugin.path.value())) { |
246 return; | 239 // If no version info present then just update this one. This was a |
240 // placeholder put here by a disabled plugin. | |
241 if (!it->HasVersion()) { | |
242 // Preserve enabled flag and reason. | |
243 bool enabled = it->enabled; | |
244 int reason = it->reason; | |
245 *it = plugin; | |
246 it->priority = priority; | |
247 it->reason = reason; | |
248 it->enabled = enabled; | |
249 return true; | |
250 } | |
251 return false; | |
247 } | 252 } |
248 } | 253 } |
249 web_plugin_infos_.push_back(plugin); | 254 web_plugin_infos_.push_back(plugin); |
250 // 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. |
251 web_plugin_positions_.push_back(position); | 256 web_plugin_infos_.back().priority = priority; |
252 UpdateActivePlugin(plugin); | 257 UpdateActivePlugin(web_plugin_infos_.back()); |
258 return true; | |
259 } | |
260 | |
261 bool PluginGroup::EnablePlugin(const FilePath& filename) { | |
262 for (std::vector<WebPluginInfo>::iterator it = web_plugin_infos_.begin(); | |
263 it != web_plugin_infos_.end(); ++it) { | |
264 if (it->path == filename) { | |
265 bool did_enable = it->Enable(WebPluginInfo::USER); | |
266 RefreshEnabledState(); | |
267 return did_enable; | |
268 } | |
269 } | |
270 return false; | |
271 } | |
272 | |
273 bool PluginGroup::DisablePlugin(const FilePath& filename) { | |
274 for (std::vector<WebPluginInfo>::iterator it = web_plugin_infos_.begin(); | |
275 it != web_plugin_infos_.end(); ++it) { | |
276 if (it->path == filename) { | |
277 bool did_disable = it->Disable( | |
278 IsPluginNameDisabledByPolicy(it->name) ? | |
279 WebPluginInfo::MANAGED : WebPluginInfo::USER); | |
280 RefreshEnabledState(); | |
281 return did_disable; | |
282 } | |
283 } | |
284 return false; | |
253 } | 285 } |
254 | 286 |
255 string16 PluginGroup::GetGroupName() const { | 287 string16 PluginGroup::GetGroupName() const { |
256 if (!group_name_.empty()) | 288 if (!group_name_.empty()) |
257 return group_name_; | 289 return group_name_; |
258 DCHECK_EQ(1u, web_plugin_infos_.size()); | 290 DCHECK_EQ(1u, web_plugin_infos_.size()); |
259 FilePath::StringType path = | 291 FilePath::StringType path = |
260 web_plugin_infos_[0].path.BaseName().RemoveExtension().value(); | 292 web_plugin_infos_.front().path.BaseName().RemoveExtension().value(); |
261 #if defined(OS_POSIX) | 293 #if defined(OS_POSIX) |
262 return UTF8ToUTF16(path); | 294 return UTF8ToUTF16(path); |
263 #elif defined(OS_WIN) | 295 #elif defined(OS_WIN) |
264 return WideToUTF16(path); | 296 return WideToUTF16(path); |
265 #endif | 297 #endif |
266 } | 298 } |
267 | 299 |
300 const std::vector<WebPluginInfo>& PluginGroup::GetPlugins() const { | |
301 return web_plugin_infos_; | |
302 } | |
303 | |
304 bool PluginGroup::HasPlugin(const FilePath& path) const { | |
305 for (std::vector<WebPluginInfo>::const_iterator it = | |
jam
2010/12/17 19:14:45
nit: size_t please
pastarmovj
2010/12/20 19:57:37
Done.
| |
306 web_plugin_infos_.begin(); | |
307 it != web_plugin_infos_.end(); ++it) { | |
308 if (it->path == path) | |
309 return true; | |
310 } | |
311 return false; | |
312 } | |
313 | |
314 | |
268 DictionaryValue* PluginGroup::GetSummary() const { | 315 DictionaryValue* PluginGroup::GetSummary() const { |
269 DictionaryValue* result = new DictionaryValue(); | 316 DictionaryValue* result = new DictionaryValue(); |
270 result->SetString("name", GetGroupName()); | 317 result->SetString("name", GetGroupName()); |
271 result->SetBoolean("enabled", enabled_); | 318 result->SetBoolean("enabled", enabled_); |
272 return result; | 319 return result; |
273 } | 320 } |
274 | 321 |
275 DictionaryValue* PluginGroup::GetDataForUI() const { | 322 DictionaryValue* PluginGroup::GetDataForUI() const { |
276 string16 name = GetGroupName(); | 323 string16 name = GetGroupName(); |
277 DictionaryValue* result = new DictionaryValue(); | 324 DictionaryValue* result = new DictionaryValue(); |
278 result->SetString("name", name); | 325 result->SetString("name", name); |
279 result->SetString("description", description_); | 326 result->SetString("description", description_); |
280 result->SetString("version", version_->GetString()); | 327 result->SetString("version", version_->GetString()); |
281 result->SetString("update_url", update_url_); | 328 result->SetString("update_url", update_url_); |
282 result->SetBoolean("critical", IsVulnerable()); | 329 result->SetBoolean("critical", IsVulnerable()); |
283 | 330 |
284 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(name); | 331 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(name); |
285 ListValue* plugin_files = new ListValue(); | 332 ListValue* plugin_files = new ListValue(); |
286 bool all_plugins_disabled_by_policy = true; | 333 bool all_plugins_disabled_by_policy = true; |
287 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { | 334 for (std::vector<WebPluginInfo>::const_iterator it = |
jam
2010/12/17 19:14:45
nit: size_t
pastarmovj
2010/12/20 19:57:37
Done.
| |
288 const WebPluginInfo& web_plugin = web_plugin_infos_[i]; | 335 web_plugin_infos_.begin(); |
289 int priority = web_plugin_positions_[i]; | 336 it != web_plugin_infos_.end(); ++it) { |
337 int priority = it->priority; | |
290 DictionaryValue* plugin_file = new DictionaryValue(); | 338 DictionaryValue* plugin_file = new DictionaryValue(); |
291 plugin_file->SetString("name", web_plugin.name); | 339 plugin_file->SetString("name", it->name); |
292 plugin_file->SetString("description", web_plugin.desc); | 340 plugin_file->SetString("description", it->desc); |
293 plugin_file->SetString("path", web_plugin.path.value()); | 341 plugin_file->SetString("path", it->path.value()); |
294 plugin_file->SetString("version", web_plugin.version); | 342 plugin_file->SetString("version", it->version); |
295 bool plugin_disabled_by_policy = group_disabled_by_policy || | 343 bool plugin_disabled_by_policy = |
296 IsPluginNameDisabledByPolicy(web_plugin.name); | 344 group_disabled_by_policy || it->IsManaged(it->reason); |
297 if (plugin_disabled_by_policy) { | 345 if (plugin_disabled_by_policy) { |
298 plugin_file->SetString("enabledMode", "disabledByPolicy"); | 346 plugin_file->SetString("enabledMode", "disabledByPolicy"); |
299 } else { | 347 } else { |
300 all_plugins_disabled_by_policy = false; | 348 all_plugins_disabled_by_policy = false; |
301 plugin_file->SetString("enabledMode", | 349 plugin_file->SetString("enabledMode", |
302 web_plugin.enabled ? "enabled" : "disabledByUser"); | 350 it->IsEnabled() ? "enabled" : "disabledByUser"); |
303 } | 351 } |
304 plugin_file->SetInteger("priority", priority); | 352 plugin_file->SetInteger("priority", priority); |
305 | 353 |
306 ListValue* mime_types = new ListValue(); | 354 ListValue* mime_types = new ListValue(); |
307 for (std::vector<WebPluginMimeType>::const_iterator type_it = | 355 for (std::vector<WebPluginMimeType>::const_iterator type_it = |
jam
2010/12/17 19:14:45
nit: size_t
pastarmovj
2010/12/20 19:57:37
I would prefer to keep this one an iterator as wel
jam
2010/12/20 20:56:59
you can always create a local const reference, i.e
pastarmovj
2010/12/20 21:47:22
Done.
| |
308 web_plugin.mime_types.begin(); | 356 it->mime_types.begin(); |
309 type_it != web_plugin.mime_types.end(); | 357 type_it != it->mime_types.end(); |
310 ++type_it) { | 358 ++type_it) { |
311 DictionaryValue* mime_type = new DictionaryValue(); | 359 DictionaryValue* mime_type = new DictionaryValue(); |
312 mime_type->SetString("mimeType", type_it->mime_type); | 360 mime_type->SetString("mimeType", type_it->mime_type); |
313 mime_type->SetString("description", type_it->description); | 361 mime_type->SetString("description", type_it->description); |
314 | 362 |
315 ListValue* file_extensions = new ListValue(); | 363 ListValue* file_extensions = new ListValue(); |
316 for (std::vector<std::string>::const_iterator ext_it = | 364 for (std::vector<std::string>::const_iterator ext_it = |
317 type_it->file_extensions.begin(); | 365 type_it->file_extensions.begin(); |
318 ext_it != type_it->file_extensions.end(); | 366 ext_it != type_it->file_extensions.end(); |
319 ++ext_it) { | 367 ++ext_it) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 // Returns true if the latest version of this plugin group is vulnerable. | 411 // Returns true if the latest version of this plugin group is vulnerable. |
364 bool PluginGroup::IsVulnerable() const { | 412 bool PluginGroup::IsVulnerable() const { |
365 for (size_t i = 0; i < version_ranges_.size(); ++i) { | 413 for (size_t i = 0; i < version_ranges_.size(); ++i) { |
366 if (IsPluginOutdated(*version_, version_ranges_[i])) | 414 if (IsPluginOutdated(*version_, version_ranges_[i])) |
367 return true; | 415 return true; |
368 } | 416 } |
369 return false; | 417 return false; |
370 } | 418 } |
371 | 419 |
372 void PluginGroup::DisableOutdatedPlugins() { | 420 void PluginGroup::DisableOutdatedPlugins() { |
373 description_ = string16(); | 421 bool first_enabled = true; |
374 enabled_ = false; | |
375 | 422 |
376 for (std::vector<WebPluginInfo>::iterator it = | 423 for (std::vector<WebPluginInfo>::iterator it = web_plugin_infos_.begin(); |
jam
2010/12/17 19:14:45
nit: size_t
pastarmovj
2010/12/20 19:57:37
Done.
| |
377 web_plugin_infos_.begin(); | 424 it != web_plugin_infos_.end(); ++it) { |
378 it != web_plugin_infos_.end(); ++it) { | |
379 scoped_ptr<Version> version(CreateVersionFromString(it->version)); | 425 scoped_ptr<Version> version(CreateVersionFromString(it->version)); |
380 if (version.get()) { | 426 if (version.get()) { |
427 bool plugin_is_outdated = false; | |
381 for (size_t i = 0; i < version_ranges_.size(); ++i) { | 428 for (size_t i = 0; i < version_ranges_.size(); ++i) { |
382 if (IsPluginOutdated(*version, version_ranges_[i])) { | 429 if (IsPluginOutdated(*version, version_ranges_[i])) { |
383 it->enabled = false; | 430 it->Disable(WebPluginInfo::USER); |
384 NPAPI::PluginList::Singleton()->DisablePlugin(it->path); | 431 plugin_is_outdated = true; |
432 break; | |
385 } | 433 } |
386 } | 434 } |
435 if (!plugin_is_outdated && first_enabled) { | |
436 first_enabled = false; | |
437 UpdateDescriptionAndVersion(*it); | |
438 } | |
387 } | 439 } |
388 UpdateActivePlugin(*it); | |
389 } | 440 } |
390 } | 441 } |
391 | 442 |
392 void PluginGroup::Enable(bool enable) { | 443 bool PluginGroup::Enable(bool enable) { |
393 bool enabled_plugin_exists = false; | 444 bool enabled_plugin_exists = false; |
394 for (std::vector<WebPluginInfo>::iterator it = | 445 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(group_name_); |
395 web_plugin_infos_.begin(); | 446 // We can't enable groups disabled by policy |
447 if (group_disabled_by_policy && enable) | |
448 return false; | |
449 | |
450 for (std::vector<WebPluginInfo>::iterator it = web_plugin_infos_.begin(); | |
jam
2010/12/17 19:14:45
nit: size_t
pastarmovj
2010/12/20 19:57:37
Done.
| |
396 it != web_plugin_infos_.end(); ++it) { | 451 it != web_plugin_infos_.end(); ++it) { |
397 if (enable && !IsPluginNameDisabledByPolicy(it->name)) { | 452 bool policy_disabled = IsPluginNameDisabledByPolicy(it->name); |
398 NPAPI::PluginList::Singleton()->EnablePlugin(it->path); | 453 if (enable && !policy_disabled) { |
399 it->enabled = true; | 454 it->Enable(WebPluginInfo::USER); |
400 enabled_plugin_exists = true; | 455 enabled_plugin_exists = true; |
401 } else { | 456 } else { |
402 it->enabled = false; | 457 it->Disable(policy_disabled || group_disabled_by_policy ? |
403 NPAPI::PluginList::Singleton()->DisablePlugin(it->path); | 458 WebPluginInfo::MANAGED : WebPluginInfo::USER); |
404 } | 459 } |
405 } | 460 } |
406 enabled_ = enabled_plugin_exists; | 461 enabled_ = enabled_plugin_exists; |
462 return enabled_ == enable; | |
463 } | |
464 | |
465 void PluginGroup::RefreshEnabledState() { | |
466 bool enabled_plugin_exists = false; | |
467 for (std::vector<WebPluginInfo>::iterator it = web_plugin_infos_.begin(); | |
jam
2010/12/17 19:14:45
nit: size_t
pastarmovj
2010/12/20 19:57:37
Done.
| |
468 it != web_plugin_infos_.end(); ++it) { | |
469 if (it->IsEnabled()) { | |
470 enabled_plugin_exists = true; | |
471 break; | |
472 } | |
473 } | |
474 enabled_ = enabled_plugin_exists; | |
407 } | 475 } |
OLD | NEW |