OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/ui/toolbar/encoding_menu_controller.h" | 5 #include "chrome/browser/ui/toolbar/encoding_menu_controller.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/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 95 |
96 if (!encoding.empty()) { | 96 if (!encoding.empty()) { |
97 return encoding == | 97 return encoding == |
98 CharacterEncoding::GetCanonicalEncodingNameByCommandId(item_id); | 98 CharacterEncoding::GetCanonicalEncodingNameByCommandId(item_id); |
99 } | 99 } |
100 | 100 |
101 return false; | 101 return false; |
102 } | 102 } |
103 | 103 |
104 void EncodingMenuController::GetEncodingMenuItems(Profile* profile, | 104 void EncodingMenuController::GetEncodingMenuItems(Profile* profile, |
105 EncodingMenuItemList* menuItems) { | 105 EncodingMenuItemList* menuItems) { |
Evan Martin
2010/12/24 01:00:42
This really should be menu_items, not menuItems.
N
Avi (use Gerrit)
2010/12/28 15:02:55
Done anyway.
| |
106 | 106 |
107 DCHECK(menuItems); | 107 DCHECK(menuItems); |
108 EncodingMenuItem separator(0, string16()); | 108 EncodingMenuItem separator(0, string16()); |
109 | 109 |
110 menuItems->clear(); | 110 menuItems->clear(); |
111 menuItems->push_back( | 111 menuItems->push_back( |
112 EncodingMenuItem(IDC_ENCODING_AUTO_DETECT, | 112 EncodingMenuItem(IDC_ENCODING_AUTO_DETECT, |
113 l10n_util::GetStringUTF16(IDS_ENCODING_AUTO_DETECT))); | 113 l10n_util::GetStringUTF16(IDS_ENCODING_AUTO_DETECT))); |
114 menuItems->push_back(separator); | 114 menuItems->push_back(separator); |
115 | 115 |
116 // Create current display encoding list. | 116 // Create current display encoding list. |
117 const std::vector<CharacterEncoding::EncodingInfo>* encodings; | 117 const std::vector<CharacterEncoding::EncodingInfo>* encodings; |
118 | 118 |
119 // Build the list of encoding ids : It is made of the | 119 // Build the list of encoding ids : It is made of the |
120 // locale-dependent short list, the cache of recently selected | 120 // locale-dependent short list, the cache of recently selected |
121 // encodings and other encodings. | 121 // encodings and other encodings. |
122 encodings = CharacterEncoding::GetCurrentDisplayEncodings( | 122 encodings = CharacterEncoding::GetCurrentDisplayEncodings( |
123 g_browser_process->GetApplicationLocale(), | 123 g_browser_process->GetApplicationLocale(), |
124 profile->GetPrefs()->GetString(prefs::kStaticEncodings), | 124 profile->GetPrefs()->GetString(prefs::kStaticEncodings), |
125 profile->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding)); | 125 profile->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding)); |
126 DCHECK(encodings); | 126 DCHECK(encodings); |
127 DCHECK(!encodings->empty()); | 127 DCHECK(!encodings->empty()); |
128 | 128 |
129 // Build up output list for menu. | 129 // Build up output list for menu. |
130 std::vector<CharacterEncoding::EncodingInfo>::const_iterator it; | 130 std::vector<CharacterEncoding::EncodingInfo>::const_iterator it; |
131 for (it = encodings->begin(); it != encodings->end(); ++it) { | 131 for (it = encodings->begin(); it != encodings->end(); ++it) { |
132 if (it->encoding_id) { | 132 if (it->encoding_id) { |
133 std::wstring encoding = it->encoding_display_name; | 133 string16 encoding = it->encoding_display_name; |
134 base::i18n::AdjustStringForLocaleDirection(&encoding); | 134 base::i18n::AdjustStringForLocaleDirection(&encoding); |
135 menuItems->push_back(EncodingMenuItem(it->encoding_id, | 135 menuItems->push_back(EncodingMenuItem(it->encoding_id, encoding)); |
136 WideToUTF16(encoding))); | |
137 } else { | 136 } else { |
138 menuItems->push_back(separator); | 137 menuItems->push_back(separator); |
139 } | 138 } |
140 } | 139 } |
141 } | 140 } |
OLD | NEW |