Chromium Code Reviews| Index: chrome/browser/chromeos/settings/cros_settings.cc |
| diff --git a/chrome/browser/chromeos/settings/cros_settings.cc b/chrome/browser/chromeos/settings/cros_settings.cc |
| index f0944071549fe51582752db5f5d1e1b7cb4a25eb..5bbc435784d524aeec97a270f6e60faebc83dd98 100644 |
| --- a/chrome/browser/chromeos/settings/cros_settings.cc |
| +++ b/chrome/browser/chromeos/settings/cros_settings.cc |
| @@ -6,10 +6,10 @@ |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| -#include "base/lazy_instance.h" |
| #include "base/stl_util.h" |
| #include "base/string_util.h" |
| #include "base/values.h" |
| +#include "chrome/browser/chromeos/login/user_manager.h" |
| #include "chrome/browser/chromeos/settings/device_settings_provider.h" |
| #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| #include "chrome/browser/chromeos/settings/kiosk_app_local_settings.h" |
| @@ -24,12 +24,31 @@ |
| namespace chromeos { |
| -static base::LazyInstance<CrosSettings> g_cros_settings = |
| - LAZY_INSTANCE_INITIALIZER; |
| +static CrosSettings* g_cros_settings = NULL; |
| +// static |
| +void CrosSettings::Initialize() { |
| + CHECK(!g_cros_settings); |
| + g_cros_settings = new CrosSettings(); |
| +} |
| + |
| +// static |
| +bool CrosSettings::IsInitialized() { |
| + return g_cros_settings != NULL; |
| +} |
| + |
| +// static |
| +void CrosSettings::Shutdown() { |
| + CHECK(g_cros_settings); |
| + delete g_cros_settings; |
| + g_cros_settings = NULL; |
| +} |
| + |
| +// static |
| CrosSettings* CrosSettings::Get() { |
| // 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.
|
| - return g_cros_settings.Pointer(); |
| + CHECK(g_cros_settings); |
| + return g_cros_settings; |
| } |
| bool CrosSettings::IsCrosSettings(const std::string& path) { |
| @@ -310,4 +329,16 @@ void CrosSettings::FireObservers(const std::string& path) { |
| } |
| } |
| +ScopedTestCrosSettings::ScopedTestCrosSettings() { |
| + chromeos::DeviceSettingsService::Initialize(); |
| + 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.
|
| +} |
| + |
| +ScopedTestCrosSettings::~ScopedTestCrosSettings() { |
| + // UserManager holds a CrosSettings*, so ensure that it is destroyed. |
| + chromeos::UserManager::Set(NULL); |
| + chromeos::CrosSettings::Shutdown(); |
| + chromeos::DeviceSettingsService::Shutdown(); |
| +} |
| + |
| } // namespace chromeos |