OLD | NEW |
---|---|
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/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 language_list_->GetIndexFromLocale(locale)); | 71 language_list_->GetIndexFromLocale(locale)); |
72 }; | 72 }; |
73 | 73 |
74 void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) { | 74 void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) { |
75 DCHECK(menu_ != NULL); | 75 DCHECK(menu_ != NULL); |
76 menu_->SetMinimumWidth(width); | 76 menu_->SetMinimumWidth(width); |
77 } | 77 } |
78 | 78 |
79 // static | 79 // static |
80 void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) { | 80 void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) { |
81 if (g_browser_process->GetApplicationLocale() == locale) { | |
82 return; | |
83 } | |
81 // Save new locale. | 84 // Save new locale. |
82 DCHECK(g_browser_process); | 85 DCHECK(g_browser_process); |
Denis Lagno
2010/11/11 19:48:03
move this DCHECK before anything else
Denis Lagno
2010/11/12 11:51:35
Done.
| |
83 PrefService* prefs = g_browser_process->local_state(); | 86 PrefService* prefs = g_browser_process->local_state(); |
84 // TODO(markusheintz): If the preference is managed and can not be changed by | 87 // TODO(markusheintz): If the preference is managed and can not be changed by |
85 // the user, changing the language should be disabled in the UI. | 88 // the user, changing the language should be disabled in the UI. |
86 // TODO(markusheintz): Change the if condition to prefs->IsUserModifiable() | 89 // TODO(markusheintz): Change the if condition to prefs->IsUserModifiable() |
87 // once Mattias landed his pending patch. | 90 // once Mattias landed his pending patch. |
88 if (!prefs->IsManagedPreference(prefs::kApplicationLocale)) { | 91 if (!prefs->IsManagedPreference(prefs::kApplicationLocale)) { |
89 prefs->SetString(prefs::kApplicationLocale, locale); | 92 prefs->SetString(prefs::kApplicationLocale, locale); |
90 prefs->SavePersistentPrefs(); | 93 prefs->SavePersistentPrefs(); |
91 | 94 |
92 // Switch the locale. | 95 // Switch the locale. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 void LanguageSwitchMenu::ExecuteCommand(int command_id) { | 145 void LanguageSwitchMenu::ExecuteCommand(int command_id) { |
143 const std::string locale = language_list_->GetLocaleFromIndex(command_id); | 146 const std::string locale = language_list_->GetLocaleFromIndex(command_id); |
144 SwitchLanguage(locale); | 147 SwitchLanguage(locale); |
145 InitLanguageMenu(); | 148 InitLanguageMenu(); |
146 | 149 |
147 // Update all view hierarchies that the locale has changed. | 150 // Update all view hierarchies that the locale has changed. |
148 views::Widget::NotifyLocaleChanged(); | 151 views::Widget::NotifyLocaleChanged(); |
149 } | 152 } |
150 | 153 |
151 } // namespace chromeos | 154 } // namespace chromeos |
OLD | NEW |