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

Side by Side Diff: chrome_frame/simple_resource_loader.cc

Issue 7744017: Updated *.pak file format to support both UTF8 and UTF16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified mac-specific parts of the code. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/tools/mac_helpers/infoplist_strings_util.mm ('k') | tools/grit/grit/format/data_pack.py » ('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) 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
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 UTF16. 244 // Data pack encodes strings as either UTF8 or UTF16.
245 DCHECK_EQ(data.length() % 2, 0U); 245 string16 msg;
246 string16 msg(reinterpret_cast<const char16*>(data.data()), 246 if (data_pack_->GetTextEncodingType() == ui::DataPack::UTF16) {
247 data.length() / 2); 247 msg = string16(reinterpret_cast<const char16*>(data.data()),
248 data.length() / 2);
249 } else if (data_pack_->GetTextEncodingType() == ui::DataPack::UTF8) {
250 msg = UTF8ToUTF16(data);
251 }
248 return msg; 252 return msg;
249 } 253 }
250 254
251 // static 255 // static
252 std::wstring SimpleResourceLoader::GetLanguage() { 256 std::wstring SimpleResourceLoader::GetLanguage() {
253 return SimpleResourceLoader::GetInstance()->language_; 257 return SimpleResourceLoader::GetInstance()->language_;
254 } 258 }
255 259
256 // static 260 // static
257 std::wstring SimpleResourceLoader::Get(int message_id) { 261 std::wstring SimpleResourceLoader::Get(int message_id) {
258 SimpleResourceLoader* loader = SimpleResourceLoader::GetInstance(); 262 SimpleResourceLoader* loader = SimpleResourceLoader::GetInstance();
259 return loader->GetLocalizedResource(message_id); 263 return loader->GetLocalizedResource(message_id);
260 } 264 }
261 265
262 HMODULE SimpleResourceLoader::GetResourceModuleHandle() { 266 HMODULE SimpleResourceLoader::GetResourceModuleHandle() {
263 return locale_dll_handle_; 267 return locale_dll_handle_;
264 } 268 }
OLDNEW
« no previous file with comments | « chrome/tools/mac_helpers/infoplist_strings_util.mm ('k') | tools/grit/grit/format/data_pack.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698