Skip to content

Commit

Permalink
Prevent public session users from changing locale via settings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bartfab@chromium.org committed Jul 24, 2014
1 parent bb508b3 commit 9a5e66b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion chrome/browser/resources/options/language_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ <h3 i18n-content="languages"></h3>
<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>
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/resources/options/language_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 9a5e66b

Please sign in to comment.