1 // Copyright (c) 2010 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.
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.
10 #ifndef CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_
11 #define CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_
16 #include "base/singleton.h"
18 class SimpleResourceLoader
{
21 static SimpleResourceLoader
* instance() {
22 return Singleton
<SimpleResourceLoader
>::get();
25 // Helper method to return the string resource identified by message_id
26 // from the currently loaded locale dll.
27 static std::wstring
Get(int message_id
);
29 // Retrieves the HINSTANCE of the loaded module handle. May be NULL if a
30 // resource DLL could not be loaded.
31 HINSTANCE
GetResourceModuleHandle();
34 SimpleResourceLoader();
36 // Retrieves the system locale in the <language>-<region> format using ICU.
37 std::wstring
GetSystemLocale();
39 // Uses |locale| to build the resource DLL name and then looks for the named
40 // DLL in known locales paths. If it doesn't find it, it falls back to
41 // looking for an en-US.dll.
43 // Returns true if a locale DLL can be found, false otherwise.
44 bool GetLocaleFilePath(const std::wstring
& locale
, std::wstring
* file_path
);
46 // Loads the locale dll at the given path. Returns a handle to the DLL or
48 HINSTANCE
LoadLocaleDll(const std::wstring
& dll_path
);
50 // Returns the string resource identified by message_id from the currently
52 std::wstring
GetLocalizedResource(int message_id
);
54 friend struct DefaultSingletonTraits
<SimpleResourceLoader
>;
56 static HINSTANCE locale_dll_handle_
;
59 #endif // CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_