| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/cros_settings.h" | 5 #include "chrome/browser/chromeos/cros_settings.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/cros_settings_provider.h" | 10 #include "chrome/browser/chromeos/cros_settings_provider.h" |
| 11 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 11 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 12 #include "content/common/content_notification_types.h" |
| 12 #include "content/common/notification_details.h" | 13 #include "content/common/notification_details.h" |
| 13 #include "content/common/notification_source.h" | 14 #include "content/common/notification_source.h" |
| 14 #include "content/common/notification_type.h" | |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 static base::LazyInstance<CrosSettings> g_cros_settings( | 18 static base::LazyInstance<CrosSettings> g_cros_settings( |
| 19 base::LINKER_INITIALIZED); | 19 base::LINKER_INITIALIZED); |
| 20 | 20 |
| 21 CrosSettings* CrosSettings::Get() { | 21 CrosSettings* CrosSettings::Get() { |
| 22 // TODO(xiyaun): Use real stuff when underlying libcros is ready. | 22 // TODO(xiyaun): Use real stuff when underlying libcros is ready. |
| 23 return g_cros_settings.Pointer(); | 23 return g_cros_settings.Pointer(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 bool CrosSettings::IsCrosSettings(const std::string& path) { | 26 bool CrosSettings::IsCrosSettings(const std::string& path) { |
| 27 return StartsWithASCII(path, kCrosSettingsPrefix, true); | 27 return StartsWithASCII(path, kCrosSettingsPrefix, true); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void CrosSettings::FireObservers(const char* path) { | 30 void CrosSettings::FireObservers(const char* path) { |
| 31 DCHECK(CalledOnValidThread()); | 31 DCHECK(CalledOnValidThread()); |
| 32 std::string path_str(path); | 32 std::string path_str(path); |
| 33 SettingsObserverMap::iterator observer_iterator = | 33 SettingsObserverMap::iterator observer_iterator = |
| 34 settings_observers_.find(path_str); | 34 settings_observers_.find(path_str); |
| 35 if (observer_iterator == settings_observers_.end()) | 35 if (observer_iterator == settings_observers_.end()) |
| 36 return; | 36 return; |
| 37 | 37 |
| 38 NotificationObserverList::Iterator it(*(observer_iterator->second)); | 38 NotificationObserverList::Iterator it(*(observer_iterator->second)); |
| 39 NotificationObserver* observer; | 39 NotificationObserver* observer; |
| 40 while ((observer = it.GetNext()) != NULL) { | 40 while ((observer = it.GetNext()) != NULL) { |
| 41 observer->Observe(NotificationType::SYSTEM_SETTING_CHANGED, | 41 observer->Observe(chrome::SYSTEM_SETTING_CHANGED, |
| 42 Source<CrosSettings>(this), | 42 Source<CrosSettings>(this), |
| 43 Details<std::string>(&path_str)); | 43 Details<std::string>(&path_str)); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 void CrosSettings::Set(const std::string& path, Value* in_value) { | 47 void CrosSettings::Set(const std::string& path, Value* in_value) { |
| 48 DCHECK(CalledOnValidThread()); | 48 DCHECK(CalledOnValidThread()); |
| 49 CrosSettingsProvider* provider; | 49 CrosSettingsProvider* provider; |
| 50 provider = GetProvider(path); | 50 provider = GetProvider(path); |
| 51 if (provider) { | 51 if (provider) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 202 } |
| 203 | 203 |
| 204 CrosSettings::CrosSettings() { | 204 CrosSettings::CrosSettings() { |
| 205 } | 205 } |
| 206 | 206 |
| 207 CrosSettings::~CrosSettings() { | 207 CrosSettings::~CrosSettings() { |
| 208 DCHECK(providers_.empty()); | 208 DCHECK(providers_.empty()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace chromeos | 211 } // namespace chromeos |
| OLD | NEW |