OLD | NEW |
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 | 4 |
5 #include "chrome/browser/encoding_menu_controller_delegate.h" | 5 #include "chrome/browser/encoding_menu_controller_delegate.h" |
6 | 6 |
7 #include "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/character_encoding.h" | 10 #include "chrome/browser/character_encoding.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 Profile* profile, Menu* encoding_menu) { | 101 Profile* profile, Menu* encoding_menu) { |
102 // Append auto-detection item. | 102 // Append auto-detection item. |
103 encoding_menu->AppendMenuItem(IDC_ENCODING_AUTO_DETECT, | 103 encoding_menu->AppendMenuItem(IDC_ENCODING_AUTO_DETECT, |
104 l10n_util::GetString(IDS_ENCODING_AUTO_DETECT), | 104 l10n_util::GetString(IDS_ENCODING_AUTO_DETECT), |
105 Menu::CHECKBOX); | 105 Menu::CHECKBOX); |
106 | 106 |
107 // Append encoding item. | 107 // Append encoding item. |
108 encoding_menu->AppendSeparator(); | 108 encoding_menu->AppendSeparator(); |
109 // Create current display encoding list. | 109 // Create current display encoding list. |
110 std::wstring cur_locale = g_browser_process->GetApplicationLocale(); | 110 std::wstring cur_locale = g_browser_process->GetApplicationLocale(); |
111 const std::vector<int>* encoding_ids; | 111 const std::vector<CharacterEncoding::EncodingInfo>* encodings; |
112 // Build the list of encoding ids : It is made of the | 112 // Build the list of encoding ids : It is made of the |
113 // locale-dependent short list, the cache of recently selected | 113 // locale-dependent short list, the cache of recently selected |
114 // encodings and other encodings. | 114 // encodings and other encodings. |
115 encoding_ids = CharacterEncoding::GetCurrentDisplayEncodings( | 115 encodings = CharacterEncoding::GetCurrentDisplayEncodings( |
| 116 cur_locale, |
116 profile->GetPrefs()->GetString(prefs::kStaticEncodings), | 117 profile->GetPrefs()->GetString(prefs::kStaticEncodings), |
117 profile->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding)); | 118 profile->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding)); |
118 DCHECK(encoding_ids); | 119 DCHECK(encodings); |
119 DCHECK(!encoding_ids->empty()); | 120 DCHECK(!encodings->empty()); |
120 unsigned len = static_cast<unsigned>(encoding_ids->size()); | 121 unsigned len = static_cast<unsigned>(encodings->size()); |
121 // Add encoding menus. | 122 // Add encoding menus. |
122 std::vector<int>::const_iterator it; | 123 std::vector<CharacterEncoding::EncodingInfo>::const_iterator it; |
123 for (it = encoding_ids->begin(); it != encoding_ids->end(); ++it) { | 124 for (it = encodings->begin(); it != encodings->end(); ++it) { |
124 if (*it) { | 125 if (it->encoding_id) { |
125 std::wstring encoding = | 126 std::wstring encoding = it->encoding_display_name; |
126 CharacterEncoding::GetCanonicalEncodingDisplayNameByCommandId(*it); | |
127 std::wstring bidi_safe_encoding; | 127 std::wstring bidi_safe_encoding; |
128 if (l10n_util::AdjustStringForLocaleDirection(encoding, | 128 if (l10n_util::AdjustStringForLocaleDirection(encoding, |
129 &bidi_safe_encoding)) | 129 &bidi_safe_encoding)) |
130 encoding.swap(bidi_safe_encoding); | 130 encoding.swap(bidi_safe_encoding); |
131 encoding_menu->AppendMenuItem(*it, encoding, Menu::RADIO); | 131 encoding_menu->AppendMenuItem(it->encoding_id, encoding, Menu::RADIO); |
| 132 } else { |
| 133 encoding_menu->AppendSeparator(); |
132 } | 134 } |
133 else | |
134 encoding_menu->AppendSeparator(); | |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
OLD | NEW |