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

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

Issue 7867044: PART1: Initiated the SignedSettings refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up some debug output. Created 9 years, 3 months 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
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..7a1af0adebeebf21a4c2780711b052c220bd6511 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,155 +561,50 @@ 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();
const PrefService::Preference* pref = prefs->FindPreference(path.c_str());
- const Value *pref_value = pref->GetValue();
+ return pref->GetValue();
+ }
+ return NULL;
+}
+
+class TrustedEntryFetcher : public Task {
+ public:
+ explicit TrustedEntryFetcher(const CrosSettingsProvider::Callback& callback)
+ : callback_(callback) {
+ }
- *out_value = CreateSettingsValue(
- pref_value->DeepCopy(),
- g_browser_process->browser_policy_connector()->IsEnterpriseManaged(),
- !UserManager::Get()->current_user_is_owner());
- return true;
+ void Run() {
+ callback_.Run();
}
- return false;
+ 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;
}

Powered by Google App Engine
This is Rietveld 408576698