Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: chrome/browser/chromeos/cros_settings.cc

Issue 8899002: [cros] Add --stub-cros-settings option for testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/cros_settings.h ('k') | chrome/browser/chromeos/cros_settings_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros_settings.cc
diff --git a/chrome/browser/chromeos/cros_settings.cc b/chrome/browser/chromeos/cros_settings.cc
index 8d54cbd3418baa48e1e4e6ad6a52002c2e538546..eb85b1a6f38549b7f321f327e60d31d48e514ddb 100644
--- a/chrome/browser/chromeos/cros_settings.cc
+++ b/chrome/browser/chromeos/cros_settings.cc
@@ -4,13 +4,17 @@
#include "chrome/browser/chromeos/cros_settings.h"
+#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/device_settings_provider.h"
+#include "chrome/browser/chromeos/stub_cros_settings_provider.h"
#include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
@@ -29,11 +33,10 @@ bool CrosSettings::IsCrosSettings(const std::string& path) {
return StartsWithASCII(path, kCrosSettingsPrefix, true);
}
-void CrosSettings::FireObservers(const char* path) {
+void CrosSettings::FireObservers(const std::string& path) {
DCHECK(CalledOnValidThread());
- std::string path_str(path);
SettingsObserverMap::iterator observer_iterator =
- settings_observers_.find(path_str);
+ settings_observers_.find(path);
if (observer_iterator == settings_observers_.end())
return;
@@ -42,7 +45,7 @@ void CrosSettings::FireObservers(const char* path) {
while ((observer = it.GetNext()) != NULL) {
observer->Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED,
content::Source<CrosSettings>(this),
- content::Details<std::string>(&path_str));
+ content::Details<const std::string>(&path));
}
}
@@ -263,8 +266,18 @@ bool CrosSettings::GetList(const std::string& path,
}
CrosSettings::CrosSettings() {
- AddSettingsProvider(new SystemSettingsProvider());
- AddSettingsProvider(new DeviceSettingsProvider());
+ CrosSettingsProvider::NotifyObserversCallback notify_cb(
+ base::Bind(&CrosSettings::FireObservers,
+ // This is safe since |this| is never deleted.
+ base::Unretained(this)));
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kStubCrosSettings)) {
+ AddSettingsProvider(new StubCrosSettingsProvider(notify_cb));
+ } else {
+ AddSettingsProvider(new DeviceSettingsProvider(notify_cb));
+ }
+ // System settings are not mocked currently.
+ AddSettingsProvider(new SystemSettingsProvider(notify_cb));
}
CrosSettings::~CrosSettings() {
« no previous file with comments | « chrome/browser/chromeos/cros_settings.h ('k') | chrome/browser/chromeos/cros_settings_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698