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/plugins/plugin_prefs.h" | 5 #include "chrome/browser/plugins/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" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // Check user preferences for the plug-in group. | 267 // Check user preferences for the plug-in group. |
268 std::map<string16, bool>::const_iterator group_it( | 268 std::map<string16, bool>::const_iterator group_it( |
269 plugin_group_state_.find(plugin.name)); | 269 plugin_group_state_.find(plugin.name)); |
270 if (group_it != plugin_group_state_.end()) | 270 if (group_it != plugin_group_state_.end()) |
271 return group_it->second; | 271 return group_it->second; |
272 | 272 |
273 // Default to enabled. | 273 // Default to enabled. |
274 return true; | 274 return true; |
275 } | 275 } |
276 | 276 |
277 void PluginPrefs::Observe(int type, | 277 void PluginPrefs::OnPreferenceChanged(PrefServiceBase* service, |
278 const content::NotificationSource& source, | 278 const std::string& pref_name) { |
279 const content::NotificationDetails& details) { | 279 DCHECK_EQ(prefs_, service); |
280 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | 280 if (pref_name == prefs::kPluginsDisabledPlugins) { |
281 const std::string* pref_name = content::Details<std::string>(details).ptr(); | |
282 if (!pref_name) { | |
283 NOTREACHED(); | |
284 return; | |
285 } | |
286 DCHECK_EQ(prefs_, content::Source<PrefService>(source).ptr()); | |
287 if (*pref_name == prefs::kPluginsDisabledPlugins) { | |
288 base::AutoLock auto_lock(lock_); | 281 base::AutoLock auto_lock(lock_); |
289 ListValueToStringSet(prefs_->GetList(prefs::kPluginsDisabledPlugins), | 282 ListValueToStringSet(prefs_->GetList(prefs::kPluginsDisabledPlugins), |
290 &policy_disabled_plugin_patterns_); | 283 &policy_disabled_plugin_patterns_); |
291 } else if (*pref_name == prefs::kPluginsDisabledPluginsExceptions) { | 284 } else if (pref_name == prefs::kPluginsDisabledPluginsExceptions) { |
292 base::AutoLock auto_lock(lock_); | 285 base::AutoLock auto_lock(lock_); |
293 ListValueToStringSet( | 286 ListValueToStringSet( |
294 prefs_->GetList(prefs::kPluginsDisabledPluginsExceptions), | 287 prefs_->GetList(prefs::kPluginsDisabledPluginsExceptions), |
295 &policy_disabled_plugin_exception_patterns_); | 288 &policy_disabled_plugin_exception_patterns_); |
296 } else if (*pref_name == prefs::kPluginsEnabledPlugins) { | 289 } else if (pref_name == prefs::kPluginsEnabledPlugins) { |
297 base::AutoLock auto_lock(lock_); | 290 base::AutoLock auto_lock(lock_); |
298 ListValueToStringSet(prefs_->GetList(prefs::kPluginsEnabledPlugins), | 291 ListValueToStringSet(prefs_->GetList(prefs::kPluginsEnabledPlugins), |
299 &policy_enabled_plugin_patterns_); | 292 &policy_enabled_plugin_patterns_); |
300 } else { | 293 } else { |
301 NOTREACHED(); | 294 NOTREACHED(); |
302 } | 295 } |
303 NotifyPluginStatusChanged(); | 296 NotifyPluginStatusChanged(); |
304 } | 297 } |
305 | 298 |
306 /*static*/ | 299 /*static*/ |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 630 } |
638 } | 631 } |
639 | 632 |
640 void PluginPrefs::NotifyPluginStatusChanged() { | 633 void PluginPrefs::NotifyPluginStatusChanged() { |
641 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
642 content::NotificationService::current()->Notify( | 635 content::NotificationService::current()->Notify( |
643 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 636 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
644 content::Source<Profile>(profile_), | 637 content::Source<Profile>(profile_), |
645 content::NotificationService::NoDetails()); | 638 content::NotificationService::NoDetails()); |
646 } | 639 } |
OLD | NEW |