| 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/extensions/api/preference/preference_api.h" | 5 #include "chrome/browser/extensions/api/preference/preference_api.h" | 
| 6 | 6 | 
| 7 #include <map> | 7 #include <map> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" | 
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 250     incognito_registrar_.Add(kPrefMapping[i].browser_pref, this); | 250     incognito_registrar_.Add(kPrefMapping[i].browser_pref, this); | 
| 251   } | 251   } | 
| 252 } | 252 } | 
| 253 | 253 | 
| 254 PreferenceEventRouter::~PreferenceEventRouter() { } | 254 PreferenceEventRouter::~PreferenceEventRouter() { } | 
| 255 | 255 | 
| 256 void PreferenceEventRouter::Observe( | 256 void PreferenceEventRouter::Observe( | 
| 257     int type, | 257     int type, | 
| 258     const content::NotificationSource& source, | 258     const content::NotificationSource& source, | 
| 259     const content::NotificationDetails& details) { | 259     const content::NotificationDetails& details) { | 
| 260   if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 260   DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | 
| 261     const std::string* pref_key = | 261   OnPrefChanged(content::Source<PrefService>(source).ptr(), | 
| 262         content::Details<const std::string>(details).ptr(); | 262                 *content::Details<const std::string>(details).ptr()); | 
| 263     OnPrefChanged(content::Source<PrefService>(source).ptr(), *pref_key); |  | 
| 264   } else { |  | 
| 265     NOTREACHED(); |  | 
| 266   } |  | 
| 267 } | 263 } | 
| 268 | 264 | 
| 269 void PreferenceEventRouter::OnPrefChanged(PrefService* pref_service, | 265 void PreferenceEventRouter::OnPrefChanged(PrefService* pref_service, | 
| 270                                           const std::string& browser_pref) { | 266                                           const std::string& browser_pref) { | 
| 271   bool incognito = (pref_service != profile_->GetPrefs()); | 267   bool incognito = (pref_service != profile_->GetPrefs()); | 
| 272 | 268 | 
| 273   std::string event_name; | 269   std::string event_name; | 
| 274   APIPermission::ID permission = APIPermission::kInvalid; | 270   APIPermission::ID permission = APIPermission::kInvalid; | 
| 275   bool rv = PrefMapping::GetInstance()->FindEventForBrowserPref( | 271   bool rv = PrefMapping::GetInstance()->FindEventForBrowserPref( | 
| 276       browser_pref, &event_name, &permission); | 272       browser_pref, &event_name, &permission); | 
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 514   if (!ValidateBrowserPref(pref_key, &browser_pref)) | 510   if (!ValidateBrowserPref(pref_key, &browser_pref)) | 
| 515     return false; | 511     return false; | 
| 516 | 512 | 
| 517   extensions::ExtensionPrefs* prefs = | 513   extensions::ExtensionPrefs* prefs = | 
| 518       profile_->GetExtensionService()->extension_prefs(); | 514       profile_->GetExtensionService()->extension_prefs(); | 
| 519   prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 515   prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); | 
| 520   return true; | 516   return true; | 
| 521 } | 517 } | 
| 522 | 518 | 
| 523 }  // namespace extensions | 519 }  // namespace extensions | 
| OLD | NEW | 
|---|