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