This source file includes following definitions.
- DoSet
- Get
- PrepareTrustedValues
- HandlesSetting
- TimezoneChanged
#include "chrome/browser/chromeos/settings/system_settings_provider.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chromeos/login/login_state.h"
#include "chromeos/settings/cros_settings_names.h"
#include "content/public/browser/render_process_host.h"
namespace chromeos {
SystemSettingsProvider::SystemSettingsProvider(
const NotifyObserversCallback& notify_cb)
: CrosSettingsProvider(notify_cb) {
system::TimezoneSettings *timezone_settings =
system::TimezoneSettings::GetInstance();
timezone_settings->AddObserver(this);
timezone_value_.reset(new base::StringValue(
timezone_settings->GetCurrentTimezoneID()));
}
SystemSettingsProvider::~SystemSettingsProvider() {
system::TimezoneSettings::GetInstance()->RemoveObserver(this);
}
void SystemSettingsProvider::DoSet(const std::string& path,
const base::Value& in_value) {
if (LoginState::Get()->IsGuestUser())
return;
if (path == kSystemTimezone) {
base::string16 timezone_id;
if (!in_value.GetAsString(&timezone_id))
return;
system::TimezoneSettings::GetInstance()->SetTimezoneFromID(timezone_id);
}
}
const base::Value* SystemSettingsProvider::Get(const std::string& path) const {
if (path == kSystemTimezone)
return timezone_value_.get();
return NULL;
}
CrosSettingsProvider::TrustedStatus
SystemSettingsProvider::PrepareTrustedValues(const base::Closure& cb) {
return TRUSTED;
}
bool SystemSettingsProvider::HandlesSetting(const std::string& path) const {
return path == kSystemTimezone;
}
void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) {
timezone_value_.reset(new base::StringValue(
system::TimezoneSettings::GetTimezoneID(timezone)));
NotifyObservers(kSystemTimezone);
for (content::RenderProcessHost::iterator it(
content::RenderProcessHost::AllHostsIterator());
!it.IsAtEnd();
it.Advance()) {
it.GetCurrentValue()->NotifyTimezoneChange();
}
}
}