| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "base/data_pack.h" | 11 #include "base/data_pack.h" |
| 12 #include "base/debug_util.h" | 12 #include "base/debug_util.h" |
| 13 #include "base/debug/stack_trace.h" |
| 13 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 14 #include "base/lock.h" | 15 #include "base/lock.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 17 #include "base/resource_util.h" | 18 #include "base/resource_util.h" |
| 18 #include "base/stl_util-inl.h" | 19 #include "base/stl_util-inl.h" |
| 19 #include "base/string_piece.h" | 20 #include "base/string_piece.h" |
| 20 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 21 | 22 |
| 22 #include "gfx/font.h" | 23 #include "gfx/font.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Loads and returns a cursor from the current module. | 133 // Loads and returns a cursor from the current module. |
| 133 HCURSOR ResourceBundle::LoadCursor(int cursor_id) { | 134 HCURSOR ResourceBundle::LoadCursor(int cursor_id) { |
| 134 return ::LoadCursor(_AtlBaseModule.GetModuleInstance(), | 135 return ::LoadCursor(_AtlBaseModule.GetModuleInstance(), |
| 135 MAKEINTRESOURCE(cursor_id)); | 136 MAKEINTRESOURCE(cursor_id)); |
| 136 } | 137 } |
| 137 | 138 |
| 138 string16 ResourceBundle::GetLocalizedString(int message_id) { | 139 string16 ResourceBundle::GetLocalizedString(int message_id) { |
| 139 // If for some reason we were unable to load a resource dll, return an empty | 140 // If for some reason we were unable to load a resource dll, return an empty |
| 140 // string (better than crashing). | 141 // string (better than crashing). |
| 141 if (!locale_resources_data_) { | 142 if (!locale_resources_data_) { |
| 142 StackTrace().PrintBacktrace(); // See http://crbug.com/21925. | 143 base::debug::StackTrace().PrintBacktrace(); // See http://crbug.com/21925. |
| 143 LOG(WARNING) << "locale resources are not loaded"; | 144 LOG(WARNING) << "locale resources are not loaded"; |
| 144 return string16(); | 145 return string16(); |
| 145 } | 146 } |
| 146 | 147 |
| 147 DCHECK(IS_INTRESOURCE(message_id)); | 148 DCHECK(IS_INTRESOURCE(message_id)); |
| 148 | 149 |
| 149 // Get a reference directly to the string resource. | 150 // Get a reference directly to the string resource. |
| 150 HINSTANCE hinstance = locale_resources_data_; | 151 HINSTANCE hinstance = locale_resources_data_; |
| 151 const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(hinstance, | 152 const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(hinstance, |
| 152 message_id); | 153 message_id); |
| 153 if (!image) { | 154 if (!image) { |
| 154 // Fall back on the current module (shouldn't be any strings here except | 155 // Fall back on the current module (shouldn't be any strings here except |
| 155 // in unittests). | 156 // in unittests). |
| 156 image = AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), | 157 image = AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), |
| 157 message_id); | 158 message_id); |
| 158 if (!image) { | 159 if (!image) { |
| 159 StackTrace().PrintBacktrace(); // See http://crbug.com/21925. | 160 // See http://crbug.com/21925. |
| 161 base::debug::StackTrace().PrintBacktrace(); |
| 160 NOTREACHED() << "unable to find resource: " << message_id; | 162 NOTREACHED() << "unable to find resource: " << message_id; |
| 161 return std::wstring(); | 163 return std::wstring(); |
| 162 } | 164 } |
| 163 } | 165 } |
| 164 // Copy into a string16 and return. | 166 // Copy into a string16 and return. |
| 165 return string16(image->achString, image->nLength); | 167 return string16(image->achString, image->nLength); |
| 166 } | 168 } |
| OLD | NEW |