Chromium Code Reviews| Index: chrome/browser/chromeos/user_cros_settings_provider.cc |
| diff --git a/chrome/browser/chromeos/user_cros_settings_provider.cc b/chrome/browser/chromeos/user_cros_settings_provider.cc |
| index 764c846dfc0179a0aba5a5ac833e831f94d1cb53..89056a8753e201eba0857d46b4695b527c3d756c 100644 |
| --- a/chrome/browser/chromeos/user_cros_settings_provider.cc |
| +++ b/chrome/browser/chromeos/user_cros_settings_provider.cc |
| @@ -22,7 +22,6 @@ |
| #include "chrome/browser/chromeos/login/ownership_service.h" |
| #include "chrome/browser/chromeos/login/ownership_status_checker.h" |
| #include "chrome/browser/chromeos/login/user_manager.h" |
| -#include "chrome/browser/policy/browser_policy_connector.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| #include "chrome/browser/ui/options/options_util.h" |
| @@ -172,17 +171,6 @@ void RegisterSetting(PrefService* local_state, const std::string& pref_path) { |
| } |
| } |
| -// Create a settings value with "managed" and "disabled" property. |
| -// "managed" property is true if the setting is managed by administrator. |
| -// "disabled" property is true if the UI for the setting should be disabled. |
| -Value* CreateSettingsValue(Value *value, bool managed, bool disabled) { |
| - DictionaryValue* dict = new DictionaryValue; |
| - dict->Set("value", value); |
| - dict->Set("managed", Value::CreateBooleanValue(managed)); |
| - dict->Set("disabled", Value::CreateBooleanValue(disabled)); |
| - return dict; |
| -} |
| - |
| enum UseValue { |
| USE_VALUE_SUPPLIED, |
| USE_VALUE_DEFAULT |
| @@ -573,158 +561,54 @@ void UserCrosSettingsProvider::RegisterPrefs(PrefService* local_state) { |
| RegisterSetting(local_state, kListSettings[i]); |
| } |
| -bool UserCrosSettingsProvider::RequestTrustedAllowGuest(Task* callback) { |
| - return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( |
| - kAccountsPrefAllowGuest, callback); |
| -} |
| - |
| -bool UserCrosSettingsProvider::RequestTrustedAllowNewUser(Task* callback) { |
| - return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( |
| - kAccountsPrefAllowNewUser, callback); |
| -} |
| - |
| -bool UserCrosSettingsProvider::RequestTrustedShowUsersOnSignin(Task* callback) { |
| - return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( |
| - kAccountsPrefShowUserNamesOnSignIn, callback); |
| -} |
| - |
| -bool UserCrosSettingsProvider::RequestTrustedDataRoamingEnabled( |
| - Task* callback) { |
| - return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( |
| - kSignedDataRoamingEnabled, callback); |
| -} |
| - |
| -bool UserCrosSettingsProvider::RequestTrustedOwner(Task* callback) { |
| - return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( |
| - kDeviceOwner, callback); |
| -} |
| - |
| -bool UserCrosSettingsProvider::RequestTrustedReportingEnabled(Task* callback) { |
| - return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( |
| - kStatsReportingPref, callback); |
| -} |
| - |
| void UserCrosSettingsProvider::Reload() { |
| UserCrosSettingsTrust::GetInstance()->Reload(); |
| } |
| -// static |
| -bool UserCrosSettingsProvider::cached_allow_guest() { |
| - // Trigger prefetching if singleton object still does not exist. |
| - UserCrosSettingsTrust::GetInstance(); |
| - return g_browser_process->local_state()->GetBoolean(kAccountsPrefAllowGuest); |
| -} |
| - |
| -// static |
| -bool UserCrosSettingsProvider::cached_allow_new_user() { |
| - // Trigger prefetching if singleton object still does not exist. |
| - UserCrosSettingsTrust::GetInstance(); |
| - return g_browser_process->local_state()->GetBoolean( |
| - kAccountsPrefAllowNewUser); |
| -} |
| - |
| -// static |
| -bool UserCrosSettingsProvider::cached_data_roaming_enabled() { |
| - // Trigger prefetching if singleton object still does not exist. |
| - UserCrosSettingsTrust::GetInstance(); |
| - return g_browser_process->local_state()->GetBoolean( |
| - kSignedDataRoamingEnabled); |
| -} |
| - |
| -// static |
| -bool UserCrosSettingsProvider::cached_show_users_on_signin() { |
| - // Trigger prefetching if singleton object still does not exist. |
| - UserCrosSettingsTrust::GetInstance(); |
| - return g_browser_process->local_state()->GetBoolean( |
| - kAccountsPrefShowUserNamesOnSignIn); |
| -} |
| - |
| -// static |
| -bool UserCrosSettingsProvider::cached_reporting_enabled() { |
| - // Trigger prefetching if singleton object still does not exist. |
| - UserCrosSettingsTrust::GetInstance(); |
| - return g_browser_process->local_state()->GetBoolean( |
| - kStatsReportingPref); |
| -} |
| - |
| -// static |
| -const ListValue* UserCrosSettingsProvider::cached_whitelist() { |
| - PrefService* prefs = g_browser_process->local_state(); |
| - const ListValue* cached_users = prefs->GetList(kAccountsPrefUsers); |
| - if (!prefs->IsManagedPreference(kAccountsPrefUsers)) { |
| - if (cached_users == NULL) { |
| - // Update whitelist cache. |
| - GetUserWhitelist(NULL); |
| - cached_users = prefs->GetList(kAccountsPrefUsers); |
| - } |
| - } |
| - if (cached_users == NULL) { |
| - NOTREACHED(); |
| - cached_users = new ListValue; |
| - } |
| - return cached_users; |
| -} |
| - |
| -// static |
| -std::string UserCrosSettingsProvider::cached_owner() { |
| - // Trigger prefetching if singleton object still does not exist. |
| - UserCrosSettingsTrust::GetInstance(); |
| - if (!g_browser_process || !g_browser_process->local_state()) |
| - return std::string(); |
| - return g_browser_process->local_state()->GetString(kDeviceOwner); |
| -} |
| - |
| -// static |
| -bool UserCrosSettingsProvider::IsEmailInCachedWhitelist( |
| - const std::string& email) { |
| - const ListValue* whitelist = cached_whitelist(); |
| - if (whitelist) { |
| - StringValue email_value(email); |
| - for (ListValue::const_iterator i(whitelist->begin()); |
| - i != whitelist->end(); ++i) { |
| - if ((*i)->Equals(&email_value)) |
| - return true; |
| - } |
| - } |
| - return false; |
| -} |
| - |
| void UserCrosSettingsProvider::DoSet(const std::string& path, |
| Value* in_value) { |
| UserCrosSettingsTrust::GetInstance()->Set(path, in_value); |
| } |
| -bool UserCrosSettingsProvider::Get(const std::string& path, |
| - Value** out_value) const { |
| - if (path == kAccountsPrefUsers) { |
| - ListValue* user_list = new ListValue; |
| - GetUserWhitelist(user_list); |
| - *out_value = user_list; |
| - return true; |
| - } |
| - |
| - if (IsControlledBooleanSetting(path) || IsControlledStringSetting(path)) { |
| +const base::Value* UserCrosSettingsProvider::Get( |
| + const std::string& path) const { |
| + if (HandlesSetting(path)) { |
| PrefService* prefs = g_browser_process->local_state(); |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
Have you considered moving the cache into a single
pastarmovj
2011/09/23 15:19:32
Doing the first might allow us to unit the live ca
|
| const PrefService::Preference* pref = prefs->FindPreference(path.c_str()); |
| - const Value *pref_value = pref->GetValue(); |
| + return pref->GetValue(); |
| + } |
| + return NULL; |
| +} |
| - *out_value = CreateSettingsValue( |
| - pref_value->DeepCopy(), |
| - g_browser_process->browser_policy_connector()->IsEnterpriseManaged(), |
| - !UserManager::Get()->current_user_is_owner()); |
| - return true; |
| +class TrustedEntryFetcher : public Task { |
| + public: |
| + explicit TrustedEntryFetcher(const CrosSettingsProvider::Callback& callback) |
| + : callback_(callback) { |
| } |
| - return false; |
| + void Run() { |
| + callback_.Run(); |
| + } |
| + |
| + private: |
| + CrosSettingsProvider::Callback callback_; |
| +}; |
| + |
| +bool UserCrosSettingsProvider::GetTrusted(const std::string& path, |
| + const Callback& callback) const { |
| + return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity( |
| + path, new TrustedEntryFetcher(callback)); |
| } |
| bool UserCrosSettingsProvider::HandlesSetting(const std::string& path) const { |
| return ::StartsWithASCII(path, "cros.accounts.", true) || |
| ::StartsWithASCII(path, "cros.signed.", true) || |
| ::StartsWithASCII(path, "cros.metrics.", true) || |
| + path == kDeviceOwner || |
| path == kReleaseChannel; |
| } |
| +// static |
| void UserCrosSettingsProvider::WhitelistUser(const std::string& email) { |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
These implementations still bypass CrosSettings.
pastarmovj
2011/09/23 15:19:32
True, this is planned to come in with the WhiteLis
|
| SignedSettingsHelper::Get()->StartWhitelistOp( |
| email, true, UserCrosSettingsTrust::GetInstance()); |
| @@ -734,6 +618,7 @@ void UserCrosSettingsProvider::WhitelistUser(const std::string& email) { |
| prefs->ScheduleSavePersistentPrefs(); |
| } |
| +// static |
| void UserCrosSettingsProvider::UnwhitelistUser(const std::string& email) { |
| SignedSettingsHelper::Get()->StartWhitelistOp( |
| email, false, UserCrosSettingsTrust::GetInstance()); |