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_ |
11 #define CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ | 11 #define CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ |
12 | 12 |
13 #include <windows.h> | 13 #include <windows.h> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/file_path.h" | 17 #include "base/file_path.h" |
18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
19 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
20 #include "ui/base/resource/data_pack.h" | |
20 | 21 |
21 class SimpleResourceLoader { | 22 class SimpleResourceLoader { |
22 public: | 23 public: |
23 | 24 |
24 static SimpleResourceLoader* GetInstance(); | 25 static SimpleResourceLoader* GetInstance(); |
25 | 26 |
26 // Returns the language tag for the active language. | 27 // Returns the language tag for the active language. |
27 static std::wstring GetLanguage(); | 28 static std::wstring GetLanguage(); |
28 | 29 |
29 // Helper method to return the string resource identified by message_id | 30 // Helper method to return the string resource identified by message_id |
(...skipping 11 matching lines...) Expand all Loading... | |
41 // Populates |locales_path| with the path to the "Locales" directory. | 42 // Populates |locales_path| with the path to the "Locales" directory. |
42 static void DetermineLocalesDirectory(FilePath* locales_path); | 43 static void DetermineLocalesDirectory(FilePath* locales_path); |
43 | 44 |
44 // Returns false if |language_tag| is malformed. | 45 // Returns false if |language_tag| is malformed. |
45 static bool IsValidLanguageTag(const std::wstring& language_tag); | 46 static bool IsValidLanguageTag(const std::wstring& language_tag); |
46 | 47 |
47 private: | 48 private: |
48 SimpleResourceLoader(); | 49 SimpleResourceLoader(); |
49 ~SimpleResourceLoader(); | 50 ~SimpleResourceLoader(); |
50 | 51 |
51 // Finds the most-preferred resource DLL for the laguages in |language_tags| | 52 // Finds the most-preferred resource dll and language pack for the laguages |
53 // in |language_tags| | |
52 // in |locales_path|. | 54 // in |locales_path|. |
53 // | 55 // |
54 // Returns true on success with a handle to the DLL that was loaded in | 56 // Returns true on success with a handle to the DLL that was loaded in |
55 // |dll_handle| and its path in |file_path|. | 57 // |dll_handle|, the data pack in data_pack and its path in |file_path|. |
56 static bool LoadLocaleDll(const std::vector<std::wstring>& language_tags, | 58 static bool LoadLocalePack(const std::vector<std::wstring>& language_tags, |
57 const FilePath& locales_path, | 59 const FilePath& locales_path, |
58 HMODULE* dll_handle, | 60 HMODULE* dll_handle, |
59 FilePath* file_path); | 61 ui::DataPack** data_pack, |
62 FilePath* file_path); | |
tony
2011/08/26 21:36:30
Nit: Maybe renamed file_path to pak_file_path?
ananta
2011/08/26 21:50:17
Replaced file_path with the language parameter as
| |
60 | 63 |
61 // Returns the string resource identified by message_id from the currently | 64 // Returns the string resource identified by message_id from the currently |
62 // loaded locale dll. | 65 // loaded locale dll. |
63 std::wstring GetLocalizedResource(int message_id); | 66 std::wstring GetLocalizedResource(int message_id); |
64 | 67 |
65 friend struct DefaultSingletonTraits<SimpleResourceLoader>; | 68 friend struct DefaultSingletonTraits<SimpleResourceLoader>; |
66 | 69 |
67 FRIEND_TEST_ALL_PREFIXES(SimpleResourceLoaderTest, LoadLocaleDll); | 70 FRIEND_TEST_ALL_PREFIXES(SimpleResourceLoaderTest, LoadLocaleDll); |
68 | 71 |
69 std::wstring language_; | 72 std::wstring language_; |
73 ui::DataPack* data_pack_; | |
tony
2011/08/26 21:36:30
Nit: You could probably make this a scoped_ptr. I
ananta
2011/08/26 21:50:17
Removed the include of the file here and replaced
| |
74 | |
70 HINSTANCE locale_dll_handle_; | 75 HINSTANCE locale_dll_handle_; |
71 }; | 76 }; |
72 | 77 |
73 #endif // CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ | 78 #endif // CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_ |
OLD | NEW |