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. Passed to 'EnablePlugin' when | |
| 82 // no action is required to be taken after the plug-in state-change check | |
| 83 // is performed. | |
|
Pam (message me for reviews)
2012/08/28 09:34:46
Still pretty self-evident. Perhaps it would be bet
ibraaaa
2012/08/28 09:50:12
Check it now.
On 2012/08/28 09:34:46, Pam wrote:
| |
| 84 void CanEnablePluginCallbackDoNothing(bool dummy) { | |
| 85 } | |
| 86 | |
| 80 } // namespace | 87 } // namespace |
| 81 | 88 |
| 82 // How long to wait to save the plugin enabled information, which might need to | 89 // How long to wait to save the plugin enabled information, which might need to |
| 83 // go to disk. | 90 // go to disk. |
| 84 #define kPluginUpdateDelayMs (60 * 1000) | 91 #define kPluginUpdateDelayMs (60 * 1000) |
| 85 | 92 |
| 86 // static | 93 // static |
| 87 scoped_refptr<PluginPrefs> PluginPrefs::GetForProfile(Profile* profile) { | 94 scoped_refptr<PluginPrefs> PluginPrefs::GetForProfile(Profile* profile) { |
| 88 return PluginPrefsFactory::GetPrefsForProfile(profile); | 95 return PluginPrefsFactory::GetPrefsForProfile(profile); |
| 89 } | 96 } |
| 90 | 97 |
| 91 // static | 98 // static |
| 92 scoped_refptr<PluginPrefs> PluginPrefs::GetForTestingProfile( | 99 scoped_refptr<PluginPrefs> PluginPrefs::GetForTestingProfile( |
| 93 Profile* profile) { | 100 Profile* profile) { |
| 94 return static_cast<PluginPrefs*>( | 101 return static_cast<PluginPrefs*>( |
| 95 PluginPrefsFactory::GetInstance()->SetTestingFactoryAndUse( | 102 PluginPrefsFactory::GetInstance()->SetTestingFactoryAndUse( |
| 96 profile, &PluginPrefsFactory::CreateForTestingProfile).get()); | 103 profile, &PluginPrefsFactory::CreateForTestingProfile).get()); |
| 97 } | 104 } |
| 98 | 105 |
| 99 void PluginPrefs::SetPluginListForTesting( | 106 void PluginPrefs::SetPluginListForTesting( |
| 100 webkit::npapi::PluginList* plugin_list) { | 107 webkit::npapi::PluginList* plugin_list) { |
| 101 plugin_list_ = plugin_list; | 108 plugin_list_ = plugin_list; |
| 102 } | 109 } |
| 103 | 110 |
| 104 void PluginPrefs::EnablePluginGroup(bool enabled, const string16& group_name) { | 111 void PluginPrefs::EnablePluginGroup(bool enabled, const string16& group_name) { |
| 105 PluginService::GetInstance()->GetPluginGroups( | 112 PluginFinder::Get( |
| 106 base::Bind(&PluginPrefs::EnablePluginGroupInternal, | 113 base::Bind(&PluginPrefs::GetPluginFinderForEnablePluginGroup, |
| 107 this, enabled, group_name)); | 114 this, enabled, group_name)); |
| 115 } | |
| 116 | |
| 117 void PluginPrefs::GetPluginFinderForEnablePluginGroup( | |
| 118 bool enabled, | |
| 119 const string16& group_name, | |
| 120 PluginFinder* finder) { | |
| 121 PluginService::GetInstance()->GetPlugins( | |
| 122 base::Bind(&PluginPrefs::EnablePluginGroupInternal, | |
| 123 this, enabled, group_name, finder)); | |
| 108 } | 124 } |
| 109 | 125 |
| 110 void PluginPrefs::EnablePluginGroupInternal( | 126 void PluginPrefs::EnablePluginGroupInternal( |
| 111 bool enabled, | 127 bool enabled, |
| 112 const string16& group_name, | 128 const string16& group_name, |
| 113 const std::vector<webkit::npapi::PluginGroup>& groups) { | 129 PluginFinder* finder, |
| 130 const std::vector<webkit::WebPluginInfo>& plugins) { | |
| 114 base::AutoLock auto_lock(lock_); | 131 base::AutoLock auto_lock(lock_); |
| 115 | 132 |
| 116 // Set the desired state for the group. | 133 // Set the desired state for the group. |
| 117 plugin_group_state_[group_name] = enabled; | 134 plugin_group_state_[group_name] = enabled; |
| 118 | 135 |
| 119 // Update the state for all plug-ins in the group. | 136 // Update the state for all plug-ins in the group. |
| 120 for (size_t i = 0; i < groups.size(); ++i) { | 137 for (size_t i = 0; i < plugins.size(); ++i) { |
| 121 if (groups[i].GetGroupName() != group_name) | 138 PluginInstaller* installer = finder->GetPluginInstaller(plugins[i]); |
| 139 if (group_name != installer->name()) | |
| 122 continue; | 140 continue; |
| 123 const std::vector<webkit::WebPluginInfo>& plugins = | 141 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 } | 142 } |
| 129 | 143 |
| 130 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 144 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 131 base::Bind(&PluginPrefs::OnUpdatePreferences, this, groups)); | 145 base::Bind(&PluginPrefs::OnUpdatePreferences, this, plugins, finder)); |
| 132 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 146 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 133 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); | 147 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); |
| 134 } | 148 } |
| 135 | 149 |
| 136 bool PluginPrefs::CanEnablePlugin(bool enabled, const FilePath& path) { | 150 void PluginPrefs::EnablePluginIfPossibleCallback( |
| 137 webkit::npapi::PluginList* plugin_list = GetPluginList(); | 151 bool enabled, const FilePath& path, |
| 152 const base::Closure& enableCallback, | |
| 153 const base::Callback<void(bool)>& canEnableCallback, | |
| 154 PluginFinder* finder) { | |
| 138 webkit::WebPluginInfo plugin; | 155 webkit::WebPluginInfo plugin; |
| 156 bool can_enable = true; | |
| 139 if (PluginService::GetInstance()->GetPluginInfoByPath(path, &plugin)) { | 157 if (PluginService::GetInstance()->GetPluginInfoByPath(path, &plugin)) { |
| 140 scoped_ptr<webkit::npapi::PluginGroup> group( | 158 PluginInstaller* installer = finder->GetPluginInstaller(plugin); |
| 141 plugin_list->GetPluginGroup(plugin)); | |
| 142 PolicyStatus plugin_status = PolicyStatusForPlugin(plugin.name); | 159 PolicyStatus plugin_status = PolicyStatusForPlugin(plugin.name); |
| 143 PolicyStatus group_status = PolicyStatusForPlugin(group->GetGroupName()); | 160 PolicyStatus group_status = PolicyStatusForPlugin(installer->name()); |
| 144 if (enabled) { | 161 if (enabled) { |
| 145 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED) | 162 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED) |
| 146 return false; | 163 can_enable = false; |
| 147 } else { | 164 } else { |
| 148 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED) | 165 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED) |
| 149 return false; | 166 can_enable = false; |
| 150 } | 167 } |
| 151 } else { | 168 } else { |
| 152 NOTREACHED(); | 169 NOTREACHED(); |
| 153 } | 170 } |
| 154 return true; | 171 |
| 172 canEnableCallback.Run(can_enable); | |
| 173 | |
| 174 if (!can_enable) | |
| 175 return; | |
| 176 | |
| 177 PluginService::GetInstance()->GetPlugins( | |
| 178 base::Bind(&PluginPrefs::EnablePluginInternal, this, | |
| 179 enabled, path, finder, enableCallback)); | |
| 155 } | 180 } |
| 156 | 181 |
| 157 void PluginPrefs::EnablePlugin(bool enabled, const FilePath& path, | 182 void PluginPrefs::EnablePlugin( |
| 158 const base::Closure& callback) { | 183 bool enabled, const FilePath& path, |
| 159 PluginService::GetInstance()->GetPluginGroups( | 184 const base::Closure& enableCallback, |
| 160 base::Bind(&PluginPrefs::EnablePluginInternal, this, | 185 const base::Callback<void(bool)>& canEnableCallback) { |
| 161 enabled, path, callback)); | 186 PluginFinder::Get(base::Bind(&PluginPrefs::EnablePluginIfPossibleCallback, |
| 187 this, enabled, path, enableCallback, | |
| 188 canEnableCallback)); | |
| 162 } | 189 } |
| 163 | 190 |
| 164 void PluginPrefs::EnablePluginInternal( | 191 void PluginPrefs::EnablePluginInternal( |
| 165 bool enabled, | 192 bool enabled, |
| 166 const FilePath& path, | 193 const FilePath& path, |
| 194 PluginFinder* plugin_finder, | |
| 167 const base::Closure& callback, | 195 const base::Closure& callback, |
| 168 const std::vector<webkit::npapi::PluginGroup>& groups) { | 196 const std::vector<webkit::WebPluginInfo>& plugins) { |
| 169 { | 197 { |
| 170 // Set the desired state for the plug-in. | 198 // Set the desired state for the plug-in. |
| 171 base::AutoLock auto_lock(lock_); | 199 base::AutoLock auto_lock(lock_); |
| 172 plugin_state_[path] = enabled; | 200 plugin_state_[path] = enabled; |
| 173 } | 201 } |
| 174 | 202 |
| 175 bool found_group = false; | 203 string16 group_name; |
| 176 for (size_t i = 0; i < groups.size(); ++i) { | 204 for (size_t i = 0; i < plugins.size(); ++i) { |
| 177 bool all_disabled = true; | 205 if (plugins[i].path == path) { |
| 178 const std::vector<webkit::WebPluginInfo>& plugins = | 206 PluginInstaller* installer = |
| 179 groups[i].web_plugin_infos(); | 207 plugin_finder->GetPluginInstaller(plugins[i]); |
| 180 for (size_t j = 0; j < plugins.size(); ++j) { | 208 // set the group name for this plug-in. |
| 181 all_disabled = all_disabled && !IsPluginEnabled(plugins[j]); | 209 group_name = installer->name(); |
| 182 if (plugins[j].path == path) { | 210 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; | 211 break; |
| 192 } | 212 } |
| 193 } | 213 } |
| 194 | 214 |
| 215 bool all_disabled = true; | |
| 216 for (size_t i = 0; i < plugins.size(); ++i) { | |
| 217 PluginInstaller* installer = plugin_finder->GetPluginInstaller(plugins[i]); | |
| 218 // The check !group_name.empty() is only a sanity check since | |
| 219 // GetPluginInstaller will always return a non-empty name. | |
| 220 if (!group_name.empty() && group_name == installer->name()) { | |
| 221 all_disabled = all_disabled && !IsPluginEnabled(plugins[i]); | |
| 222 } | |
| 223 } | |
| 224 | |
| 225 if (!group_name.empty()) { | |
| 226 // Update the state for the corresponding plug-in group. | |
| 227 base::AutoLock auto_lock(lock_); | |
| 228 plugin_group_state_[group_name] = !all_disabled; | |
| 229 } | |
| 230 | |
| 195 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 231 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 196 base::Bind(&PluginPrefs::OnUpdatePreferences, this, groups)); | 232 base::Bind(&PluginPrefs::OnUpdatePreferences, this, |
| 233 plugins, plugin_finder)); | |
| 197 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 234 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 198 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); | 235 base::Bind(&PluginPrefs::NotifyPluginStatusChanged, this)); |
| 199 callback.Run(); | 236 callback.Run(); |
| 200 } | 237 } |
| 201 | 238 |
| 202 // static | 239 // static |
| 203 void PluginPrefs::EnablePluginGlobally(bool enable, const FilePath& file_path, | 240 void PluginPrefs::EnablePluginGlobally(bool enable, const FilePath& file_path, |
| 204 const base::Closure& callback) { | 241 const base::Closure& callback) { |
| 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 206 g_default_plugin_state.Get()[file_path] = enable; | 243 g_default_plugin_state.Get()[file_path] = enable; |
| 207 std::vector<Profile*> profiles = | 244 std::vector<Profile*> profiles = |
| 208 g_browser_process->profile_manager()->GetLoadedProfiles(); | 245 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 209 scoped_refptr<CallbackBarrier> barrier = new CallbackBarrier(callback); | 246 scoped_refptr<CallbackBarrier> barrier = new CallbackBarrier(callback); |
| 210 for (std::vector<Profile*>::iterator it = profiles.begin(); | 247 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| 211 it != profiles.end(); ++it) { | 248 it != profiles.end(); ++it) { |
| 212 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(*it); | 249 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(*it); |
| 213 DCHECK(plugin_prefs); | 250 DCHECK(plugin_prefs); |
| 214 plugin_prefs->EnablePlugin(enable, file_path, barrier->CreateCallback()); | 251 plugin_prefs->EnablePlugin(enable, file_path, barrier->CreateCallback(), |
| 252 base::Bind(&CanEnablePluginCallbackDoNothing)); | |
| 215 } | 253 } |
| 216 } | 254 } |
| 217 | 255 |
| 218 PluginPrefs::PolicyStatus PluginPrefs::PolicyStatusForPlugin( | 256 PluginPrefs::PolicyStatus PluginPrefs::PolicyStatusForPlugin( |
| 219 const string16& name) const { | 257 const string16& name) const { |
| 220 base::AutoLock auto_lock(lock_); | 258 base::AutoLock auto_lock(lock_); |
| 221 if (IsStringMatchedInSet(name, policy_enabled_plugin_patterns_)) { | 259 if (IsStringMatchedInSet(name, policy_enabled_plugin_patterns_)) { |
| 222 return POLICY_ENABLED; | 260 return POLICY_ENABLED; |
| 223 } else if (IsStringMatchedInSet(name, policy_disabled_plugin_patterns_) && | 261 } else if (IsStringMatchedInSet(name, policy_disabled_plugin_patterns_) && |
| 224 !IsStringMatchedInSet( | 262 !IsStringMatchedInSet( |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 policy_enabled_plugin_patterns_ = enabled_patterns; | 542 policy_enabled_plugin_patterns_ = enabled_patterns; |
| 505 } | 543 } |
| 506 | 544 |
| 507 webkit::npapi::PluginList* PluginPrefs::GetPluginList() const { | 545 webkit::npapi::PluginList* PluginPrefs::GetPluginList() const { |
| 508 if (plugin_list_) | 546 if (plugin_list_) |
| 509 return plugin_list_; | 547 return plugin_list_; |
| 510 return PluginService::GetInstance()->GetPluginList(); | 548 return PluginService::GetInstance()->GetPluginList(); |
| 511 } | 549 } |
| 512 | 550 |
| 513 void PluginPrefs::GetPreferencesDataOnFileThread() { | 551 void PluginPrefs::GetPreferencesDataOnFileThread() { |
| 514 std::vector<webkit::npapi::PluginGroup> groups; | 552 PluginFinder::Get( |
| 553 base::Bind(&PluginPrefs::GetPluginFinderForGetPreferencesDataOnFileThread, | |
| 554 this)); | |
| 555 } | |
| 515 | 556 |
| 557 void PluginPrefs::GetPluginFinderForGetPreferencesDataOnFileThread( | |
| 558 PluginFinder* finder) { | |
| 559 std::vector<webkit::WebPluginInfo> plugins; | |
| 516 webkit::npapi::PluginList* plugin_list = GetPluginList(); | 560 webkit::npapi::PluginList* plugin_list = GetPluginList(); |
| 517 plugin_list->GetPluginGroups(false, &groups); | 561 plugin_list->GetPluginsNoRefresh(&plugins); |
| 518 | 562 |
| 519 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 563 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 520 base::Bind(&PluginPrefs::OnUpdatePreferences, this, groups)); | 564 base::Bind(&PluginPrefs::OnUpdatePreferences, this, plugins, finder)); |
| 521 } | 565 } |
| 522 | 566 |
| 523 void PluginPrefs::OnUpdatePreferences( | 567 void PluginPrefs::OnUpdatePreferences( |
| 524 const std::vector<webkit::npapi::PluginGroup>& groups) { | 568 const std::vector<webkit::WebPluginInfo>& plugins, |
| 569 PluginFinder* finder) { | |
| 525 if (!prefs_) | 570 if (!prefs_) |
| 526 return; | 571 return; |
| 527 | 572 |
| 528 ListPrefUpdate update(prefs_, prefs::kPluginsPluginsList); | 573 ListPrefUpdate update(prefs_, prefs::kPluginsPluginsList); |
| 529 ListValue* plugins_list = update.Get(); | 574 ListValue* plugins_list = update.Get(); |
| 530 plugins_list->Clear(); | 575 plugins_list->Clear(); |
| 531 | 576 |
| 532 FilePath internal_dir; | 577 FilePath internal_dir; |
| 533 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) | 578 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) |
| 534 prefs_->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir); | 579 prefs_->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir); |
| 535 | 580 |
| 536 base::AutoLock auto_lock(lock_); | 581 base::AutoLock auto_lock(lock_); |
| 537 | 582 |
| 583 // Add the plugin files. | |
| 584 std::set<string16> group_names; | |
| 585 for (size_t i = 0; i < plugins.size(); ++i) { | |
| 586 DictionaryValue* summary = new DictionaryValue(); | |
| 587 summary->SetString("path", plugins[i].path.value()); | |
| 588 summary->SetString("name", plugins[i].name); | |
| 589 summary->SetString("version", plugins[i].version); | |
| 590 bool enabled = true; | |
| 591 std::map<FilePath, bool>::iterator it = plugin_state_.find(plugins[i].path); | |
| 592 if (it != plugin_state_.end()) | |
| 593 enabled = it->second; | |
| 594 summary->SetBoolean("enabled", enabled); | |
| 595 plugins_list->Append(summary); | |
| 596 | |
| 597 PluginInstaller* installer = finder->GetPluginInstaller(plugins[i]); | |
| 598 // Insert into a set of all group names. | |
| 599 group_names.insert(installer->name()); | |
| 600 } | |
| 601 | |
| 538 // Add the plug-in groups. | 602 // Add the plug-in groups. |
| 539 for (size_t i = 0; i < groups.size(); ++i) { | 603 for (std::set<string16>::const_iterator it = group_names.begin(); |
| 540 // Add the plugin files to the same list. | 604 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(); | 605 DictionaryValue* summary = new DictionaryValue(); |
| 558 string16 name = groups[i].GetGroupName(); | 606 summary->SetString("name", *it); |
| 559 summary->SetString("name", name); | |
| 560 bool enabled = true; | 607 bool enabled = true; |
| 561 std::map<string16, bool>::iterator it = | 608 std::map<string16, bool>::iterator gstate_it = |
| 562 plugin_group_state_.find(name); | 609 plugin_group_state_.find(*it); |
| 563 if (it != plugin_group_state_.end()) | 610 if (gstate_it != plugin_group_state_.end()) |
| 564 enabled = it->second; | 611 enabled = gstate_it->second; |
| 565 summary->SetBoolean("enabled", enabled); | 612 summary->SetBoolean("enabled", enabled); |
| 566 plugins_list->Append(summary); | 613 plugins_list->Append(summary); |
| 567 } | 614 } |
| 568 } | 615 } |
| 569 | 616 |
| 570 void PluginPrefs::NotifyPluginStatusChanged() { | 617 void PluginPrefs::NotifyPluginStatusChanged() { |
| 571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 618 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 572 content::NotificationService::current()->Notify( | 619 content::NotificationService::current()->Notify( |
| 573 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 620 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
| 574 content::Source<Profile>(profile_), | 621 content::Source<Profile>(profile_), |
| 575 content::NotificationService::NoDetails()); | 622 content::NotificationService::NoDetails()); |
| 576 } | 623 } |
| OLD | NEW |