Commit 9a5e66bb authored by bartfab@chromium.org's avatar bartfab@chromium.org

Prevent public session users from changing locale via settings

Changes to the locale made via the settings screen persist outside the
current session and affect e.g. the login screen. Public session users
should not be permitted to make such changes.

BUG=214904
TEST=Manual - public session cannot, regular user can change locale

Review URL: https://codereview.chromium.org/412583002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285091 0039d316-1c4b-4281-b951-d872f2087c98
parent bb508b30
......@@ -28,7 +28,8 @@
<div id="language-options-details">
<h3 id="language-options-language-name"></h3>
<if expr="os == 'win32' or chromeos">
<div class="language-options-contents">
<div id="language-options-ui-language-section"
class="language-options-contents">
<button id="language-options-ui-language-button"
i18n-content="displayInThisLanguage">
</button>
......
......@@ -253,6 +253,10 @@ cr.define('options', function() {
$('language-confirm').onclick =
OptionsPage.closeOverlay.bind(OptionsPage);
// Public session users cannot change the locale.
if (cr.isChromeOS && UIAccountTweaks.loggedInAsPublicAccount())
$('language-options-ui-language-section').hidden = true;
},
/**
......
......@@ -25,6 +25,7 @@
#include "chromeos/ime/component_extension_ime_manager.h"
#include "chromeos/ime/extension_ime_util.h"
#include "chromeos/ime/input_method_manager.h"
#include "components/user_manager/user_type.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
......@@ -199,9 +200,11 @@ void CrosLanguageOptionsHandler::SetApplicationLocale(
Profile* profile = Profile::FromWebUI(web_ui());
UserManager* user_manager = UserManager::Get();
// Only the primary user can change the locale.
// Secondary users and public session users cannot change the locale.
user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
if (user && user->email() == user_manager->GetPrimaryUser()->email()) {
if (user &&
user->email() == user_manager->GetPrimaryUser()->email() &&
user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
profile->ChangeAppLocale(language_code,
Profile::APP_LOCALE_CHANGED_VIA_SETTINGS);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment