Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome_frame/simple_resource_loader.h

Issue 126143005: Remove Chrome Frame code and resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to r244038 Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // This class implements a simplified and much stripped down version of
6 // Chrome's app/resource_bundle machinery. It notably avoids unwanted
7 // dependencies on things like Skia.
8 //
9
10 #ifndef CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_
11 #define CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_
12
13 #include <windows.h>
14 #include <string>
15 #include <vector>
16
17 #include "base/files/file_path.h"
18 #include "base/gtest_prod_util.h"
19 #include "base/memory/singleton.h"
20
21 namespace ui {
22 class DataPack;
23 } // namespace ui
24
25 class SimpleResourceLoader {
26 public:
27
28 static SimpleResourceLoader* GetInstance();
29
30 // Returns the language tag for the active language.
31 static std::wstring GetLanguage();
32
33 // Helper method to return the string resource identified by message_id
34 // from the currently loaded locale dll.
35 static std::wstring Get(int message_id);
36
37 // Retrieves the HINSTANCE of the loaded module handle. May be NULL if a
38 // resource DLL could not be loaded.
39 HMODULE GetResourceModuleHandle();
40
41 // Retrieves the preferred languages for the current thread, adding them to
42 // |language_tags|.
43 static void GetPreferredLanguages(std::vector<std::wstring>* language_tags);
44
45 // Populates |locales_path| with the path to the "Locales" directory.
46 static void DetermineLocalesDirectory(base::FilePath* locales_path);
47
48 // Returns false if |language_tag| is malformed.
49 static bool IsValidLanguageTag(const std::wstring& language_tag);
50
51 private:
52 SimpleResourceLoader();
53 ~SimpleResourceLoader();
54
55 // Finds the most-preferred resource dll and language pack for the laguages
56 // in |language_tags|
57 // in |locales_path|.
58 //
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
61 // the |language| parameter.
62 static bool LoadLocalePack(const std::vector<std::wstring>& language_tags,
63 const base::FilePath& locales_path,
64 HMODULE* dll_handle,
65 ui::DataPack** data_pack,
66 std::wstring* language);
67
68 // Returns the string resource identified by message_id from the currently
69 // loaded locale dll.
70 std::wstring GetLocalizedResource(int message_id);
71
72 friend struct DefaultSingletonTraits<SimpleResourceLoader>;
73
74 FRIEND_TEST_ALL_PREFIXES(SimpleResourceLoaderTest, LoadLocaleDll);
75
76 std::wstring language_;
77 ui::DataPack* data_pack_;
78
79 HINSTANCE locale_dll_handle_;
80 };
81
82 #endif // CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_
OLDNEW
« no previous file with comments | « chrome_frame/scoped_initialization_manager_unittest.cc ('k') | chrome_frame/simple_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698