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_list.h" | 5 #include "webkit/plugins/npapi/plugin_list.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return g_singleton.Pointer(); | 175 return g_singleton.Pointer(); |
176 } | 176 } |
177 | 177 |
178 // static | 178 // static |
179 bool PluginList::DebugPluginLoading() { | 179 bool PluginList::DebugPluginLoading() { |
180 return CommandLine::ForCurrentProcess()->HasSwitch( | 180 return CommandLine::ForCurrentProcess()->HasSwitch( |
181 switches::kDebugPluginLoading); | 181 switches::kDebugPluginLoading); |
182 } | 182 } |
183 | 183 |
184 bool PluginList::PluginsLoaded() { | 184 bool PluginList::PluginsLoaded() { |
185 AutoLock lock(lock_); | 185 base::AutoLock lock(lock_); |
186 return plugins_loaded_; | 186 return plugins_loaded_; |
187 } | 187 } |
188 | 188 |
189 void PluginList::RefreshPlugins() { | 189 void PluginList::RefreshPlugins() { |
190 AutoLock lock(lock_); | 190 base::AutoLock lock(lock_); |
191 plugins_need_refresh_ = true; | 191 plugins_need_refresh_ = true; |
192 } | 192 } |
193 | 193 |
194 void PluginList::AddExtraPluginPath(const FilePath& plugin_path) { | 194 void PluginList::AddExtraPluginPath(const FilePath& plugin_path) { |
195 // Chrome OS only loads plugins from /opt/google/chrome/plugins. | 195 // Chrome OS only loads plugins from /opt/google/chrome/plugins. |
196 #if !defined(OS_CHROMEOS) | 196 #if !defined(OS_CHROMEOS) |
197 AutoLock lock(lock_); | 197 base::AutoLock lock(lock_); |
198 extra_plugin_paths_.push_back(plugin_path); | 198 extra_plugin_paths_.push_back(plugin_path); |
199 #endif | 199 #endif |
200 } | 200 } |
201 | 201 |
202 void PluginList::RemoveExtraPluginPath(const FilePath& plugin_path) { | 202 void PluginList::RemoveExtraPluginPath(const FilePath& plugin_path) { |
203 AutoLock lock(lock_); | 203 base::AutoLock lock(lock_); |
204 std::vector<FilePath>::iterator it = | 204 std::vector<FilePath>::iterator it = |
205 std::find(extra_plugin_paths_.begin(), extra_plugin_paths_.end(), | 205 std::find(extra_plugin_paths_.begin(), extra_plugin_paths_.end(), |
206 plugin_path); | 206 plugin_path); |
207 if (it != extra_plugin_paths_.end()) | 207 if (it != extra_plugin_paths_.end()) |
208 extra_plugin_paths_.erase(it); | 208 extra_plugin_paths_.erase(it); |
209 } | 209 } |
210 | 210 |
211 void PluginList::AddExtraPluginDir(const FilePath& plugin_dir) { | 211 void PluginList::AddExtraPluginDir(const FilePath& plugin_dir) { |
212 // Chrome OS only loads plugins from /opt/google/chrome/plugins. | 212 // Chrome OS only loads plugins from /opt/google/chrome/plugins. |
213 #if !defined(OS_CHROMEOS) | 213 #if !defined(OS_CHROMEOS) |
214 AutoLock lock(lock_); | 214 base::AutoLock lock(lock_); |
215 extra_plugin_dirs_.push_back(plugin_dir); | 215 extra_plugin_dirs_.push_back(plugin_dir); |
216 #endif | 216 #endif |
217 } | 217 } |
218 | 218 |
219 void PluginList::RegisterInternalPlugin(const PluginVersionInfo& info) { | 219 void PluginList::RegisterInternalPlugin(const PluginVersionInfo& info) { |
220 AutoLock lock(lock_); | 220 base::AutoLock lock(lock_); |
221 internal_plugins_.push_back(info); | 221 internal_plugins_.push_back(info); |
222 } | 222 } |
223 | 223 |
224 void PluginList::RegisterInternalPlugin(const FilePath& path) { | 224 void PluginList::RegisterInternalPlugin(const FilePath& path) { |
225 webkit::npapi::PluginVersionInfo info; | 225 webkit::npapi::PluginVersionInfo info; |
226 info.path = path; | 226 info.path = path; |
227 memset(&info.entry_points, 0, sizeof(info.entry_points)); | 227 memset(&info.entry_points, 0, sizeof(info.entry_points)); |
228 RegisterInternalPlugin(info); | 228 RegisterInternalPlugin(info); |
229 } | 229 } |
230 | 230 |
231 void PluginList::RegisterInternalPlugin(const FilePath& filename, | 231 void PluginList::RegisterInternalPlugin(const FilePath& filename, |
232 const std::string& name, | 232 const std::string& name, |
233 const std::string& description, | 233 const std::string& description, |
234 const std::string& mime_type, | 234 const std::string& mime_type, |
235 const PluginEntryPoints& entry_points) { | 235 const PluginEntryPoints& entry_points) { |
236 webkit::npapi::PluginVersionInfo info = { | 236 webkit::npapi::PluginVersionInfo info = { |
237 filename, | 237 filename, |
238 ASCIIToWide(name), | 238 ASCIIToWide(name), |
239 ASCIIToWide(description), | 239 ASCIIToWide(description), |
240 L"1", | 240 L"1", |
241 ASCIIToWide(mime_type), | 241 ASCIIToWide(mime_type), |
242 L"", | 242 L"", |
243 L"", | 243 L"", |
244 entry_points | 244 entry_points |
245 }; | 245 }; |
246 RegisterInternalPlugin(info); | 246 RegisterInternalPlugin(info); |
247 } | 247 } |
248 | 248 |
249 void PluginList::UnregisterInternalPlugin(const FilePath& path) { | 249 void PluginList::UnregisterInternalPlugin(const FilePath& path) { |
250 AutoLock lock(lock_); | 250 base::AutoLock lock(lock_); |
251 for (size_t i = 0; i < internal_plugins_.size(); i++) { | 251 for (size_t i = 0; i < internal_plugins_.size(); i++) { |
252 if (internal_plugins_[i].path == path) { | 252 if (internal_plugins_[i].path == path) { |
253 internal_plugins_.erase(internal_plugins_.begin() + i); | 253 internal_plugins_.erase(internal_plugins_.begin() + i); |
254 return; | 254 return; |
255 } | 255 } |
256 } | 256 } |
257 NOTREACHED(); | 257 NOTREACHED(); |
258 } | 258 } |
259 | 259 |
260 bool PluginList::ReadPluginInfo(const FilePath& filename, | 260 bool PluginList::ReadPluginInfo(const FilePath& filename, |
261 WebPluginInfo* info, | 261 WebPluginInfo* info, |
262 const PluginEntryPoints** entry_points) { | 262 const PluginEntryPoints** entry_points) { |
263 { | 263 { |
264 AutoLock lock(lock_); | 264 base::AutoLock lock(lock_); |
265 for (size_t i = 0; i < internal_plugins_.size(); ++i) { | 265 for (size_t i = 0; i < internal_plugins_.size(); ++i) { |
266 if (filename == internal_plugins_[i].path) { | 266 if (filename == internal_plugins_[i].path) { |
267 *entry_points = &internal_plugins_[i].entry_points; | 267 *entry_points = &internal_plugins_[i].entry_points; |
268 return CreateWebPluginInfo(internal_plugins_[i], info); | 268 return CreateWebPluginInfo(internal_plugins_[i], info); |
269 } | 269 } |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 // Not an internal plugin. | 273 // Not an internal plugin. |
274 *entry_points = NULL; | 274 *entry_points = NULL; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 PluginList::PluginList() | 328 PluginList::PluginList() |
329 : plugins_loaded_(false), | 329 : plugins_loaded_(false), |
330 plugins_need_refresh_(false), | 330 plugins_need_refresh_(false), |
331 disable_outdated_plugins_(false), | 331 disable_outdated_plugins_(false), |
332 next_priority_(0) { | 332 next_priority_(0) { |
333 PlatformInit(); | 333 PlatformInit(); |
334 AddHardcodedPluginGroups(); | 334 AddHardcodedPluginGroups(); |
335 } | 335 } |
336 | 336 |
337 bool PluginList::ShouldDisableGroup(const string16& group_name) { | 337 bool PluginList::ShouldDisableGroup(const string16& group_name) { |
338 AutoLock lock(lock_); | 338 base::AutoLock lock(lock_); |
339 if (PluginGroup::IsPluginNameDisabledByPolicy(group_name)) { | 339 if (PluginGroup::IsPluginNameDisabledByPolicy(group_name)) { |
340 disabled_groups_.insert(group_name); | 340 disabled_groups_.insert(group_name); |
341 return true; | 341 return true; |
342 } | 342 } |
343 return disabled_groups_.count(group_name) > 0; | 343 return disabled_groups_.count(group_name) > 0; |
344 } | 344 } |
345 | 345 |
346 void PluginList::LoadPlugins(bool refresh) { | 346 void PluginList::LoadPlugins(bool refresh) { |
347 // Don't want to hold the lock while loading new plugins, so we don't block | 347 // Don't want to hold the lock while loading new plugins, so we don't block |
348 // other methods if they're called on other threads. | 348 // other methods if they're called on other threads. |
349 std::vector<FilePath> extra_plugin_paths; | 349 std::vector<FilePath> extra_plugin_paths; |
350 std::vector<FilePath> extra_plugin_dirs; | 350 std::vector<FilePath> extra_plugin_dirs; |
351 std::vector<PluginVersionInfo> internal_plugins; | 351 std::vector<PluginVersionInfo> internal_plugins; |
352 { | 352 { |
353 AutoLock lock(lock_); | 353 base::AutoLock lock(lock_); |
354 if (plugins_loaded_ && !refresh && !plugins_need_refresh_) | 354 if (plugins_loaded_ && !refresh && !plugins_need_refresh_) |
355 return; | 355 return; |
356 | 356 |
357 // Clear the refresh bit now, because it might get set again before we | 357 // Clear the refresh bit now, because it might get set again before we |
358 // reach the end of the method. | 358 // reach the end of the method. |
359 plugins_need_refresh_ = false; | 359 plugins_need_refresh_ = false; |
360 extra_plugin_paths = extra_plugin_paths_; | 360 extra_plugin_paths = extra_plugin_paths_; |
361 extra_plugin_dirs = extra_plugin_dirs_; | 361 extra_plugin_dirs = extra_plugin_dirs_; |
362 internal_plugins = internal_plugins_; | 362 internal_plugins = internal_plugins_; |
363 } | 363 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 PluginGroup* group = it->second; | 411 PluginGroup* group = it->second; |
412 string16 group_name = group->GetGroupName(); | 412 string16 group_name = group->GetGroupName(); |
413 if (ShouldDisableGroup(group_name)) { | 413 if (ShouldDisableGroup(group_name)) { |
414 group->Enable(false); | 414 group->Enable(false); |
415 } | 415 } |
416 | 416 |
417 if (disable_outdated_plugins_) { | 417 if (disable_outdated_plugins_) { |
418 group->DisableOutdatedPlugins(); | 418 group->DisableOutdatedPlugins(); |
419 } | 419 } |
420 if (!group->Enabled()) { | 420 if (!group->Enabled()) { |
421 AutoLock lock(lock_); | 421 base::AutoLock lock(lock_); |
422 disabled_groups_.insert(group_name); | 422 disabled_groups_.insert(group_name); |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 // Only update the data now since loading plugins can take a while. | 426 // Only update the data now since loading plugins can take a while. |
427 AutoLock lock(lock_); | 427 base::AutoLock lock(lock_); |
428 | 428 |
429 plugins_ = new_plugins; | 429 plugins_ = new_plugins; |
430 plugins_loaded_ = true; | 430 plugins_loaded_ = true; |
431 } | 431 } |
432 | 432 |
433 void PluginList::LoadPlugin(const FilePath& path, | 433 void PluginList::LoadPlugin(const FilePath& path, |
434 std::vector<WebPluginInfo>* plugins) { | 434 std::vector<WebPluginInfo>* plugins) { |
435 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 435 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
436 << "Loading plugin " << path.value(); | 436 << "Loading plugin " << path.value(); |
437 | 437 |
(...skipping 22 matching lines...) Expand all Loading... |
460 } | 460 } |
461 | 461 |
462 // Mark disabled plugins as such. (This has to happen before calling | 462 // Mark disabled plugins as such. (This has to happen before calling |
463 // |AddToPluginGroups(plugin_info)|.) | 463 // |AddToPluginGroups(plugin_info)|.) |
464 if (disabled_plugins_.count(plugin_info.path)) { | 464 if (disabled_plugins_.count(plugin_info.path)) { |
465 plugin_info.enabled = false; | 465 plugin_info.enabled = false; |
466 } else { | 466 } else { |
467 plugin_info.enabled = true; | 467 plugin_info.enabled = true; |
468 } | 468 } |
469 | 469 |
470 AutoLock lock(lock_); | 470 base::AutoLock lock(lock_); |
471 plugins->push_back(plugin_info); | 471 plugins->push_back(plugin_info); |
472 AddToPluginGroups(plugin_info); | 472 AddToPluginGroups(plugin_info); |
473 } | 473 } |
474 | 474 |
475 bool PluginList::SupportsType(const WebPluginInfo& info, | 475 bool PluginList::SupportsType(const WebPluginInfo& info, |
476 const std::string &mime_type, | 476 const std::string &mime_type, |
477 bool allow_wildcard) { | 477 bool allow_wildcard) { |
478 // Webkit will ask for a plugin to handle empty mime types. | 478 // Webkit will ask for a plugin to handle empty mime types. |
479 if (mime_type.empty()) | 479 if (mime_type.empty()) |
480 return false; | 480 return false; |
(...skipping 24 matching lines...) Expand all Loading... |
505 } | 505 } |
506 } | 506 } |
507 | 507 |
508 return false; | 508 return false; |
509 } | 509 } |
510 | 510 |
511 | 511 |
512 void PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { | 512 void PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { |
513 LoadPlugins(refresh); | 513 LoadPlugins(refresh); |
514 | 514 |
515 AutoLock lock(lock_); | 515 base::AutoLock lock(lock_); |
516 *plugins = plugins_; | 516 *plugins = plugins_; |
517 } | 517 } |
518 | 518 |
519 void PluginList::GetEnabledPlugins(bool refresh, | 519 void PluginList::GetEnabledPlugins(bool refresh, |
520 std::vector<WebPluginInfo>* plugins) { | 520 std::vector<WebPluginInfo>* plugins) { |
521 LoadPlugins(refresh); | 521 LoadPlugins(refresh); |
522 | 522 |
523 plugins->clear(); | 523 plugins->clear(); |
524 AutoLock lock(lock_); | 524 base::AutoLock lock(lock_); |
525 for (std::vector<WebPluginInfo>::const_iterator it = plugins_.begin(); | 525 for (std::vector<WebPluginInfo>::const_iterator it = plugins_.begin(); |
526 it != plugins_.end(); | 526 it != plugins_.end(); |
527 ++it) { | 527 ++it) { |
528 if (it->enabled) | 528 if (it->enabled) |
529 plugins->push_back(*it); | 529 plugins->push_back(*it); |
530 } | 530 } |
531 } | 531 } |
532 | 532 |
533 void PluginList::GetPluginInfoArray( | 533 void PluginList::GetPluginInfoArray( |
534 const GURL& url, | 534 const GURL& url, |
535 const std::string& mime_type, | 535 const std::string& mime_type, |
536 bool allow_wildcard, | 536 bool allow_wildcard, |
537 std::vector<WebPluginInfo>* info, | 537 std::vector<WebPluginInfo>* info, |
538 std::vector<std::string>* actual_mime_types) { | 538 std::vector<std::string>* actual_mime_types) { |
539 DCHECK(mime_type == StringToLowerASCII(mime_type)); | 539 DCHECK(mime_type == StringToLowerASCII(mime_type)); |
540 DCHECK(info); | 540 DCHECK(info); |
541 | 541 |
542 LoadPlugins(false); | 542 LoadPlugins(false); |
543 AutoLock lock(lock_); | 543 base::AutoLock lock(lock_); |
544 info->clear(); | 544 info->clear(); |
545 if (actual_mime_types) | 545 if (actual_mime_types) |
546 actual_mime_types->clear(); | 546 actual_mime_types->clear(); |
547 | 547 |
548 std::set<FilePath> visited_plugins; | 548 std::set<FilePath> visited_plugins; |
549 | 549 |
550 // Add in enabled plugins by mime type. | 550 // Add in enabled plugins by mime type. |
551 WebPluginInfo default_plugin; | 551 WebPluginInfo default_plugin; |
552 for (size_t i = 0; i < plugins_.size(); ++i) { | 552 for (size_t i = 0; i < plugins_.size(); ++i) { |
553 if (plugins_[i].enabled && | 553 if (plugins_[i].enabled && |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 *info = info_list[0]; | 633 *info = info_list[0]; |
634 return true; | 634 return true; |
635 } | 635 } |
636 } | 636 } |
637 return false; | 637 return false; |
638 } | 638 } |
639 | 639 |
640 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, | 640 bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, |
641 WebPluginInfo* info) { | 641 WebPluginInfo* info) { |
642 LoadPlugins(false); | 642 LoadPlugins(false); |
643 AutoLock lock(lock_); | 643 base::AutoLock lock(lock_); |
644 for (size_t i = 0; i < plugins_.size(); ++i) { | 644 for (size_t i = 0; i < plugins_.size(); ++i) { |
645 if (plugins_[i].path == plugin_path) { | 645 if (plugins_[i].path == plugin_path) { |
646 *info = plugins_[i]; | 646 *info = plugins_[i]; |
647 return true; | 647 return true; |
648 } | 648 } |
649 } | 649 } |
650 | 650 |
651 return false; | 651 return false; |
652 } | 652 } |
653 | 653 |
654 void PluginList::GetPluginGroups( | 654 void PluginList::GetPluginGroups( |
655 bool load_if_necessary, | 655 bool load_if_necessary, |
656 std::vector<PluginGroup>* plugin_groups) { | 656 std::vector<PluginGroup>* plugin_groups) { |
657 if (load_if_necessary) | 657 if (load_if_necessary) |
658 LoadPlugins(false); | 658 LoadPlugins(false); |
659 plugin_groups->clear(); | 659 plugin_groups->clear(); |
660 for (PluginGroup::PluginMap::const_iterator it = plugin_groups_.begin(); | 660 for (PluginGroup::PluginMap::const_iterator it = plugin_groups_.begin(); |
661 it != plugin_groups_.end(); ++it) { | 661 it != plugin_groups_.end(); ++it) { |
662 if (!it->second->IsEmpty()) | 662 if (!it->second->IsEmpty()) |
663 plugin_groups->push_back(*it->second); | 663 plugin_groups->push_back(*it->second); |
664 } | 664 } |
665 } | 665 } |
666 | 666 |
667 const PluginGroup* PluginList::GetPluginGroup( | 667 const PluginGroup* PluginList::GetPluginGroup( |
668 const WebPluginInfo& web_plugin_info) { | 668 const WebPluginInfo& web_plugin_info) { |
669 AutoLock lock(lock_); | 669 base::AutoLock lock(lock_); |
670 return AddToPluginGroups(web_plugin_info); | 670 return AddToPluginGroups(web_plugin_info); |
671 } | 671 } |
672 | 672 |
673 string16 PluginList::GetPluginGroupName(std::string identifier) { | 673 string16 PluginList::GetPluginGroupName(std::string identifier) { |
674 PluginGroup::PluginMap::iterator it = plugin_groups_.find(identifier); | 674 PluginGroup::PluginMap::iterator it = plugin_groups_.find(identifier); |
675 if (it == plugin_groups_.end()) { | 675 if (it == plugin_groups_.end()) { |
676 return string16(); | 676 return string16(); |
677 } | 677 } |
678 return it->second->GetGroupName(); | 678 return it->second->GetGroupName(); |
679 } | 679 } |
680 | 680 |
681 std::string PluginList::GetPluginGroupIdentifier( | 681 std::string PluginList::GetPluginGroupIdentifier( |
682 const WebPluginInfo& web_plugin_info) { | 682 const WebPluginInfo& web_plugin_info) { |
683 AutoLock lock(lock_); | 683 base::AutoLock lock(lock_); |
684 PluginGroup* group = AddToPluginGroups(web_plugin_info); | 684 PluginGroup* group = AddToPluginGroups(web_plugin_info); |
685 return group->identifier(); | 685 return group->identifier(); |
686 } | 686 } |
687 | 687 |
688 void PluginList::AddHardcodedPluginGroups() { | 688 void PluginList::AddHardcodedPluginGroups() { |
689 AutoLock lock(lock_); | 689 base::AutoLock lock(lock_); |
690 const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); | 690 const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); |
691 for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { | 691 for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { |
692 PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( | 692 PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( |
693 definitions[i]); | 693 definitions[i]); |
694 std::string identifier = definition_group->identifier(); | 694 std::string identifier = definition_group->identifier(); |
695 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); | 695 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); |
696 plugin_groups_.insert(std::make_pair(identifier, definition_group)); | 696 plugin_groups_.insert(std::make_pair(identifier, definition_group)); |
697 } | 697 } |
698 } | 698 } |
699 | 699 |
(...skipping 17 matching lines...) Expand all Loading... |
717 if (plugin_groups_.find(identifier) != plugin_groups_.end()) | 717 if (plugin_groups_.find(identifier) != plugin_groups_.end()) |
718 identifier = PluginGroup::GetLongIdentifier(web_plugin_info); | 718 identifier = PluginGroup::GetLongIdentifier(web_plugin_info); |
719 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); | 719 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); |
720 plugin_groups_.insert(std::make_pair(identifier, group)); | 720 plugin_groups_.insert(std::make_pair(identifier, group)); |
721 } | 721 } |
722 group->AddPlugin(web_plugin_info, next_priority_++); | 722 group->AddPlugin(web_plugin_info, next_priority_++); |
723 return group; | 723 return group; |
724 } | 724 } |
725 | 725 |
726 bool PluginList::EnablePlugin(const FilePath& filename) { | 726 bool PluginList::EnablePlugin(const FilePath& filename) { |
727 AutoLock lock(lock_); | 727 base::AutoLock lock(lock_); |
728 | 728 |
729 bool did_enable = false; | 729 bool did_enable = false; |
730 | 730 |
731 std::set<FilePath>::iterator entry = disabled_plugins_.find(filename); | 731 std::set<FilePath>::iterator entry = disabled_plugins_.find(filename); |
732 if (entry == disabled_plugins_.end()) | 732 if (entry == disabled_plugins_.end()) |
733 return did_enable; // Early exit if plugin not in disabled list. | 733 return did_enable; // Early exit if plugin not in disabled list. |
734 | 734 |
735 disabled_plugins_.erase(entry); // Remove from disabled list. | 735 disabled_plugins_.erase(entry); // Remove from disabled list. |
736 | 736 |
737 // Set enabled flags if necessary. | 737 // Set enabled flags if necessary. |
738 for (std::vector<WebPluginInfo>::iterator it = plugins_.begin(); | 738 for (std::vector<WebPluginInfo>::iterator it = plugins_.begin(); |
739 it != plugins_.end(); | 739 it != plugins_.end(); |
740 ++it) { | 740 ++it) { |
741 if (it->path == filename) { | 741 if (it->path == filename) { |
742 DCHECK(!it->enabled); // Should have been disabled. | 742 DCHECK(!it->enabled); // Should have been disabled. |
743 it->enabled = true; | 743 it->enabled = true; |
744 did_enable = true; | 744 did_enable = true; |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 return did_enable; | 748 return did_enable; |
749 } | 749 } |
750 | 750 |
751 bool PluginList::DisablePlugin(const FilePath& filename) { | 751 bool PluginList::DisablePlugin(const FilePath& filename) { |
752 AutoLock lock(lock_); | 752 base::AutoLock lock(lock_); |
753 | 753 |
754 bool did_disable = false; | 754 bool did_disable = false; |
755 | 755 |
756 if (disabled_plugins_.find(filename) != disabled_plugins_.end()) | 756 if (disabled_plugins_.find(filename) != disabled_plugins_.end()) |
757 return did_disable; // Early exit if plugin already in disabled list. | 757 return did_disable; // Early exit if plugin already in disabled list. |
758 | 758 |
759 disabled_plugins_.insert(filename); // Add to disabled list. | 759 disabled_plugins_.insert(filename); // Add to disabled list. |
760 | 760 |
761 // Unset enabled flags if necessary. | 761 // Unset enabled flags if necessary. |
762 for (std::vector<WebPluginInfo>::iterator it = plugins_.begin(); | 762 for (std::vector<WebPluginInfo>::iterator it = plugins_.begin(); |
763 it != plugins_.end(); | 763 it != plugins_.end(); |
764 ++it) { | 764 ++it) { |
765 if (it->path == filename) { | 765 if (it->path == filename) { |
766 DCHECK(it->enabled); // Should have been enabled. | 766 DCHECK(it->enabled); // Should have been enabled. |
767 it->enabled = false; | 767 it->enabled = false; |
768 did_disable = true; | 768 did_disable = true; |
769 } | 769 } |
770 } | 770 } |
771 | 771 |
772 return did_disable; | 772 return did_disable; |
773 } | 773 } |
774 | 774 |
775 bool PluginList::EnableGroup(bool enable, const string16& group_name) { | 775 bool PluginList::EnableGroup(bool enable, const string16& group_name) { |
776 bool did_change = false; | 776 bool did_change = false; |
777 { | 777 { |
778 AutoLock lock(lock_); | 778 base::AutoLock lock(lock_); |
779 | 779 |
780 std::set<string16>::iterator entry = disabled_groups_.find(group_name); | 780 std::set<string16>::iterator entry = disabled_groups_.find(group_name); |
781 if (enable) { | 781 if (enable) { |
782 if (entry == disabled_groups_.end()) | 782 if (entry == disabled_groups_.end()) |
783 return did_change; // Early exit if group not in disabled list. | 783 return did_change; // Early exit if group not in disabled list. |
784 disabled_groups_.erase(entry); // Remove from disabled list. | 784 disabled_groups_.erase(entry); // Remove from disabled list. |
785 } else { | 785 } else { |
786 if (entry != disabled_groups_.end()) | 786 if (entry != disabled_groups_.end()) |
787 return did_change; // Early exit if group already in disabled list. | 787 return did_change; // Early exit if group already in disabled list. |
788 disabled_groups_.insert(group_name); | 788 disabled_groups_.insert(group_name); |
(...skipping 22 matching lines...) Expand all Loading... |
811 Shutdown(); | 811 Shutdown(); |
812 } | 812 } |
813 | 813 |
814 void PluginList::Shutdown() { | 814 void PluginList::Shutdown() { |
815 STLDeleteContainerPairSecondPointers(plugin_groups_.begin(), | 815 STLDeleteContainerPairSecondPointers(plugin_groups_.begin(), |
816 plugin_groups_.end()); | 816 plugin_groups_.end()); |
817 } | 817 } |
818 | 818 |
819 } // namespace npapi | 819 } // namespace npapi |
820 } // namespace webkit | 820 } // namespace webkit |
OLD | NEW |