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

Side by Side Diff: chrome/browser/chromeos/login/language_switch_menu.cc

Issue 2809058: Add application locale policy. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: " Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/chromeos/login/language_switch_menu.h" 5 #include "chrome/browser/chromeos/login/language_switch_menu.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) { 81 void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) {
82 DCHECK(menu_ != NULL); 82 DCHECK(menu_ != NULL);
83 gtk_widget_set_size_request(menu_->GetNativeMenu(), width, -1); 83 gtk_widget_set_size_request(menu_->GetNativeMenu(), width, -1);
84 } 84 }
85 85
86 // static 86 // static
87 void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) { 87 void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) {
88 // Save new locale. 88 // Save new locale.
89 DCHECK(g_browser_process); 89 DCHECK(g_browser_process);
90 PrefService* prefs = g_browser_process->local_state(); 90 PrefService* prefs = g_browser_process->local_state();
91 prefs->SetString(prefs::kApplicationLocale, locale); 91 // TODO(markusheintz): If the preference is managed and can not be changed by
92 prefs->SavePersistentPrefs(); 92 // the user, changing the language should be disabled in the UI.
93 // TODO(markusheintz): Change the if condition to prefs->IsUserModifiable()
94 // once Mattias landed his pending patch.
95 if (!prefs->IsManagedPreference(prefs::kApplicationLocale)) {
96 prefs->SetString(prefs::kApplicationLocale, locale);
97 prefs->SavePersistentPrefs();
93 98
94 // Switch the locale. 99 // Switch the locale.
95 ResourceBundle::ReloadSharedInstance(UTF8ToWide(locale)); 100 ResourceBundle::ReloadSharedInstance(UTF8ToWide(locale));
96 101
97 // Enable the keyboard layouts that are necessary for the new locale. 102 // Enable the keyboard layouts that are necessary for the new locale.
98 chromeos::input_method::EnableInputMethods( 103 chromeos::input_method::EnableInputMethods(
99 locale, chromeos::input_method::kKeyboardLayoutsOnly, 104 locale, chromeos::input_method::kKeyboardLayoutsOnly,
100 kHardwareKeyboardLayout); 105 kHardwareKeyboardLayout);
101 106
102 // The following line does not seem to affect locale anyhow. Maybe in future.. 107 // The following line does not seem to affect locale anyhow. Maybe in
103 g_browser_process->SetApplicationLocale(locale); 108 // future..
109 g_browser_process->SetApplicationLocale(locale);
110 }
104 } 111 }
105 112
106 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
107 // views::ViewMenuDelegate implementation. 114 // views::ViewMenuDelegate implementation.
108 115
109 void LanguageSwitchMenu::RunMenu(views::View* source, const gfx::Point& pt) { 116 void LanguageSwitchMenu::RunMenu(views::View* source, const gfx::Point& pt) {
110 DCHECK(menu_ != NULL); 117 DCHECK(menu_ != NULL);
111 gfx::Point point(pt); 118 gfx::Point point(pt);
112 point.Offset(delta_x_, delta_y_); 119 point.Offset(delta_x_, delta_y_);
113 menu_->RunMenuAt(point, views::Menu2::ALIGN_TOPRIGHT); 120 menu_->RunMenuAt(point, views::Menu2::ALIGN_TOPRIGHT);
(...skipping 18 matching lines...) Expand all
132 void LanguageSwitchMenu::ExecuteCommand(int command_id) { 139 void LanguageSwitchMenu::ExecuteCommand(int command_id) {
133 const std::string locale = language_list_->GetLocaleFromIndex(command_id); 140 const std::string locale = language_list_->GetLocaleFromIndex(command_id);
134 SwitchLanguage(locale); 141 SwitchLanguage(locale);
135 InitLanguageMenu(); 142 InitLanguageMenu();
136 143
137 // Update all view hierarchies that the locale has changed. 144 // Update all view hierarchies that the locale has changed.
138 views::Widget::NotifyLocaleChanged(); 145 views::Widget::NotifyLocaleChanged();
139 } 146 }
140 147
141 } // namespace chromeos 148 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/candidate_window.cc ('k') | chrome/browser/configuration_policy_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698