summaryrefslogtreecommitdiffstats
path: root/chrome_frame/simple_resource_loader.h
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 03:09:05 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 03:09:05 +0000
commit36a26ed0faf7fb24d1991136cb5d6969f8042055 (patch)
treef8651c491b8a25bc7bd5b56f85f099c3b3f651dd /chrome_frame/simple_resource_loader.h
parent6502d03df070469ccc6f634f4c72d4ceda9a3bb3 (diff)
downloadchromium_src-36a26ed0faf7fb24d1991136cb5d6969f8042055.zip
chromium_src-36a26ed0faf7fb24d1991136cb5d6969f8042055.tar.gz
chromium_src-36a26ed0faf7fb24d1991136cb5d6969f8042055.tar.bz2
Add a simple resource loader to Chrome Frame that is capable of finding, loading and extracting resources from the Chrome locale DLLs.
Add the Chrome Frame resource strings to the Chrome .grds so they get built directly into the Chrome locale dlls. There is one remaining todo here, which is to load the dialog template into a grd + rc somewhere (probably in generated_resources.grd) and then get CF to load dialog templates from a different module. Will do that in another patch. BUG=24305 TEST=Chrome Frame when loaded on machines whose locales are not US English will display strings appropriate to those locales. Review URL: http://codereview.chromium.org/1240001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/simple_resource_loader.h')
-rw-r--r--chrome_frame/simple_resource_loader.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/chrome_frame/simple_resource_loader.h b/chrome_frame/simple_resource_loader.h
new file mode 100644
index 0000000..2ec9860
--- /dev/null
+++ b/chrome_frame/simple_resource_loader.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// This class implements a simplified and much stripped down version of
+// Chrome's app/resource_bundle machinery. It notably avoids unwanted
+// dependencies on things like Skia.
+//
+
+#ifndef CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_
+#define CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_
+
+#include <windows.h>
+#include <string>
+
+#include "base/singleton.h"
+
+class SimpleResourceLoader {
+ public:
+
+ static SimpleResourceLoader* instance() {
+ return Singleton<SimpleResourceLoader>::get();
+ }
+
+ // Helper method to return the string resource identified by message_id
+ // from the currently loaded locale dll.
+ static std::wstring Get(int message_id);
+
+ private:
+ SimpleResourceLoader();
+
+ // Retrieves the system locale in the <language>-<region> format using ICU.
+ std::wstring GetSystemLocale();
+
+ // Uses |locale| to build the resource DLL name and then looks for the named
+ // DLL in known locales paths. If it doesn't find it, it falls back to
+ // looking for an en-US.dll.
+ //
+ // Returns true if a locale DLL can be found, false otherwise.
+ bool GetLocaleFilePath(const std::wstring& locale, std::wstring* file_path);
+
+ // Loads the locale dll at the given path. Returns a handle to the DLL or
+ // NULL on failure.
+ HINSTANCE LoadLocaleDll(const std::wstring& dll_path);
+
+ // Returns the string resource identified by message_id from the currently
+ // loaded locale dll.
+ std::wstring GetLocalizedResource(int message_id);
+
+ friend struct DefaultSingletonTraits<SimpleResourceLoader>;
+
+ static HINSTANCE locale_dll_handle_;
+};
+
+#endif // CHROME_FRAME_SIMPLE_RESOURCE_LOADER_H_