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

Side by Side Diff: app/resource_bundle_win.cc

Issue 196132: Print a stacktrace when we can't find a string resource (on Windows). (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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/app_paths.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "base/debug_util.h"
12 #include "base/file_util.h" 13 #include "base/file_util.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/resource_util.h" 16 #include "base/resource_util.h"
16 #include "base/string_piece.h" 17 #include "base/string_piece.h"
17 #include "base/win_util.h" 18 #include "base/win_util.h"
18 19
19 namespace { 20 namespace {
20 21
21 // Returns the flags that should be passed to LoadLibraryEx. 22 // Returns the flags that should be passed to LoadLibraryEx.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Loads and returns a cursor from the current module. 127 // Loads and returns a cursor from the current module.
127 HCURSOR ResourceBundle::LoadCursor(int cursor_id) { 128 HCURSOR ResourceBundle::LoadCursor(int cursor_id) {
128 return ::LoadCursor(_AtlBaseModule.GetModuleInstance(), 129 return ::LoadCursor(_AtlBaseModule.GetModuleInstance(),
129 MAKEINTRESOURCE(cursor_id)); 130 MAKEINTRESOURCE(cursor_id));
130 } 131 }
131 132
132 string16 ResourceBundle::GetLocalizedString(int message_id) { 133 string16 ResourceBundle::GetLocalizedString(int message_id) {
133 // If for some reason we were unable to load a resource dll, return an empty 134 // If for some reason we were unable to load a resource dll, return an empty
134 // string (better than crashing). 135 // string (better than crashing).
135 if (!locale_resources_data_) { 136 if (!locale_resources_data_) {
137 StackTrace().PrintBacktrace(); // See http://crbug.com/21925.
136 LOG(WARNING) << "locale resources are not loaded"; 138 LOG(WARNING) << "locale resources are not loaded";
137 return string16(); 139 return string16();
138 } 140 }
139 141
140 DCHECK(IS_INTRESOURCE(message_id)); 142 DCHECK(IS_INTRESOURCE(message_id));
141 143
142 // Get a reference directly to the string resource. 144 // Get a reference directly to the string resource.
143 HINSTANCE hinstance = locale_resources_data_; 145 HINSTANCE hinstance = locale_resources_data_;
144 const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(hinstance, 146 const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(hinstance,
145 message_id); 147 message_id);
146 if (!image) { 148 if (!image) {
147 // Fall back on the current module (shouldn't be any strings here except 149 // Fall back on the current module (shouldn't be any strings here except
148 // in unittests). 150 // in unittests).
149 image = AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), 151 image = AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(),
150 message_id); 152 message_id);
151 if (!image) { 153 if (!image) {
154 StackTrace().PrintBacktrace(); // See http://crbug.com/21925.
152 NOTREACHED() << "unable to find resource: " << message_id; 155 NOTREACHED() << "unable to find resource: " << message_id;
153 return std::wstring(); 156 return std::wstring();
154 } 157 }
155 } 158 }
156 // Copy into a string16 and return. 159 // Copy into a string16 and return.
157 return string16(image->achString, image->nLength); 160 return string16(image->achString, image->nLength);
158 } 161 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698