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

Side by Side Diff: app/resource_bundle_win.cc

Issue 115420: Reland this change. Registers paths for the testing exe, too.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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
« no previous file with comments | « app/resource_bundle_linux.cc ('k') | chrome/app/chrome_dll_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "app/resource_bundle.h" 5 #include "app/resource_bundle.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 8
9 #include "app/app_paths.h"
9 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
10 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/path_service.h" 14 #include "base/path_service.h"
14 #include "base/resource_util.h" 15 #include "base/resource_util.h"
15 #include "base/string_piece.h" 16 #include "base/string_piece.h"
16 #include "base/win_util.h" 17 #include "base/win_util.h"
17 #include "chrome/common/chrome_paths.h"
18 18
19 namespace { 19 namespace {
20 20
21 // Returns the flags that should be passed to LoadLibraryEx. 21 // Returns the flags that should be passed to LoadLibraryEx.
22 DWORD GetDataDllLoadFlags() { 22 DWORD GetDataDllLoadFlags() {
23 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) 23 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA)
24 return LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE | LOAD_LIBRARY_AS_IMAGE_RESOURCE; 24 return LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE | LOAD_LIBRARY_AS_IMAGE_RESOURCE;
25 25
26 return DONT_RESOLVE_DLL_REFERENCES; 26 return DONT_RESOLVE_DLL_REFERENCES;
27 } 27 }
(...skipping 28 matching lines...) Expand all
56 56
57 // The dll should only have resources, not executable code. 57 // The dll should only have resources, not executable code.
58 locale_resources_data_ = LoadLibraryEx(locale_path.value().c_str(), NULL, 58 locale_resources_data_ = LoadLibraryEx(locale_path.value().c_str(), NULL,
59 GetDataDllLoadFlags()); 59 GetDataDllLoadFlags());
60 DCHECK(locale_resources_data_ != NULL) << 60 DCHECK(locale_resources_data_ != NULL) <<
61 "unable to load generated resources"; 61 "unable to load generated resources";
62 } 62 }
63 63
64 FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) { 64 FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) {
65 FilePath locale_path; 65 FilePath locale_path;
66 PathService::Get(chrome::DIR_LOCALES, &locale_path); 66 PathService::Get(app::DIR_LOCALES, &locale_path);
67 67
68 const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale); 68 const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale);
69 if (app_locale.empty()) 69 if (app_locale.empty())
70 return FilePath(); 70 return FilePath();
71 71
72 return locale_path.Append(app_locale + L".dll"); 72 return locale_path.Append(app_locale + L".dll");
73 } 73 }
74 74
75 void ResourceBundle::LoadThemeResources() { 75 void ResourceBundle::LoadThemeResources() {
76 DCHECK(NULL == theme_data_) << "theme dll already loaded"; 76 DCHECK(NULL == theme_data_) << "theme dll already loaded";
77 std::wstring theme_data_path; 77 std::wstring theme_data_path;
78 PathService::Get(chrome::DIR_THEMES, &theme_data_path); 78 PathService::Get(app::DIR_THEMES, &theme_data_path);
79 file_util::AppendToPath(&theme_data_path, L"default.dll"); 79 file_util::AppendToPath(&theme_data_path, L"default.dll");
80 80
81 // The dll should only have resources, not executable code. 81 // The dll should only have resources, not executable code.
82 theme_data_ = LoadLibraryEx(theme_data_path.c_str(), NULL, 82 theme_data_ = LoadLibraryEx(theme_data_path.c_str(), NULL,
83 GetDataDllLoadFlags()); 83 GetDataDllLoadFlags());
84 DCHECK(theme_data_ != NULL) << "unable to load " << theme_data_path; 84 DCHECK(theme_data_ != NULL) << "unable to load " << theme_data_path;
85 } 85 }
86 86
87 /* static */ 87 /* static */
88 bool ResourceBundle::LoadResourceBytes( 88 bool ResourceBundle::LoadResourceBytes(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 image = AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), 149 image = AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(),
150 message_id); 150 message_id);
151 if (!image) { 151 if (!image) {
152 NOTREACHED() << "unable to find resource: " << message_id; 152 NOTREACHED() << "unable to find resource: " << message_id;
153 return std::wstring(); 153 return std::wstring();
154 } 154 }
155 } 155 }
156 // Copy into a string16 and return. 156 // Copy into a string16 and return.
157 return string16(image->achString, image->nLength); 157 return string16(image->achString, image->nLength);
158 } 158 }
OLDNEW
« no previous file with comments | « app/resource_bundle_linux.cc ('k') | chrome/app/chrome_dll_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698