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

Side by Side Diff: chrome/browser/views/options/languages_page_view.cc

Issue 126223: Replace std:;wstring with std::string in locale-name related APIs.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include <windows.h> 4 #include <windows.h>
5 #include <shlobj.h> 5 #include <shlobj.h>
6 #include <vsstyle.h> 6 #include <vsstyle.h>
7 #include <vssym32.h> 7 #include <vssym32.h>
8 8
9 #include "chrome/browser/views/options/languages_page_view.h" 9 #include "chrome/browser/views/options/languages_page_view.h"
10 10
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 views::View* child) { 284 views::View* child) {
285 // Can't init before we're inserted into a Widget, because we require 285 // Can't init before we're inserted into a Widget, because we require
286 // a HWND to parent native child controls to. 286 // a HWND to parent native child controls to.
287 if (is_add && child == this) 287 if (is_add && child == this)
288 Init(); 288 Init();
289 } 289 }
290 290
291 void AddLanguageWindowView::Init() { 291 void AddLanguageWindowView::Init() {
292 // Determine Locale Codes. 292 // Determine Locale Codes.
293 std::vector<std::string> locale_codes; 293 std::vector<std::string> locale_codes;
294 const std::wstring app_locale = g_browser_process->GetApplicationLocale(); 294 const std::string app_locale = g_browser_process->GetApplicationLocale();
295 for (size_t i = 0; i < arraysize(accept_language_list); ++i) { 295 for (size_t i = 0; i < arraysize(accept_language_list); ++i) {
296 std::wstring local_name = 296 string16 display_name =
297 l10n_util::GetLocalName(accept_language_list[i], app_locale, false); 297 l10n_util::GetDisplayNameForLocale(accept_language_list[i],
298 app_locale, false);
298 // This is a hack. If ICU doesn't have a translated name for 299 // This is a hack. If ICU doesn't have a translated name for
299 // this language, GetLocalName will just return the language code. 300 // this language, GetDisplayNameForLocale will just return the
300 // In that case, we skip it. 301 // language code. In that case, we skip it.
301 // TODO(jungshik) : Put them at the of the list with language codes 302 // TODO(jungshik) : Put them at the of the list with language codes
302 // enclosed by brackets. 303 // enclosed by brackets.
303 if (IsStringASCII(local_name) && 304 if (IsStringASCII(display_name) &&
304 WideToASCII(local_name) == accept_language_list[i]) 305 UTF16ToASCII(display_name) == accept_language_list[i])
305 continue; 306 continue;
306 locale_codes.push_back(accept_language_list[i]); 307 locale_codes.push_back(accept_language_list[i]);
307 } 308 }
308 accept_language_combobox_model_.reset(new LanguageComboboxModel( 309 accept_language_combobox_model_.reset(new LanguageComboboxModel(
309 profile_, locale_codes)); 310 profile_, locale_codes));
310 accept_language_combobox_ = new views::Combobox( 311 accept_language_combobox_ = new views::Combobox(
311 accept_language_combobox_model_.get()); 312 accept_language_combobox_model_.get());
312 accept_language_combobox_->SetSelectedItem(0); 313 accept_language_combobox_->SetSelectedItem(0);
313 accept_language_combobox_->set_listener(this); 314 accept_language_combobox_->set_listener(this);
314 AddChildView(accept_language_combobox_); 315 AddChildView(accept_language_combobox_);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 Add(languages_vector.at(i)); 375 Add(languages_vector.at(i));
375 } 376 }
376 } 377 }
377 378
378 void LanguageOrderTableModel::SetObserver(TableModelObserver* observer) { 379 void LanguageOrderTableModel::SetObserver(TableModelObserver* observer) {
379 observer_ = observer; 380 observer_ = observer;
380 } 381 }
381 382
382 std::wstring LanguageOrderTableModel::GetText(int row, int column_id) { 383 std::wstring LanguageOrderTableModel::GetText(int row, int column_id) {
383 DCHECK(row >= 0 && row < RowCount()); 384 DCHECK(row >= 0 && row < RowCount());
384 const std::wstring app_locale = g_browser_process->GetApplicationLocale(); 385 const std::string app_locale = g_browser_process->GetApplicationLocale();
385 return l10n_util::GetLocalName(languages_.at(row), app_locale, true); 386 return l10n_util::GetDisplayNameForLocale(languages_.at(row),
387 app_locale,
388 true);
386 } 389 }
387 390
388 void LanguageOrderTableModel::Add(const std::string& language) { 391 void LanguageOrderTableModel::Add(const std::string& language) {
389 if (language.empty()) 392 if (language.empty())
390 return; 393 return;
391 // Check for selecting duplicated language. 394 // Check for selecting duplicated language.
392 for (std::vector<std::string>::const_iterator cit = languages_.begin(); 395 for (std::vector<std::string>::const_iterator cit = languages_.begin();
393 cit != languages_.end(); ++cit) 396 cit != languages_.end(); ++cit)
394 if (*cit == language) 397 if (*cit == language)
395 return; 398 return;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 language_order_table_model_->SetAcceptLanguagesString( 698 language_order_table_model_->SetAcceptLanguagesString(
696 WideToASCII(accept_languages_.GetValue())); 699 WideToASCII(accept_languages_.GetValue()));
697 } 700 }
698 if (!pref_name || *pref_name == prefs::kApplicationLocale) { 701 if (!pref_name || *pref_name == prefs::kApplicationLocale) {
699 int index = ui_language_model_->GetSelectedLanguageIndex( 702 int index = ui_language_model_->GetSelectedLanguageIndex(
700 prefs::kApplicationLocale); 703 prefs::kApplicationLocale);
701 if (-1 == index) { 704 if (-1 == index) {
702 // The pref value for locale isn't valid. Use the current app locale 705 // The pref value for locale isn't valid. Use the current app locale
703 // (which is what we're currently using). 706 // (which is what we're currently using).
704 index = ui_language_model_->GetIndexFromLocale( 707 index = ui_language_model_->GetIndexFromLocale(
705 WideToASCII(g_browser_process->GetApplicationLocale())); 708 g_browser_process->GetApplicationLocale());
706 } 709 }
707 DCHECK(-1 != index); 710 DCHECK(-1 != index);
708 change_ui_language_combobox_->SetSelectedItem(index); 711 change_ui_language_combobox_->SetSelectedItem(index);
709 starting_ui_language_index_ = index; 712 starting_ui_language_index_ = index;
710 } 713 }
711 if (!pref_name || *pref_name == prefs::kSpellCheckDictionary) { 714 if (!pref_name || *pref_name == prefs::kSpellCheckDictionary) {
712 int index = dictionary_language_model_->GetSelectedLanguageIndex( 715 int index = dictionary_language_model_->GetSelectedLanguageIndex(
713 prefs::kSpellCheckDictionary); 716 prefs::kSpellCheckDictionary);
714 717
715 // If the index for the current language cannot be found, it is due to 718 // If the index for the current language cannot be found, it is due to
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 } 873 }
871 874
872 if (enable_spellcheck_checkbox_clicked_) 875 if (enable_spellcheck_checkbox_clicked_)
873 enable_spellcheck_.SetValue(enable_spellchecking_checkbox_->checked()); 876 enable_spellcheck_.SetValue(enable_spellchecking_checkbox_->checked());
874 877
875 if (enable_autospellcorrect_checkbox_clicked_) { 878 if (enable_autospellcorrect_checkbox_clicked_) {
876 enable_autospellcorrect_.SetValue( 879 enable_autospellcorrect_.SetValue(
877 enable_autospellcorrect_checkbox_->checked()); 880 enable_autospellcorrect_checkbox_->checked());
878 } 881 }
879 } 882 }
OLDNEW
« no previous file with comments | « chrome/browser/views/options/language_combobox_model.cc ('k') | chrome/test/automated_ui_tests/automated_ui_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698