| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This class implements a simplified and much stripped down version of | 5 // This class implements a simplified and much stripped down version of |
| 6 // Chrome's app/resource_bundle machinery. It notably avoids unwanted | 6 // Chrome's app/resource_bundle machinery. It notably avoids unwanted |
| 7 // dependencies on things like Skia. | 7 // dependencies on things like Skia. |
| 8 // | 8 // |
| 9 | 9 |
| 10 #ifndef CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ | 10 #ifndef CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 // Retrieves the HINSTANCE of the loaded module handle. May be NULL if a | 37 // Retrieves the HINSTANCE of the loaded module handle. May be NULL if a |
| 38 // resource DLL could not be loaded. | 38 // resource DLL could not be loaded. |
| 39 HMODULE GetResourceModuleHandle(); | 39 HMODULE GetResourceModuleHandle(); |
| 40 | 40 |
| 41 // Retrieves the preferred languages for the current thread, adding them to | 41 // Retrieves the preferred languages for the current thread, adding them to |
| 42 // |language_tags|. | 42 // |language_tags|. |
| 43 static void GetPreferredLanguages(std::vector<std::wstring>* language_tags); | 43 static void GetPreferredLanguages(std::vector<std::wstring>* language_tags); |
| 44 | 44 |
| 45 // Populates |locales_path| with the path to the "Locales" directory. | 45 // Populates |locales_path| with the path to the "Locales" directory. |
| 46 static void DetermineLocalesDirectory(FilePath* locales_path); | 46 static void DetermineLocalesDirectory(base::FilePath* locales_path); |
| 47 | 47 |
| 48 // Returns false if |language_tag| is malformed. | 48 // Returns false if |language_tag| is malformed. |
| 49 static bool IsValidLanguageTag(const std::wstring& language_tag); | 49 static bool IsValidLanguageTag(const std::wstring& language_tag); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 SimpleResourceLoader(); | 52 SimpleResourceLoader(); |
| 53 ~SimpleResourceLoader(); | 53 ~SimpleResourceLoader(); |
| 54 | 54 |
| 55 // Finds the most-preferred resource dll and language pack for the laguages | 55 // Finds the most-preferred resource dll and language pack for the laguages |
| 56 // in |language_tags| | 56 // in |language_tags| |
| 57 // in |locales_path|. | 57 // in |locales_path|. |
| 58 // | 58 // |
| 59 // Returns true on success with a handle to the DLL that was loaded in | 59 // Returns true on success with a handle to the DLL that was loaded in |
| 60 // |dll_handle|, the data pack in |data_pack| and the locale language in | 60 // |dll_handle|, the data pack in |data_pack| and the locale language in |
| 61 // the |language| parameter. | 61 // the |language| parameter. |
| 62 static bool LoadLocalePack(const std::vector<std::wstring>& language_tags, | 62 static bool LoadLocalePack(const std::vector<std::wstring>& language_tags, |
| 63 const FilePath& locales_path, | 63 const base::FilePath& locales_path, |
| 64 HMODULE* dll_handle, | 64 HMODULE* dll_handle, |
| 65 ui::DataPack** data_pack, | 65 ui::DataPack** data_pack, |
| 66 std::wstring* language); | 66 std::wstring* language); |
| 67 | 67 |
| 68 // Returns the string resource identified by message_id from the currently | 68 // Returns the string resource identified by message_id from the currently |
| 69 // loaded locale dll. | 69 // loaded locale dll. |
| 70 std::wstring GetLocalizedResource(int message_id); | 70 std::wstring GetLocalizedResource(int message_id); |
| 71 | 71 |
| 72 friend struct DefaultSingletonTraits<SimpleResourceLoader>; | 72 friend struct DefaultSingletonTraits<SimpleResourceLoader>; |
| 73 | 73 |
| 74 FRIEND_TEST_ALL_PREFIXES(SimpleResourceLoaderTest, LoadLocaleDll); | 74 FRIEND_TEST_ALL_PREFIXES(SimpleResourceLoaderTest, LoadLocaleDll); |
| 75 | 75 |
| 76 std::wstring language_; | 76 std::wstring language_; |
| 77 ui::DataPack* data_pack_; | 77 ui::DataPack* data_pack_; |
| 78 | 78 |
| 79 HINSTANCE locale_dll_handle_; | 79 HINSTANCE locale_dll_handle_; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 #endif // CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ | 82 #endif // CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ |
| OLD | NEW |