| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome_frame/simple_resource_loader.h" | 5 #include "chrome_frame/simple_resource_loader.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 234 } |
| 235 | 235 |
| 236 DCHECK(IS_INTRESOURCE(message_id)); | 236 DCHECK(IS_INTRESOURCE(message_id)); |
| 237 | 237 |
| 238 base::StringPiece data; | 238 base::StringPiece data; |
| 239 if (!data_pack_->GetStringPiece(message_id, &data)) { | 239 if (!data_pack_->GetStringPiece(message_id, &data)) { |
| 240 DLOG(ERROR) << "Unable to find string for resource id:" << message_id; | 240 DLOG(ERROR) << "Unable to find string for resource id:" << message_id; |
| 241 return std::wstring(); | 241 return std::wstring(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Data pack encodes strings as either UTF8 or UTF16. | 244 // Data pack encodes strings as UTF16. |
| 245 string16 msg; | 245 DCHECK_EQ(data.length() % 2, 0U); |
| 246 if (data_pack_->GetTextEncodingType() == ui::DataPack::UTF16) { | 246 string16 msg(reinterpret_cast<const char16*>(data.data()), |
| 247 msg = string16(reinterpret_cast<const char16*>(data.data()), | 247 data.length() / 2); |
| 248 data.length() / 2); | |
| 249 } else if (data_pack_->GetTextEncodingType() == ui::DataPack::UTF8) { | |
| 250 msg = UTF8ToUTF16(data); | |
| 251 } | |
| 252 return msg; | 248 return msg; |
| 253 } | 249 } |
| 254 | 250 |
| 255 // static | 251 // static |
| 256 std::wstring SimpleResourceLoader::GetLanguage() { | 252 std::wstring SimpleResourceLoader::GetLanguage() { |
| 257 return SimpleResourceLoader::GetInstance()->language_; | 253 return SimpleResourceLoader::GetInstance()->language_; |
| 258 } | 254 } |
| 259 | 255 |
| 260 // static | 256 // static |
| 261 std::wstring SimpleResourceLoader::Get(int message_id) { | 257 std::wstring SimpleResourceLoader::Get(int message_id) { |
| 262 SimpleResourceLoader* loader = SimpleResourceLoader::GetInstance(); | 258 SimpleResourceLoader* loader = SimpleResourceLoader::GetInstance(); |
| 263 return loader->GetLocalizedResource(message_id); | 259 return loader->GetLocalizedResource(message_id); |
| 264 } | 260 } |
| 265 | 261 |
| 266 HMODULE SimpleResourceLoader::GetResourceModuleHandle() { | 262 HMODULE SimpleResourceLoader::GetResourceModuleHandle() { |
| 267 return locale_dll_handle_; | 263 return locale_dll_handle_; |
| 268 } | 264 } |
| OLD | NEW |