| 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/string_util.h" | 11 #include "base/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/kiosk_app_local_settings.h" | |
| 16 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 15 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 17 #include "chrome/browser/chromeos/settings/system_settings_provider.h" | 16 #include "chrome/browser/chromeos/settings/system_settings_provider.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 20 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
| 21 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
| 23 #include "google_apis/gaia/gaia_auth_util.h" | 22 #include "google_apis/gaia/gaia_auth_util.h" |
| 24 | 23 |
| 25 namespace chromeos { | 24 namespace chromeos { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 165 |
| 167 bool CrosSettings::GetList(const std::string& path, | 166 bool CrosSettings::GetList(const std::string& path, |
| 168 const base::ListValue** out_value) const { | 167 const base::ListValue** out_value) const { |
| 169 DCHECK(CalledOnValidThread()); | 168 DCHECK(CalledOnValidThread()); |
| 170 const base::Value* value = GetPref(path); | 169 const base::Value* value = GetPref(path); |
| 171 if (value) | 170 if (value) |
| 172 return value->GetAsList(out_value); | 171 return value->GetAsList(out_value); |
| 173 return false; | 172 return false; |
| 174 } | 173 } |
| 175 | 174 |
| 175 bool CrosSettings::GetDictionary( |
| 176 const std::string& path, |
| 177 const base::DictionaryValue** out_value) const { |
| 178 DCHECK(CalledOnValidThread()); |
| 179 const base::Value* value = GetPref(path); |
| 180 if (value) |
| 181 return value->GetAsDictionary(out_value); |
| 182 return false; |
| 183 } |
| 184 |
| 176 bool CrosSettings::FindEmailInList(const std::string& path, | 185 bool CrosSettings::FindEmailInList(const std::string& path, |
| 177 const std::string& email) const { | 186 const std::string& email) const { |
| 178 DCHECK(CalledOnValidThread()); | 187 DCHECK(CalledOnValidThread()); |
| 179 std::string canonicalized_email( | 188 std::string canonicalized_email( |
| 180 gaia::CanonicalizeEmail(gaia::SanitizeEmail(email))); | 189 gaia::CanonicalizeEmail(gaia::SanitizeEmail(email))); |
| 181 std::string wildcard_email; | 190 std::string wildcard_email; |
| 182 std::string::size_type at_pos = canonicalized_email.find('@'); | 191 std::string::size_type at_pos = canonicalized_email.find('@'); |
| 183 if (at_pos != std::string::npos) { | 192 if (at_pos != std::string::npos) { |
| 184 wildcard_email = | 193 wildcard_email = |
| 185 std::string("*").append(canonicalized_email.substr(at_pos)); | 194 std::string("*").append(canonicalized_email.substr(at_pos)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 base::Unretained(this))); | 305 base::Unretained(this))); |
| 297 if (CommandLine::ForCurrentProcess()->HasSwitch( | 306 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 298 switches::kStubCrosSettings)) { | 307 switches::kStubCrosSettings)) { |
| 299 AddSettingsProvider(new StubCrosSettingsProvider(notify_cb)); | 308 AddSettingsProvider(new StubCrosSettingsProvider(notify_cb)); |
| 300 } else { | 309 } else { |
| 301 AddSettingsProvider( | 310 AddSettingsProvider( |
| 302 new DeviceSettingsProvider(notify_cb, DeviceSettingsService::Get())); | 311 new DeviceSettingsProvider(notify_cb, DeviceSettingsService::Get())); |
| 303 } | 312 } |
| 304 // System settings are not mocked currently. | 313 // System settings are not mocked currently. |
| 305 AddSettingsProvider(new SystemSettingsProvider(notify_cb)); | 314 AddSettingsProvider(new SystemSettingsProvider(notify_cb)); |
| 306 // Kiosk app settings are not mocked. | |
| 307 AddSettingsProvider(new KioskAppLocalSettings(notify_cb)); | |
| 308 } | 315 } |
| 309 | 316 |
| 310 CrosSettings::~CrosSettings() { | 317 CrosSettings::~CrosSettings() { |
| 311 STLDeleteElements(&providers_); | 318 STLDeleteElements(&providers_); |
| 312 STLDeleteValues(&settings_observers_); | 319 STLDeleteValues(&settings_observers_); |
| 313 } | 320 } |
| 314 | 321 |
| 315 void CrosSettings::FireObservers(const std::string& path) { | 322 void CrosSettings::FireObservers(const std::string& path) { |
| 316 DCHECK(CalledOnValidThread()); | 323 DCHECK(CalledOnValidThread()); |
| 317 SettingsObserverMap::iterator observer_iterator = | 324 SettingsObserverMap::iterator observer_iterator = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 330 | 337 |
| 331 ScopedTestCrosSettings::ScopedTestCrosSettings() { | 338 ScopedTestCrosSettings::ScopedTestCrosSettings() { |
| 332 CrosSettings::Initialize(); | 339 CrosSettings::Initialize(); |
| 333 } | 340 } |
| 334 | 341 |
| 335 ScopedTestCrosSettings::~ScopedTestCrosSettings() { | 342 ScopedTestCrosSettings::~ScopedTestCrosSettings() { |
| 336 CrosSettings::Shutdown(); | 343 CrosSettings::Shutdown(); |
| 337 } | 344 } |
| 338 | 345 |
| 339 } // namespace chromeos | 346 } // namespace chromeos |
| OLD | NEW |