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/chromeos/settings/cros_settings.h" | 5 #include "chrome/browser/chromeos/settings/cros_settings.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | |
10 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
11 #include "base/string_util.h" | 10 #include "base/string_util.h" |
12 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/chromeos/login/user_manager.h" | |
13 #include "chrome/browser/chromeos/settings/device_settings_provider.h" | 13 #include "chrome/browser/chromeos/settings/device_settings_provider.h" |
14 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 14 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
15 #include "chrome/browser/chromeos/settings/kiosk_app_local_settings.h" | 15 #include "chrome/browser/chromeos/settings/kiosk_app_local_settings.h" |
16 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 16 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
17 #include "chrome/browser/chromeos/settings/system_settings_provider.h" | 17 #include "chrome/browser/chromeos/settings/system_settings_provider.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
22 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
23 #include "google_apis/gaia/gaia_auth_util.h" | 23 #include "google_apis/gaia/gaia_auth_util.h" |
24 | 24 |
25 namespace chromeos { | 25 namespace chromeos { |
26 | 26 |
27 static base::LazyInstance<CrosSettings> g_cros_settings = | 27 static CrosSettings* g_cros_settings = NULL; |
28 LAZY_INSTANCE_INITIALIZER; | |
29 | 28 |
29 // static | |
30 void CrosSettings::Initialize() { | |
31 CHECK(!g_cros_settings); | |
32 g_cros_settings = new CrosSettings(); | |
33 } | |
34 | |
35 // static | |
36 bool CrosSettings::IsInitialized() { | |
37 return g_cros_settings != NULL; | |
38 } | |
39 | |
40 // static | |
41 void CrosSettings::Shutdown() { | |
42 CHECK(g_cros_settings); | |
43 delete g_cros_settings; | |
44 g_cros_settings = NULL; | |
45 } | |
46 | |
47 // static | |
30 CrosSettings* CrosSettings::Get() { | 48 CrosSettings* CrosSettings::Get() { |
31 // TODO(xiyaun): Use real stuff when underlying libcros is ready. | 49 // TODO(xiyaun): Use real stuff when underlying libcros is ready. |
xiyuan
2013/04/16 16:07:31
This TODO is obsolete. It is the real stuff. :)
Mattias Nissler (ping if slow)
2013/04/16 16:09:51
I think this comment is entirely obsolete by now.
stevenjb
2013/04/16 16:49:43
Done.
| |
32 return g_cros_settings.Pointer(); | 50 CHECK(g_cros_settings); |
51 return g_cros_settings; | |
33 } | 52 } |
34 | 53 |
35 bool CrosSettings::IsCrosSettings(const std::string& path) { | 54 bool CrosSettings::IsCrosSettings(const std::string& path) { |
36 return StartsWithASCII(path, kCrosSettingsPrefix, true); | 55 return StartsWithASCII(path, kCrosSettingsPrefix, true); |
37 } | 56 } |
38 | 57 |
39 void CrosSettings::Set(const std::string& path, const base::Value& in_value) { | 58 void CrosSettings::Set(const std::string& path, const base::Value& in_value) { |
40 DCHECK(CalledOnValidThread()); | 59 DCHECK(CalledOnValidThread()); |
41 CrosSettingsProvider* provider; | 60 CrosSettingsProvider* provider; |
42 provider = GetProvider(path); | 61 provider = GetProvider(path); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 | 322 |
304 NotificationObserverList::Iterator it(*(observer_iterator->second)); | 323 NotificationObserverList::Iterator it(*(observer_iterator->second)); |
305 content::NotificationObserver* observer; | 324 content::NotificationObserver* observer; |
306 while ((observer = it.GetNext()) != NULL) { | 325 while ((observer = it.GetNext()) != NULL) { |
307 observer->Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, | 326 observer->Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, |
308 content::Source<CrosSettings>(this), | 327 content::Source<CrosSettings>(this), |
309 content::Details<const std::string>(&path)); | 328 content::Details<const std::string>(&path)); |
310 } | 329 } |
311 } | 330 } |
312 | 331 |
332 ScopedTestCrosSettings::ScopedTestCrosSettings() { | |
333 chromeos::DeviceSettingsService::Initialize(); | |
334 chromeos::CrosSettings::Initialize(); | |
xiyuan
2013/04/16 16:07:31
nit: no need to have chromeos:: since the code is
stevenjb
2013/04/16 16:49:43
Done.
| |
335 } | |
336 | |
337 ScopedTestCrosSettings::~ScopedTestCrosSettings() { | |
338 // UserManager holds a CrosSettings*, so ensure that it is destroyed. | |
339 chromeos::UserManager::Set(NULL); | |
340 chromeos::CrosSettings::Shutdown(); | |
341 chromeos::DeviceSettingsService::Shutdown(); | |
342 } | |
343 | |
313 } // namespace chromeos | 344 } // namespace chromeos |
OLD | NEW |