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

Unified Diff: chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc

Issue 811973002: Enable lucid sleep (wake on wi-fi SSID) and add to Privacy options. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
Index: chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
index 0d18b94f7e74acbf44728beb77fe0e629ef187f1..91dc717eadbfd7b1b00df8a41c65fe7b33b5efae 100644
--- a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
@@ -46,12 +46,23 @@ const char* kNonPrivilegedSettings[] = {
kSystemTimezone
};
+// List of settings that should only be changeable by the primary user.
+const char* kPrimaryUserSettings[] = {
+ prefs::kWakeOnWifiSsid,
+};
+
// Returns true if |pref| can be controlled (e.g. by policy or owner).
bool IsSettingPrivileged(const std::string& pref) {
const char** end = kNonPrivilegedSettings + arraysize(kNonPrivilegedSettings);
return std::find(kNonPrivilegedSettings, end, pref) == end;
}
+// Returns true if |pref| is shared (controlled by the primary user).
+bool IsSettingShared(const std::string& pref) {
+ const char** end = kPrimaryUserSettings + arraysize(kPrimaryUserSettings);
+ return std::find(kPrimaryUserSettings, end, pref) != end;
stevenjb 2014/12/17 22:22:55 Ugh, I was going to bitch about this pattern (I th
+}
+
// Creates a user info dictionary to be stored in the |ListValue| that is
// passed to Javascript for the |kAccountsPrefUsers| preference.
base::DictionaryValue* CreateUserInfo(const std::string& username,
@@ -88,6 +99,13 @@ base::Value* CreateUsersWhitelist(const base::Value *pref_value) {
return user_list;
}
+// Checks whether this is a secondary user in a multi-profile session.
+bool IsSecondaryUser(Profile* profile) {
+ user_manager::UserManager* user_manager = user_manager::UserManager::Get();
+ user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
+ return user && user->email() != user_manager->GetPrimaryUser()->email();
stevenjb 2014/12/17 22:22:55 Any reason to compare email() instead of User*s, i
michaelpg 2014/12/22 22:23:18 I asked skuhne why we do this but he wasn't sure.
+}
+
const char kSelectNetworkMessage[] = "selectNetwork";
} // namespace
@@ -163,10 +181,25 @@ base::Value* CoreChromeOSOptionsHandler::FetchPref(
return value;
}
+ Profile* profile = Profile::FromWebUI(web_ui());
if (!CrosSettings::IsCrosSettings(pref_name)) {
std::string controlling_pref =
pref_name == prefs::kUseSharedProxies ? prefs::kProxy : std::string();
- return CreateValueForPref(pref_name, controlling_pref);
+ base::Value* value = CreateValueForPref(pref_name, controlling_pref);
+ base::DictionaryValue* dict;
+ if (IsSettingShared(pref_name) && IsSecondaryUser(profile) &&
+ value->GetAsDictionary(&dict) && !dict->HasKey("controlledBy")) {
stevenjb 2014/12/17 22:22:55 if (!IsSettingShared(pref_name) || !IsSecondaryUse
michaelpg 2014/12/22 22:23:18 Done.
+ Profile* primary_profile = ProfileHelper::Get()->GetProfileByUser(
+ user_manager::UserManager::Get()->GetPrimaryUser());
+ if (primary_profile) {
stevenjb 2014/12/17 22:22:55 early exit here too
michaelpg 2014/12/22 22:23:18 Done.
+ dict->SetString("controlledBy", "shared");
+ dict->SetBoolean("disabled", true);
+ dict->SetBoolean("value", primary_profile->GetPrefs()->GetBoolean(
+ pref_name));
+ return dict;
+ }
+ }
+ return value;
}
const base::Value* pref_value = CrosSettings::Get()->GetPref(pref_name);
@@ -187,7 +220,7 @@ base::Value* CoreChromeOSOptionsHandler::FetchPref(
g_browser_process->platform_part()->browser_policy_connector_chromeos();
if (connector->IsEnterpriseManaged())
controlled_by = "policy";
- else if (!ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())))
+ else if (!ProfileHelper::IsOwnerProfile(profile))
controlled_by = "owner";
}
dict->SetBoolean("disabled", !controlled_by.empty());
@@ -302,10 +335,7 @@ void CoreChromeOSOptionsHandler::GetLocalizedValues(
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
- // Check at load time whether this is a secondary user in a multi-profile
- // session.
- user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
- if (user && user->email() != user_manager->GetPrimaryUser()->email()) {
stevenjb 2014/12/17 22:22:55 Ah, I see this was just moved, so go ahead and lea
+ if (IsSecondaryUser(profile)) {
const std::string& primary_email = user_manager->GetPrimaryUser()->email();
// Set secondaryUser to show the shared icon by the network section header.

Powered by Google App Engine
This is Rietveld 408576698