| 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/character_encoding.h" | 5 #include "chrome/browser/character_encoding.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 // Static. | 288 // Static. |
| 289 std::wstring CharacterEncoding::GetCanonicalEncodingDisplayNameByIndex( | 289 std::wstring CharacterEncoding::GetCanonicalEncodingDisplayNameByIndex( |
| 290 int index) { | 290 int index) { |
| 291 if (index < canonical_encoding_names_length) | 291 if (index < canonical_encoding_names_length) |
| 292 return GetEncodingDisplayName(canonical_encoding_names[index].name, | 292 return GetEncodingDisplayName(canonical_encoding_names[index].name, |
| 293 canonical_encoding_names[index].category_string_id); | 293 canonical_encoding_names[index].category_string_id); |
| 294 return std::wstring(); | 294 return std::wstring(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 // Static. | 297 // Static. |
| 298 int CharacterEncoding::GetEncodingCommandIdByIndex(int index) { |
| 299 if (index < canonical_encoding_names_length) |
| 300 return canonical_encoding_names[index].resource_id; |
| 301 return 0; |
| 302 } |
| 303 |
| 304 // Static. |
| 298 std::wstring CharacterEncoding::GetCanonicalEncodingNameByAliasName( | 305 std::wstring CharacterEncoding::GetCanonicalEncodingNameByAliasName( |
| 299 const std::wstring& alias_name) { | 306 const std::wstring& alias_name) { |
| 300 // If the input alias_name is already canonical encoding name, just return it. | 307 // If the input alias_name is already canonical encoding name, just return it. |
| 301 const CanonicalEncodingNameToIdMapType* map = | 308 const CanonicalEncodingNameToIdMapType* map = |
| 302 canonical_encoding_name_map_singleton. | 309 canonical_encoding_name_map_singleton. |
| 303 GetCanonicalEncodingNameToIdMapData(); | 310 GetCanonicalEncodingNameToIdMapData(); |
| 304 DCHECK(map); | 311 DCHECK(map); |
| 305 | 312 |
| 306 CanonicalEncodingNameToIdMapType::const_iterator found_id = | 313 CanonicalEncodingNameToIdMapType::const_iterator found_id = |
| 307 map->find(alias_name); | 314 map->find(alias_name); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 // Insert new encoding to head of selected encoding list. | 460 // Insert new encoding to head of selected encoding list. |
| 454 *selected_encodings = encoding_name; | 461 *selected_encodings = encoding_name; |
| 455 // Generate the string for rest selected encoding list. | 462 // Generate the string for rest selected encoding list. |
| 456 for (std::vector<int>::const_iterator it = selected_encoding_list.begin(); | 463 for (std::vector<int>::const_iterator it = selected_encoding_list.begin(); |
| 457 it != selected_encoding_list.end(); ++it) { | 464 it != selected_encoding_list.end(); ++it) { |
| 458 selected_encodings->append(1, L','); | 465 selected_encodings->append(1, L','); |
| 459 selected_encodings->append(GetCanonicalEncodingNameByCommandId(*it)); | 466 selected_encodings->append(GetCanonicalEncodingNameByCommandId(*it)); |
| 460 } | 467 } |
| 461 return true; | 468 return true; |
| 462 } | 469 } |
| OLD | NEW |