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/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 "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 DefaultEncodingComboboxModel::~DefaultEncodingComboboxModel() { | 27 DefaultEncodingComboboxModel::~DefaultEncodingComboboxModel() { |
28 } | 28 } |
29 | 29 |
30 int DefaultEncodingComboboxModel::GetItemCount() { | 30 int DefaultEncodingComboboxModel::GetItemCount() { |
31 return static_cast<int>(sorted_encoding_list_.size()); | 31 return static_cast<int>(sorted_encoding_list_.size()); |
32 } | 32 } |
33 | 33 |
34 string16 DefaultEncodingComboboxModel::GetItemAt(int index) { | 34 string16 DefaultEncodingComboboxModel::GetItemAt(int index) { |
35 DCHECK(index >= 0 && index < GetItemCount()); | 35 DCHECK(index >= 0 && index < GetItemCount()); |
36 return WideToUTF16Hack(sorted_encoding_list_[index].encoding_display_name); | 36 return sorted_encoding_list_[index].encoding_display_name; |
37 } | 37 } |
38 | 38 |
39 std::string DefaultEncodingComboboxModel::GetEncodingCharsetByIndex(int index) { | 39 std::string DefaultEncodingComboboxModel::GetEncodingCharsetByIndex(int index) { |
40 DCHECK(index >= 0 && index < GetItemCount()); | 40 DCHECK(index >= 0 && index < GetItemCount()); |
41 int encoding_id = sorted_encoding_list_[index].encoding_id; | 41 int encoding_id = sorted_encoding_list_[index].encoding_id; |
42 return CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); | 42 return CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); |
43 } | 43 } |
44 | 44 |
45 int DefaultEncodingComboboxModel::GetSelectedEncodingIndex(Profile* profile) { | 45 int DefaultEncodingComboboxModel::GetSelectedEncodingIndex(Profile* profile) { |
46 StringPrefMember current_encoding_string; | 46 StringPrefMember current_encoding_string; |
47 current_encoding_string.Init(prefs::kDefaultCharset, | 47 current_encoding_string.Init(prefs::kDefaultCharset, |
48 profile->GetPrefs(), | 48 profile->GetPrefs(), |
49 NULL); | 49 NULL); |
50 const std::string current_encoding = current_encoding_string.GetValue(); | 50 const std::string current_encoding = current_encoding_string.GetValue(); |
51 for (int i = 0; i < GetItemCount(); ++i) { | 51 for (int i = 0; i < GetItemCount(); ++i) { |
52 if (GetEncodingCharsetByIndex(i) == current_encoding) | 52 if (GetEncodingCharsetByIndex(i) == current_encoding) |
53 return i; | 53 return i; |
54 } | 54 } |
55 | 55 |
56 return 0; | 56 return 0; |
57 } | 57 } |
OLD | NEW |