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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc

Issue 412583002: Prevent public session users from changing locale via settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/options/language_options.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h" 5 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/app/chrome_command_ids.h" 12 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/chromeos/input_method/input_method_util.h" 13 #include "chrome/browser/chromeos/input_method/input_method_util.h"
14 #include "chrome/browser/chromeos/login/users/user_manager.h" 14 #include "chrome/browser/chromeos/login/users/user_manager.h"
15 #include "chrome/browser/chromeos/profiles/profile_helper.h" 15 #include "chrome/browser/chromeos/profiles/profile_helper.h"
16 #include "chrome/browser/extensions/extension_tab_util.h" 16 #include "chrome/browser/extensions/extension_tab_util.h"
17 #include "chrome/browser/lifetime/application_lifetime.h" 17 #include "chrome/browser/lifetime/application_lifetime.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" 23 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
24 #include "chrome/common/extensions/manifest_url_handler.h" 24 #include "chrome/common/extensions/manifest_url_handler.h"
25 #include "chromeos/ime/component_extension_ime_manager.h" 25 #include "chromeos/ime/component_extension_ime_manager.h"
26 #include "chromeos/ime/extension_ime_util.h" 26 #include "chromeos/ime/extension_ime_util.h"
27 #include "chromeos/ime/input_method_manager.h" 27 #include "chromeos/ime/input_method_manager.h"
28 #include "components/user_manager/user_type.h"
28 #include "content/public/browser/navigation_controller.h" 29 #include "content/public/browser/navigation_controller.h"
29 #include "content/public/browser/user_metrics.h" 30 #include "content/public/browser/user_metrics.h"
30 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
31 #include "extensions/browser/extension_registry.h" 32 #include "extensions/browser/extension_registry.h"
32 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
33 #include "grit/chromium_strings.h" 34 #include "grit/chromium_strings.h"
34 #include "grit/generated_resources.h" 35 #include "grit/generated_resources.h"
35 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
36 37
37 using base::UserMetricsAction; 38 using base::UserMetricsAction;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 193
193 base::string16 CrosLanguageOptionsHandler::GetProductName() { 194 base::string16 CrosLanguageOptionsHandler::GetProductName() {
194 return l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME); 195 return l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME);
195 } 196 }
196 197
197 void CrosLanguageOptionsHandler::SetApplicationLocale( 198 void CrosLanguageOptionsHandler::SetApplicationLocale(
198 const std::string& language_code) { 199 const std::string& language_code) {
199 Profile* profile = Profile::FromWebUI(web_ui()); 200 Profile* profile = Profile::FromWebUI(web_ui());
200 UserManager* user_manager = UserManager::Get(); 201 UserManager* user_manager = UserManager::Get();
201 202
202 // Only the primary user can change the locale. 203 // Secondary users and public session users cannot change the locale.
203 user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile); 204 user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
204 if (user && user->email() == user_manager->GetPrimaryUser()->email()) { 205 if (user &&
206 user->email() == user_manager->GetPrimaryUser()->email() &&
207 user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
205 profile->ChangeAppLocale(language_code, 208 profile->ChangeAppLocale(language_code,
206 Profile::APP_LOCALE_CHANGED_VIA_SETTINGS); 209 Profile::APP_LOCALE_CHANGED_VIA_SETTINGS);
207 } 210 }
208 } 211 }
209 212
210 void CrosLanguageOptionsHandler::RestartCallback(const base::ListValue* args) { 213 void CrosLanguageOptionsHandler::RestartCallback(const base::ListValue* args) {
211 content::RecordAction(UserMetricsAction("LanguageOptions_SignOut")); 214 content::RecordAction(UserMetricsAction("LanguageOptions_SignOut"));
212 chrome::AttemptUserExit(); 215 chrome::AttemptUserExit();
213 } 216 }
214 217
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); 321 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id);
319 const extensions::Extension* extension = 322 const extensions::Extension* extension =
320 enabled_extensions.GetByID(extension_id); 323 enabled_extensions.GetByID(extension_id);
321 if (extension) 324 if (extension)
322 entry->SetString("extensionName", extension->name()); 325 entry->SetString("extensionName", extension->name());
323 } 326 }
324 } 327 }
325 328
326 } // namespace options 329 } // namespace options
327 } // namespace chromeos 330 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/language_options.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698