| 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..3f3665c55958bd4307606368f9b367d4d3930ad6 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;
|
| +}
|
| +
|
| // 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();
|
| +}
|
| +
|
| 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);
|
| + if (!IsSettingShared(pref_name) || !IsSecondaryUser(profile))
|
| + return value;
|
| + base::DictionaryValue* dict;
|
| + if (!value->GetAsDictionary(&dict) || dict->HasKey("controlledBy"))
|
| + return value;
|
| + Profile* primary_profile = ProfileHelper::Get()->GetProfileByUser(
|
| + user_manager::UserManager::Get()->GetPrimaryUser());
|
| + if (!primary_profile)
|
| + return value;
|
| + dict->SetString("controlledBy", "shared");
|
| + dict->SetBoolean("disabled", true);
|
| + dict->SetBoolean("value", primary_profile->GetPrefs()->GetBoolean(
|
| + pref_name));
|
| + return dict;
|
| }
|
|
|
| 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()) {
|
| + if (IsSecondaryUser(profile)) {
|
| const std::string& primary_email = user_manager->GetPrimaryUser()->email();
|
|
|
| // Set secondaryUser to show the shared icon by the network section header.
|
|
|