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

Side by Side Diff: chrome/browser/default_encoding_combo_model.cc

Issue 3159031: Remove wstrings from bookmarks, part 12. (Closed)
Patch Set: rebased ToT Created 10 years, 4 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/default_encoding_combo_model.h" 5 #include "chrome/browser/default_encoding_combo_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/l10n_util_collator.h" 8 #include "app/l10n_util_collator.h"
9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/pref_member.h" 11 #include "chrome/browser/pref_member.h"
11 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
12 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 14
14 DefaultEncodingComboboxModel::DefaultEncodingComboboxModel() { 15 DefaultEncodingComboboxModel::DefaultEncodingComboboxModel() {
15 // Initialize the vector of all sorted encodings according to current 16 // Initialize the vector of all sorted encodings according to current
16 // UI locale. 17 // UI locale.
17 std::string locale = g_browser_process->GetApplicationLocale(); 18 std::string locale = g_browser_process->GetApplicationLocale();
18 int size = CharacterEncoding::GetSupportCanonicalEncodingCount(); 19 int size = CharacterEncoding::GetSupportCanonicalEncodingCount();
19 for (int i = 0; i < size; ++i) { 20 for (int i = 0; i < size; ++i) {
20 sorted_encoding_list_.push_back(CharacterEncoding::EncodingInfo( 21 sorted_encoding_list_.push_back(CharacterEncoding::EncodingInfo(
21 CharacterEncoding::GetEncodingCommandIdByIndex(i))); 22 CharacterEncoding::GetEncodingCommandIdByIndex(i)));
22 } 23 }
23 l10n_util::SortVectorWithStringKey(locale, &sorted_encoding_list_, true); 24 l10n_util::SortVectorWithStringKey(locale, &sorted_encoding_list_, true);
24 } 25 }
25 26
26 std::wstring DefaultEncodingComboboxModel::GetItemAt(int index) { 27 string16 DefaultEncodingComboboxModel::GetItemAt(int index) {
27 DCHECK(index >= 0 && index < GetItemCount()); 28 DCHECK(index >= 0 && index < GetItemCount());
28 return sorted_encoding_list_[index].encoding_display_name; 29 return WideToUTF16Hack(sorted_encoding_list_[index].encoding_display_name);
29 } 30 }
30 31
31 std::string DefaultEncodingComboboxModel::GetEncodingCharsetByIndex(int index) { 32 std::string DefaultEncodingComboboxModel::GetEncodingCharsetByIndex(int index) {
32 DCHECK(index >= 0 && index < GetItemCount()); 33 DCHECK(index >= 0 && index < GetItemCount());
33 int encoding_id = sorted_encoding_list_[index].encoding_id; 34 int encoding_id = sorted_encoding_list_[index].encoding_id;
34 return CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); 35 return CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id);
35 } 36 }
36 37
37 int DefaultEncodingComboboxModel::GetSelectedEncodingIndex(Profile* profile) { 38 int DefaultEncodingComboboxModel::GetSelectedEncodingIndex(Profile* profile) {
38 StringPrefMember current_encoding_string; 39 StringPrefMember current_encoding_string;
39 current_encoding_string.Init(prefs::kDefaultCharset, 40 current_encoding_string.Init(prefs::kDefaultCharset,
40 profile->GetPrefs(), 41 profile->GetPrefs(),
41 NULL); 42 NULL);
42 const std::string current_encoding = current_encoding_string.GetValue(); 43 const std::string current_encoding = current_encoding_string.GetValue();
43 for (int i = 0; i < GetItemCount(); ++i) { 44 for (int i = 0; i < GetItemCount(); ++i) {
44 if (GetEncodingCharsetByIndex(i) == current_encoding) 45 if (GetEncodingCharsetByIndex(i) == current_encoding)
45 return i; 46 return i;
46 } 47 }
47 48
48 return 0; 49 return 0;
49 } 50 }
OLDNEW
« no previous file with comments | « chrome/browser/default_encoding_combo_model.h ('k') | chrome/browser/gtk/bookmark_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698