| 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 #ifndef CHROME_BROWSER_CHARACTER_ENCODING_H_ | 5 #ifndef CHROME_BROWSER_CHARACTER_ENCODING_H_ |
| 6 #define CHROME_BROWSER_CHARACTER_ENCODING_H_ | 6 #define CHROME_BROWSER_CHARACTER_ENCODING_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 | 13 |
| 14 class CharacterEncoding { | 14 class CharacterEncoding { |
| 15 public: | 15 public: |
| 16 // Enumeration of the types of Browser encoding name we | 16 // Enumeration of the types of Browser encoding name we |
| 17 // currently support. This is defined outside of Browser | 17 // currently support. This is defined outside of Browser |
| 18 // to avoid cyclical dependencies. | 18 // to avoid cyclical dependencies. |
| 19 | 19 |
| 20 // Structure to save encoding information. | 20 // Structure to save encoding information. |
| 21 struct EncodingInfo { | 21 struct EncodingInfo { |
| 22 explicit EncodingInfo(int id); | 22 explicit EncodingInfo(int id); |
| 23 // Gets string key of EncodingInfo. With this method, we can use | 23 // Gets string key of EncodingInfo. With this method, we can use |
| 24 // l10n_util::SortVectorWithStringKey to sort the encoding menu items | 24 // l10n_util::SortVectorWithStringKey to sort the encoding menu items |
| 25 // by current locale character sequence. We need to keep the order within | 25 // by current locale character sequence. We need to keep the order within |
| 26 // encoding category name, that's why we use category name as key. | 26 // encoding category name, that's why we use category name as key. |
| 27 const string16& GetStringKey() const { return encoding_category_name; } | 27 const base::string16& GetStringKey() const { return encoding_category_name;
} |
| 28 | 28 |
| 29 // Encoding command id. | 29 // Encoding command id. |
| 30 int encoding_id; | 30 int encoding_id; |
| 31 // Encoding display name. | 31 // Encoding display name. |
| 32 string16 encoding_display_name; | 32 base::string16 encoding_display_name; |
| 33 // Encoding category name. | 33 // Encoding category name. |
| 34 string16 encoding_category_name; | 34 base::string16 encoding_category_name; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 // Return canonical encoding name according to the command ID. | 37 // Return canonical encoding name according to the command ID. |
| 38 // THIS FUNCTION IS NOT THREADSAFE. You must run this function | 38 // THIS FUNCTION IS NOT THREADSAFE. You must run this function |
| 39 // only in UI thread. | 39 // only in UI thread. |
| 40 static std::string GetCanonicalEncodingNameByCommandId(int id); | 40 static std::string GetCanonicalEncodingNameByCommandId(int id); |
| 41 | 41 |
| 42 // Return display name of canonical encoding according to the command | 42 // Return display name of canonical encoding according to the command |
| 43 // ID. THIS FUNCTION IS NOT THREADSAFE. You must run this function | 43 // ID. THIS FUNCTION IS NOT THREADSAFE. You must run this function |
| 44 // only in UI thread. | 44 // only in UI thread. |
| 45 static string16 GetCanonicalEncodingDisplayNameByCommandId(int id); | 45 static base::string16 GetCanonicalEncodingDisplayNameByCommandId(int id); |
| 46 | 46 |
| 47 // Return count number of all supported canonical encoding. | 47 // Return count number of all supported canonical encoding. |
| 48 static int GetSupportCanonicalEncodingCount(); | 48 static int GetSupportCanonicalEncodingCount(); |
| 49 | 49 |
| 50 // Return canonical encoding name according to the index, which starts | 50 // Return canonical encoding name according to the index, which starts |
| 51 // from zero to GetSupportCanonicalEncodingCount() - 1. THIS FUNCTION | 51 // from zero to GetSupportCanonicalEncodingCount() - 1. THIS FUNCTION |
| 52 // IS NOT THREADSAFE. You must run this function only in UI thread. | 52 // IS NOT THREADSAFE. You must run this function only in UI thread. |
| 53 static std::string GetCanonicalEncodingNameByIndex(int index); | 53 static std::string GetCanonicalEncodingNameByIndex(int index); |
| 54 | 54 |
| 55 // Return display name of canonical encoding according to the index, | 55 // Return display name of canonical encoding according to the index, |
| 56 // which starts from zero to GetSupportCanonicalEncodingCount() - 1. | 56 // which starts from zero to GetSupportCanonicalEncodingCount() - 1. |
| 57 // THIS FUNCTION IS NOT THREADSAFE. You must run this function | 57 // THIS FUNCTION IS NOT THREADSAFE. You must run this function |
| 58 // only in UI thread. | 58 // only in UI thread. |
| 59 static string16 GetCanonicalEncodingDisplayNameByIndex(int index); | 59 static base::string16 GetCanonicalEncodingDisplayNameByIndex(int index); |
| 60 | 60 |
| 61 // Return encoding command id according to the index, which starts from | 61 // Return encoding command id according to the index, which starts from |
| 62 // zero to GetSupportCanonicalEncodingCount() - 1. Otherwise returns 0. | 62 // zero to GetSupportCanonicalEncodingCount() - 1. Otherwise returns 0. |
| 63 static int GetEncodingCommandIdByIndex(int index); | 63 static int GetEncodingCommandIdByIndex(int index); |
| 64 | 64 |
| 65 // Return canonical encoding name according to the encoding alias name. THIS | 65 // Return canonical encoding name according to the encoding alias name. THIS |
| 66 // FUNCTION IS NOT THREADSAFE. You must run this function only in UI thread. | 66 // FUNCTION IS NOT THREADSAFE. You must run this function only in UI thread. |
| 67 static std::string GetCanonicalEncodingNameByAliasName( | 67 static std::string GetCanonicalEncodingNameByAliasName( |
| 68 const std::string& alias_name); | 68 const std::string& alias_name); |
| 69 | 69 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 97 // valid, return corresponding encoding command id. Otherwise return 0; | 97 // valid, return corresponding encoding command id. Otherwise return 0; |
| 98 static int GetCommandIdByCanonicalEncodingName( | 98 static int GetCommandIdByCanonicalEncodingName( |
| 99 const std::string& encoding_name); | 99 const std::string& encoding_name); |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 // Disallow instantiating it since this class only contains static methods. | 102 // Disallow instantiating it since this class only contains static methods. |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(CharacterEncoding); | 103 DISALLOW_IMPLICIT_CONSTRUCTORS(CharacterEncoding); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 #endif // CHROME_BROWSER_CHARACTER_ENCODING_H_ | 106 #endif // CHROME_BROWSER_CHARACTER_ENCODING_H_ |
| OLD | NEW |