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

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

Issue 5939002: Error handling added (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | « no previous file | 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) 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 line, WideToUTF16(language_list_->GetLanguageNameAt(line))); 60 line, WideToUTF16(language_list_->GetLanguageNameAt(line)));
61 } 61 }
62 62
63 // Initialize menu here so it appears fast when called. 63 // Initialize menu here so it appears fast when called.
64 menu_.reset(new views::Menu2(&menu_model_)); 64 menu_.reset(new views::Menu2(&menu_model_));
65 } 65 }
66 66
67 std::wstring LanguageSwitchMenu::GetCurrentLocaleName() const { 67 std::wstring LanguageSwitchMenu::GetCurrentLocaleName() const {
68 DCHECK(g_browser_process); 68 DCHECK(g_browser_process);
69 const std::string locale = g_browser_process->GetApplicationLocale(); 69 const std::string locale = g_browser_process->GetApplicationLocale();
70 return language_list_->GetLanguageNameAt( 70 int index = language_list_->GetIndexFromLocale(locale);
71 language_list_->GetIndexFromLocale(locale)); 71 if (index == -1) {
72 // If locale cannot be found (probably user edited prefs file
Nikita (slow) 2010/12/16 15:28:49 I'm not sure that in the original crash users were
73 // manually) - use the default.
74 index = 0;
Nikita (slow) 2010/12/16 15:28:49 Default locale (0) is always en-US?
75 }
76 return language_list_->GetLanguageNameAt(index);
72 }; 77 };
73 78
74 void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) { 79 void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) {
75 DCHECK(menu_ != NULL); 80 DCHECK(menu_ != NULL);
76 menu_->SetMinimumWidth(width); 81 menu_->SetMinimumWidth(width);
77 } 82 }
78 83
79 // static 84 // static
80 void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) { 85 void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) {
81 DCHECK(g_browser_process); 86 DCHECK(g_browser_process);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 void LanguageSwitchMenu::ExecuteCommand(int command_id) { 150 void LanguageSwitchMenu::ExecuteCommand(int command_id) {
146 const std::string locale = language_list_->GetLocaleFromIndex(command_id); 151 const std::string locale = language_list_->GetLocaleFromIndex(command_id);
147 SwitchLanguage(locale); 152 SwitchLanguage(locale);
148 InitLanguageMenu(); 153 InitLanguageMenu();
149 154
150 // Update all view hierarchies that the locale has changed. 155 // Update all view hierarchies that the locale has changed.
151 views::Widget::NotifyLocaleChanged(); 156 views::Widget::NotifyLocaleChanged();
152 } 157 }
153 158
154 } // namespace chromeos 159 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698