| OLD | NEW |
| 1 // Copyright (c) 2009 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/language_combobox_model.h" | 5 #include "chrome/browser/language_combobox_model.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.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" |
| 11 #include "chrome/browser/metrics/user_metrics.h" | 11 #include "chrome/browser/metrics/user_metrics.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 LanguageComboboxModel::LanguageComboboxModel() | 144 LanguageComboboxModel::LanguageComboboxModel() |
| 145 : profile_(NULL) { | 145 : profile_(NULL) { |
| 146 } | 146 } |
| 147 | 147 |
| 148 LanguageComboboxModel::LanguageComboboxModel( | 148 LanguageComboboxModel::LanguageComboboxModel( |
| 149 Profile* profile, const std::vector<std::string>& locale_codes) | 149 Profile* profile, const std::vector<std::string>& locale_codes) |
| 150 : LanguageList(locale_codes), | 150 : LanguageList(locale_codes), |
| 151 profile_(profile) { | 151 profile_(profile) { |
| 152 } | 152 } |
| 153 | 153 |
| 154 int LanguageComboboxModel::GetItemCount() { |
| 155 return get_languages_count(); |
| 156 } |
| 157 |
| 158 string16 LanguageComboboxModel::GetItemAt(int index) { |
| 159 return WideToUTF16Hack(GetLanguageNameAt(index)); |
| 160 } |
| 161 |
| 154 // Returns the index of the language currently specified in the user's | 162 // Returns the index of the language currently specified in the user's |
| 155 // preference file. Note that it's possible for language A to be picked | 163 // preference file. Note that it's possible for language A to be picked |
| 156 // while chrome is currently in language B if the user specified language B | 164 // while chrome is currently in language B if the user specified language B |
| 157 // via --lang. Since --lang is not a persistent setting, it seems that it | 165 // via --lang. Since --lang is not a persistent setting, it seems that it |
| 158 // shouldn't be reflected in this combo box. We return -1 if the value in | 166 // shouldn't be reflected in this combo box. We return -1 if the value in |
| 159 // the pref doesn't map to a know language (possible if the user edited the | 167 // the pref doesn't map to a know language (possible if the user edited the |
| 160 // prefs file manually). | 168 // prefs file manually). |
| 161 int LanguageComboboxModel::GetSelectedLanguageIndex(const std::string& prefs) { | 169 int LanguageComboboxModel::GetSelectedLanguageIndex(const std::string& prefs) { |
| 162 PrefService* local_state; | 170 PrefService* local_state; |
| 163 if (!profile_) | 171 if (!profile_) |
| 164 local_state = g_browser_process->local_state(); | 172 local_state = g_browser_process->local_state(); |
| 165 else | 173 else |
| 166 local_state = profile_->GetPrefs(); | 174 local_state = profile_->GetPrefs(); |
| 167 | 175 |
| 168 DCHECK(local_state); | 176 DCHECK(local_state); |
| 169 const std::string& current_locale = local_state->GetString(prefs.c_str()); | 177 const std::string& current_locale = local_state->GetString(prefs.c_str()); |
| 170 | 178 |
| 171 return GetIndexFromLocale(current_locale); | 179 return GetIndexFromLocale(current_locale); |
| 172 } | 180 } |
| OLD | NEW |