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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/values.h" | 12 #include "base/values.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/stub_cros_settings_provider.h" | 15 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
16 #include "chrome/browser/chromeos/settings/system_settings_provider.h" | 16 #include "chrome/browser/chromeos/settings/system_settings_provider.h" |
17 #include "chromeos/chromeos_switches.h" | 17 #include "chromeos/chromeos_switches.h" |
| 18 #include "chromeos/settings/cros_settings_names.h" |
18 #include "google_apis/gaia/gaia_auth_util.h" | 19 #include "google_apis/gaia/gaia_auth_util.h" |
19 | 20 |
20 namespace chromeos { | 21 namespace chromeos { |
21 | 22 |
22 static CrosSettings* g_cros_settings = NULL; | 23 static CrosSettings* g_cros_settings = NULL; |
23 | 24 |
24 // static | 25 // static |
25 void CrosSettings::Initialize() { | 26 void CrosSettings::Initialize() { |
26 CHECK(!g_cros_settings); | 27 CHECK(!g_cros_settings); |
27 g_cros_settings = new CrosSettings(DeviceSettingsService::Get()); | 28 g_cros_settings = new CrosSettings(DeviceSettingsService::Get()); |
(...skipping 10 matching lines...) Expand all Loading... |
38 delete g_cros_settings; | 39 delete g_cros_settings; |
39 g_cros_settings = NULL; | 40 g_cros_settings = NULL; |
40 } | 41 } |
41 | 42 |
42 // static | 43 // static |
43 CrosSettings* CrosSettings::Get() { | 44 CrosSettings* CrosSettings::Get() { |
44 CHECK(g_cros_settings); | 45 CHECK(g_cros_settings); |
45 return g_cros_settings; | 46 return g_cros_settings; |
46 } | 47 } |
47 | 48 |
| 49 // static |
| 50 bool CrosSettings::IsWhitelisted(const std::string& username, |
| 51 bool* wildcard_match) { |
| 52 // Skip whitelist check for tests. |
| 53 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 54 chromeos::switches::kOobeSkipPostLogin)) { |
| 55 return true; |
| 56 } |
| 57 |
| 58 CrosSettings* cros_settings = CrosSettings::Get(); |
| 59 bool allow_new_user = false; |
| 60 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 61 if (allow_new_user) |
| 62 return true; |
| 63 return cros_settings->FindEmailInList(kAccountsPrefUsers, username, |
| 64 wildcard_match); |
| 65 } |
| 66 |
48 CrosSettings::CrosSettings(DeviceSettingsService* device_settings_service) { | 67 CrosSettings::CrosSettings(DeviceSettingsService* device_settings_service) { |
49 CrosSettingsProvider::NotifyObserversCallback notify_cb( | 68 CrosSettingsProvider::NotifyObserversCallback notify_cb( |
50 base::Bind(&CrosSettings::FireObservers, | 69 base::Bind(&CrosSettings::FireObservers, |
51 // This is safe since |this| is never deleted. | 70 // This is safe since |this| is never deleted. |
52 base::Unretained(this))); | 71 base::Unretained(this))); |
53 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 72 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
54 switches::kStubCrosSettings)) { | 73 switches::kStubCrosSettings)) { |
55 AddSettingsProvider(new StubCrosSettingsProvider(notify_cb)); | 74 AddSettingsProvider(new StubCrosSettingsProvider(notify_cb)); |
56 } else { | 75 } else { |
57 AddSettingsProvider( | 76 AddSettingsProvider( |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 340 |
322 ScopedTestCrosSettings::ScopedTestCrosSettings() { | 341 ScopedTestCrosSettings::ScopedTestCrosSettings() { |
323 CrosSettings::Initialize(); | 342 CrosSettings::Initialize(); |
324 } | 343 } |
325 | 344 |
326 ScopedTestCrosSettings::~ScopedTestCrosSettings() { | 345 ScopedTestCrosSettings::~ScopedTestCrosSettings() { |
327 CrosSettings::Shutdown(); | 346 CrosSettings::Shutdown(); |
328 } | 347 } |
329 | 348 |
330 } // namespace chromeos | 349 } // namespace chromeos |
OLD | NEW |