Chromium Code Reviews| 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/plugin_prefs.h" | 5 #include "chrome/browser/plugin_prefs.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "base/version.h" | 19 #include "base/version.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/plugin_installer.h" | |
| 21 #include "chrome/browser/plugin_prefs_factory.h" | 22 #include "chrome/browser/plugin_prefs_factory.h" |
| 22 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/profiles/profile_keyed_service.h" | 25 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/common/chrome_content_client.h" | 27 #include "chrome/common/chrome_content_client.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 if (--outstanding_callbacks_ == 0) { | 71 if (--outstanding_callbacks_ == 0) { |
| 71 callback_.Run(); | 72 callback_.Run(); |
| 72 callback_.Reset(); | 73 callback_.Reset(); |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 base::Closure callback_; | 77 base::Closure callback_; |
| 77 int outstanding_callbacks_; | 78 int outstanding_callbacks_; |
| 78 }; | 79 }; |
| 79 | 80 |
| 81 // A callback function that does nothing. | |
|
Pam (message me for reviews)
2012/08/27 13:18:05
This comment doesn't add any information. Please e
ibraaaa
2012/08/28 09:25:52
Done.
| |
| 82 void CanEnablePluginCallbackDoNothing(bool dummy) { | |
|
Bernhard Bauer
2012/08/29 12:56:36
This is available as base::DoNothing() in base/bin
ibraaaa
2012/08/29 15:35:50
It doesn't take bool parameter, does it?
On 2012/0
| |
| 83 } | |
| 84 | |
| 80 } // namespace | 85 } // namespace |
| 81 | 86 |
| 82 // How long to wait to save the plugin enabled information, which might need to | 87 // How long to wait to save the plugin enabled information, which might need to |
| 83 // go to disk. | 88 // go to disk. |
| 84 #define kPluginUpdateDelayMs (60 * 1000) | 89 #define kPluginUpdateDelayMs (60 * 1000) |
| 85 | 90 |
| 86 // static | 91 // static |
| 87 scoped_refptr<PluginPrefs> PluginPrefs::GetForProfile(Profile* profile) { | 92 scoped_refptr<PluginPrefs> PluginPrefs::GetForProfile(Profile* profile) { |
| 88 return PluginPrefsFactory::GetPrefsForProfile(profile); | 93 return PluginPrefsFactory::GetPrefsForProfile(profile); |
| 89 } | 94 } |
| 90 | 95 |
| 91 // static | 96 // static |
| 92 scoped_refptr<PluginPrefs> PluginPrefs::GetForTestingProfile( | 97 scoped_refptr<PluginPrefs> PluginPrefs::GetForTestingProfile( |
| 93 Profile* profile) { | 98 Profile* profile) { |
| 94 return static_cast<PluginPrefs*>( | 99 return static_cast<PluginPrefs*>( |
| 95 PluginPrefsFactory::GetInstance()->SetTestingFactoryAndUse( | 100 PluginPrefsFactory::GetInstance()->SetTestingFactoryAndUse( |
| 96 profile, &PluginPrefsFactory::CreateForTestingProfile).get()); | 101 profile, &PluginPrefsFactory::CreateForTestingProfile).get()); |
| 97 } | 102 } |
| 98 | 103 |
| 99 void PluginPrefs::SetPluginListForTesting( | 104 void PluginPrefs::SetPluginListForTesting( |
| 100 webkit::npapi::PluginList* plugin_list) { | 105 webkit::npapi::PluginList* plugin_list) { |
| 101 plugin_list_ = plugin_list; | 106 plugin_list_ = plugin_list; |
| 102 } | 107 } |
| 103 | 108 |
| 104 void PluginPrefs::EnablePluginGroup(bool enabled, const string16& group_name) { | 109 void PluginPrefs::EnablePluginGroup(bool enabled, const string16& group_name) { |
| 105 PluginService::GetInstance()->GetPluginGroups( | 110 PluginFinder::Get( |
| 106 base::Bind(&PluginPrefs::EnablePluginGroupInternal, | 111 base::Bind(&PluginPrefs::GetPluginFinderForEnablePluginGroup, |
| 107 this, enabled, group_name)); | 112 this, enabled, group_name)); |
| 113 } | |
| 114 | |
| 115 void PluginPrefs::GetPluginFinderForEnablePluginGroup( | |
| 116 bool enabled, | |
| 117 const string16& group_name, | |
| 118 PluginFinder* finder) { | |
| 119 PluginService::GetInstance()->GetPlugins( | |
| 120 base::Bind(&PluginPrefs::EnablePluginGroupInternal, | |
| 121 this, enabled, group_name, finder)); | |
| 108 } | 122 } |
| 109 | 123 |
| 110 void PluginPrefs::EnablePluginGroupInternal( | 124 void PluginPrefs::EnablePluginGroupInternal( |
| 111 bool enabled, | 125 bool enabled, |
| 112 const string16& group_name, | 126 const string16& group_name, |
| 113 const std::vector<webkit::npapi::PluginGroup>& groups) { | 127 PluginFinder* finder, |
| 128 const std::vector<webkit::WebPluginInfo>& plugins) { | |
| 114 base::AutoLock auto_lock(lock_); | 129 base::AutoLock auto_lock(lock_); |
| 115 | 130 |
| 116 // Set the desired state for the group. | 131 // Set the desired state for the group. |
| 117 plugin_group_state_[group_name] = enabled; | 132 plugin_group_state_[group_name] = enabled; |
| 118 | 133 |
| 119 // Update the state for all plug-ins in the group. | 134 // Update the state for all plug-ins in the group. |
| 120 for (size_t i = 0; i < groups.size(); ++i) { | 135 for (size_t i = 0; i < plugins.size(); ++i) { |
| 121 if (groups[i].GetGroupName() != group_name) | 136 PluginInstaller* installer = finder->GetPluginInstaller(plugins[i]); |
| 137 if (group_name != installer->name()) | |
| 122 continue; | 138 continue; |
| 123 const std::vector<webkit::WebPluginInfo>& plugins = | 139 plugin_state_[plugins[i].path] = enabled; |
| 124 groups[i].web_plugin_infos(); | |
| 125 for (size_t j = 0; j < plugins.size(); ++j) | |
| 126 plugin_state_[plugins[j].path] = enabled; | |
| 127 break; | |
| 128 } | 140 } |
| 129 | 141 |
| 130 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 142 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 131 base::Bind(&PluginPrefs::OnUpdatePreferences, this, groups)); | 143 base::Bind(&PluginPrefs::OnUpdatePreferences, this, plugins, finder)); |
| 132 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 144 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 133 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); | 145 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); |
| 134 } | 146 } |
| 135 | 147 |
| 136 bool PluginPrefs::CanEnablePlugin(bool enabled, const FilePath& path) { | 148 void PluginPrefs::EnablePluginIfPossibleCallback( |
|
Bernhard Bauer
2012/08/29 12:56:36
I still don't think we need two separate callbacks
ibraaaa
2012/08/29 15:35:50
I wanted to keep the exact same interface but I gu
| |
| 137 webkit::npapi::PluginList* plugin_list = GetPluginList(); | 149 bool enabled, const FilePath& path, |
| 150 const base::Closure& enableCallback, | |
| 151 const base::Callback<void(bool)>& canEnableCallback, | |
| 152 PluginFinder* finder) { | |
| 138 webkit::WebPluginInfo plugin; | 153 webkit::WebPluginInfo plugin; |
| 154 bool can_enable = true; | |
| 139 if (PluginService::GetInstance()->GetPluginInfoByPath(path, &plugin)) { | 155 if (PluginService::GetInstance()->GetPluginInfoByPath(path, &plugin)) { |
| 140 scoped_ptr<webkit::npapi::PluginGroup> group( | 156 PluginInstaller* installer = finder->GetPluginInstaller(plugin); |
| 141 plugin_list->GetPluginGroup(plugin)); | |
| 142 PolicyStatus plugin_status = PolicyStatusForPlugin(plugin.name); | 157 PolicyStatus plugin_status = PolicyStatusForPlugin(plugin.name); |
| 143 PolicyStatus group_status = PolicyStatusForPlugin(group->GetGroupName()); | 158 PolicyStatus group_status = PolicyStatusForPlugin(installer->name()); |
| 144 if (enabled) { | 159 if (enabled) { |
| 145 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED) | 160 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED) |
| 146 return false; | 161 can_enable = false; |
| 147 } else { | 162 } else { |
| 148 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED) | 163 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED) |
| 149 return false; | 164 can_enable = false; |
| 150 } | 165 } |
| 151 } else { | 166 } else { |
| 152 NOTREACHED(); | 167 NOTREACHED(); |
| 153 } | 168 } |
| 154 return true; | 169 |
| 170 canEnableCallback.Run(can_enable); | |
| 171 | |
| 172 if (!can_enable) | |
| 173 return; | |
| 174 | |
| 175 PluginService::GetInstance()->GetPlugins( | |
| 176 base::Bind(&PluginPrefs::EnablePluginInternal, this, | |
| 177 enabled, path, finder, enableCallback)); | |
| 155 } | 178 } |
| 156 | 179 |
| 157 void PluginPrefs::EnablePlugin(bool enabled, const FilePath& path, | 180 void PluginPrefs::EnablePlugin( |
| 158 const base::Closure& callback) { | 181 bool enabled, const FilePath& path, |
| 159 PluginService::GetInstance()->GetPluginGroups( | 182 const base::Closure& enableCallback, |
| 160 base::Bind(&PluginPrefs::EnablePluginInternal, this, | 183 const base::Callback<void(bool)>& canEnableCallback) { |
| 161 enabled, path, callback)); | 184 PluginFinder::Get(base::Bind(&PluginPrefs::EnablePluginIfPossibleCallback, |
| 185 this, enabled, path, enableCallback, | |
| 186 canEnableCallback)); | |
| 162 } | 187 } |
| 163 | 188 |
| 164 void PluginPrefs::EnablePluginInternal( | 189 void PluginPrefs::EnablePluginInternal( |
| 165 bool enabled, | 190 bool enabled, |
| 166 const FilePath& path, | 191 const FilePath& path, |
| 192 PluginFinder* plugin_finder, | |
| 167 const base::Closure& callback, | 193 const base::Closure& callback, |
| 168 const std::vector<webkit::npapi::PluginGroup>& groups) { | 194 const std::vector<webkit::WebPluginInfo>& plugins) { |
| 169 { | 195 { |
| 170 // Set the desired state for the plug-in. | 196 // Set the desired state for the plug-in. |
| 171 base::AutoLock auto_lock(lock_); | 197 base::AutoLock auto_lock(lock_); |
| 172 plugin_state_[path] = enabled; | 198 plugin_state_[path] = enabled; |
| 173 } | 199 } |
| 174 | 200 |
| 175 bool found_group = false; | 201 string16 group_name; |
| 176 for (size_t i = 0; i < groups.size(); ++i) { | 202 for (size_t i = 0; i < plugins.size(); ++i) { |
| 177 bool all_disabled = true; | 203 if (plugins[i].path == path) { |
| 178 const std::vector<webkit::WebPluginInfo>& plugins = | 204 PluginInstaller* installer = |
| 179 groups[i].web_plugin_infos(); | 205 plugin_finder->GetPluginInstaller(plugins[i]); |
| 180 for (size_t j = 0; j < plugins.size(); ++j) { | 206 // set the group name for this plug-in. |
| 181 all_disabled = all_disabled && !IsPluginEnabled(plugins[j]); | 207 group_name = installer->name(); |
| 182 if (plugins[j].path == path) { | 208 DCHECK_EQ(enabled, IsPluginEnabled(plugins[i])); |
| 183 found_group = true; | |
| 184 DCHECK_EQ(enabled, IsPluginEnabled(plugins[j])); | |
| 185 } | |
| 186 } | |
| 187 if (found_group) { | |
| 188 // Update the state for the corresponding plug-in group. | |
| 189 base::AutoLock auto_lock(lock_); | |
| 190 plugin_group_state_[groups[i].GetGroupName()] = !all_disabled; | |
| 191 break; | 209 break; |
| 192 } | 210 } |
| 193 } | 211 } |
| 194 | 212 |
| 213 bool all_disabled = true; | |
| 214 for (size_t i = 0; i < plugins.size(); ++i) { | |
| 215 PluginInstaller* installer = plugin_finder->GetPluginInstaller(plugins[i]); | |
| 216 // The check !group_name.empty() is only a sanity check since | |
| 217 // GetPluginInstaller will always return a non-empty name. | |
|
Bernhard Bauer
2012/08/29 12:56:36
If that is the case, then you should DCHECK, I gue
ibraaaa
2012/08/29 15:35:50
Added, however let me confirm if we can have a plu
| |
| 218 if (!group_name.empty() && group_name == installer->name()) { | |
| 219 all_disabled = all_disabled && !IsPluginEnabled(plugins[i]); | |
| 220 } | |
| 221 } | |
| 222 | |
| 223 if (!group_name.empty()) { | |
| 224 // Update the state for the corresponding plug-in group. | |
| 225 base::AutoLock auto_lock(lock_); | |
| 226 plugin_group_state_[group_name] = !all_disabled; | |
| 227 } | |
| 228 | |
| 195 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 229 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 196 base::Bind(&PluginPrefs::OnUpdatePreferences, this, groups)); | 230 base::Bind(&PluginPrefs::OnUpdatePreferences, this, |
| 231 plugins, plugin_finder)); | |
| 197 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 232 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 198 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); | 233 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); |
| 199 callback.Run(); | 234 callback.Run(); |
| 200 } | 235 } |
| 201 | 236 |
| 202 // static | 237 // static |
| 203 void PluginPrefs::EnablePluginGlobally(bool enable, const FilePath& file_path, | 238 void PluginPrefs::EnablePluginGlobally(bool enable, const FilePath& file_path, |
| 204 const base::Closure& callback) { | 239 const base::Closure& callback) { |
| 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 206 g_default_plugin_state.Get()[file_path] = enable; | 241 g_default_plugin_state.Get()[file_path] = enable; |
| 207 std::vector<Profile*> profiles = | 242 std::vector<Profile*> profiles = |
| 208 g_browser_process->profile_manager()->GetLoadedProfiles(); | 243 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 209 scoped_refptr<CallbackBarrier> barrier = new CallbackBarrier(callback); | 244 scoped_refptr<CallbackBarrier> barrier = new CallbackBarrier(callback); |
| 210 for (std::vector<Profile*>::iterator it = profiles.begin(); | 245 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| 211 it != profiles.end(); ++it) { | 246 it != profiles.end(); ++it) { |
| 212 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(*it); | 247 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(*it); |
| 213 DCHECK(plugin_prefs); | 248 DCHECK(plugin_prefs); |
| 214 plugin_prefs->EnablePlugin(enable, file_path, barrier->CreateCallback()); | 249 plugin_prefs->EnablePlugin(enable, file_path, barrier->CreateCallback(), |
| 250 base::Bind(&CanEnablePluginCallbackDoNothing)); | |
| 215 } | 251 } |
| 216 } | 252 } |
| 217 | 253 |
| 218 PluginPrefs::PolicyStatus PluginPrefs::PolicyStatusForPlugin( | 254 PluginPrefs::PolicyStatus PluginPrefs::PolicyStatusForPlugin( |
| 219 const string16& name) const { | 255 const string16& name) const { |
| 220 base::AutoLock auto_lock(lock_); | 256 base::AutoLock auto_lock(lock_); |
| 221 if (IsStringMatchedInSet(name, policy_enabled_plugin_patterns_)) { | 257 if (IsStringMatchedInSet(name, policy_enabled_plugin_patterns_)) { |
| 222 return POLICY_ENABLED; | 258 return POLICY_ENABLED; |
| 223 } else if (IsStringMatchedInSet(name, policy_disabled_plugin_patterns_) && | 259 } else if (IsStringMatchedInSet(name, policy_disabled_plugin_patterns_) && |
| 224 !IsStringMatchedInSet( | 260 !IsStringMatchedInSet( |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 policy_enabled_plugin_patterns_ = enabled_patterns; | 540 policy_enabled_plugin_patterns_ = enabled_patterns; |
| 505 } | 541 } |
| 506 | 542 |
| 507 webkit::npapi::PluginList* PluginPrefs::GetPluginList() const { | 543 webkit::npapi::PluginList* PluginPrefs::GetPluginList() const { |
| 508 if (plugin_list_) | 544 if (plugin_list_) |
| 509 return plugin_list_; | 545 return plugin_list_; |
| 510 return PluginService::GetInstance()->GetPluginList(); | 546 return PluginService::GetInstance()->GetPluginList(); |
| 511 } | 547 } |
| 512 | 548 |
| 513 void PluginPrefs::GetPreferencesDataOnFileThread() { | 549 void PluginPrefs::GetPreferencesDataOnFileThread() { |
| 514 std::vector<webkit::npapi::PluginGroup> groups; | 550 PluginFinder::Get( |
| 551 base::Bind(&PluginPrefs::GetPluginFinderForGetPreferencesDataOnFileThread, | |
| 552 this)); | |
| 553 } | |
| 515 | 554 |
| 555 void PluginPrefs::GetPluginFinderForGetPreferencesDataOnFileThread( | |
| 556 PluginFinder* finder) { | |
| 557 std::vector<webkit::WebPluginInfo> plugins; | |
| 516 webkit::npapi::PluginList* plugin_list = GetPluginList(); | 558 webkit::npapi::PluginList* plugin_list = GetPluginList(); |
| 517 plugin_list->GetPluginGroups(false, &groups); | 559 plugin_list->GetPluginsNoRefresh(&plugins); |
| 518 | 560 |
| 519 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 561 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 520 base::Bind(&PluginPrefs::OnUpdatePreferences, this, groups)); | 562 base::Bind(&PluginPrefs::OnUpdatePreferences, this, plugins, finder)); |
| 521 } | 563 } |
| 522 | 564 |
| 523 void PluginPrefs::OnUpdatePreferences( | 565 void PluginPrefs::OnUpdatePreferences( |
| 524 const std::vector<webkit::npapi::PluginGroup>& groups) { | 566 const std::vector<webkit::WebPluginInfo>& plugins, |
| 567 PluginFinder* finder) { | |
| 525 if (!prefs_) | 568 if (!prefs_) |
| 526 return; | 569 return; |
| 527 | 570 |
| 528 ListPrefUpdate update(prefs_, prefs::kPluginsPluginsList); | 571 ListPrefUpdate update(prefs_, prefs::kPluginsPluginsList); |
| 529 ListValue* plugins_list = update.Get(); | 572 ListValue* plugins_list = update.Get(); |
| 530 plugins_list->Clear(); | 573 plugins_list->Clear(); |
| 531 | 574 |
| 532 FilePath internal_dir; | 575 FilePath internal_dir; |
| 533 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) | 576 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) |
| 534 prefs_->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir); | 577 prefs_->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir); |
| 535 | 578 |
| 536 base::AutoLock auto_lock(lock_); | 579 base::AutoLock auto_lock(lock_); |
| 537 | 580 |
| 581 // Add the plugin files. | |
| 582 std::set<string16> group_names; | |
| 583 for (size_t i = 0; i < plugins.size(); ++i) { | |
| 584 DictionaryValue* summary = new DictionaryValue(); | |
| 585 summary->SetString("path", plugins[i].path.value()); | |
| 586 summary->SetString("name", plugins[i].name); | |
| 587 summary->SetString("version", plugins[i].version); | |
| 588 bool enabled = true; | |
| 589 std::map<FilePath, bool>::iterator it = plugin_state_.find(plugins[i].path); | |
| 590 if (it != plugin_state_.end()) | |
| 591 enabled = it->second; | |
| 592 summary->SetBoolean("enabled", enabled); | |
| 593 plugins_list->Append(summary); | |
| 594 | |
| 595 PluginInstaller* installer = finder->GetPluginInstaller(plugins[i]); | |
| 596 // Insert into a set of all group names. | |
| 597 group_names.insert(installer->name()); | |
| 598 } | |
| 599 | |
| 538 // Add the plug-in groups. | 600 // Add the plug-in groups. |
| 539 for (size_t i = 0; i < groups.size(); ++i) { | 601 for (std::set<string16>::const_iterator it = group_names.begin(); |
|
ibraaaa
2012/08/24 15:56:21
I guess that here the order of having the plugins
| |
| 540 // Add the plugin files to the same list. | 602 it != group_names.end(); ++it) { |
| 541 const std::vector<webkit::WebPluginInfo>& plugins = | |
| 542 groups[i].web_plugin_infos(); | |
| 543 for (size_t j = 0; j < plugins.size(); ++j) { | |
| 544 DictionaryValue* summary = new DictionaryValue(); | |
| 545 summary->SetString("path", plugins[j].path.value()); | |
| 546 summary->SetString("name", plugins[j].name); | |
| 547 summary->SetString("version", plugins[j].version); | |
| 548 bool enabled = true; | |
| 549 std::map<FilePath, bool>::iterator it = | |
| 550 plugin_state_.find(plugins[j].path); | |
| 551 if (it != plugin_state_.end()) | |
| 552 enabled = it->second; | |
| 553 summary->SetBoolean("enabled", enabled); | |
| 554 plugins_list->Append(summary); | |
| 555 } | |
| 556 | |
| 557 DictionaryValue* summary = new DictionaryValue(); | 603 DictionaryValue* summary = new DictionaryValue(); |
| 558 string16 name = groups[i].GetGroupName(); | 604 summary->SetString("name", *it); |
| 559 summary->SetString("name", name); | |
| 560 bool enabled = true; | 605 bool enabled = true; |
| 561 std::map<string16, bool>::iterator it = | 606 std::map<string16, bool>::iterator gstate_it = |
| 562 plugin_group_state_.find(name); | 607 plugin_group_state_.find(*it); |
| 563 if (it != plugin_group_state_.end()) | 608 if (gstate_it != plugin_group_state_.end()) |
| 564 enabled = it->second; | 609 enabled = gstate_it->second; |
| 565 summary->SetBoolean("enabled", enabled); | 610 summary->SetBoolean("enabled", enabled); |
| 566 plugins_list->Append(summary); | 611 plugins_list->Append(summary); |
| 567 } | 612 } |
| 568 } | 613 } |
| 569 | 614 |
| 570 void PluginPrefs::NotifyPluginStatusChanged() { | 615 void PluginPrefs::NotifyPluginStatusChanged() { |
| 571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 616 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 572 content::NotificationService::current()->Notify( | 617 content::NotificationService::current()->Notify( |
| 573 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 618 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
| 574 content::Source<Profile>(profile_), | 619 content::Source<Profile>(profile_), |
| 575 content::NotificationService::NoDetails()); | 620 content::NotificationService::NoDetails()); |
| 576 } | 621 } |
| OLD | NEW |