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

Side by Side Diff: ui/base/resource/resource_bundle.cc

Issue 2311223003: [chromecast] Add ResourceBundle::LoadLocalizedResourceBytes(). (Closed)
Patch Set: [chromecast] Add ResourceBundle::LoadLocalizedResourceBytes() to to get binary data from locale_res… Created 4 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 | « ui/base/resource/resource_bundle.h ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 base::string16 msg; 549 base::string16 msg;
550 if (encoding == ResourceHandle::UTF16) { 550 if (encoding == ResourceHandle::UTF16) {
551 msg = base::string16(reinterpret_cast<const base::char16*>(data.data()), 551 msg = base::string16(reinterpret_cast<const base::char16*>(data.data()),
552 data.length() / 2); 552 data.length() / 2);
553 } else if (encoding == ResourceHandle::UTF8) { 553 } else if (encoding == ResourceHandle::UTF8) {
554 msg = base::UTF8ToUTF16(data); 554 msg = base::UTF8ToUTF16(data);
555 } 555 }
556 return msg; 556 return msg;
557 } 557 }
558 558
559 base::RefCountedMemory* ResourceBundle::LoadLocalizedResourceBytes(
560 int resource_id) {
561 {
562 base::AutoLock lock_scope(*locale_resources_data_lock_);
563 base::StringPiece data;
564 if (locale_resources_data_.get() &&
565 locale_resources_data_->GetStringPiece(
566 static_cast<uint16_t>(resource_id), &data) &&
567 !data.empty()) {
568 return new base::RefCountedStaticMemory(data.data(), data.length());
569 }
570 }
571 // Release lock_scope and fall back to main data pack.
572 return LoadDataResourceBytes(resource_id);
573 }
574
559 const gfx::FontList& ResourceBundle::GetFontListWithDelta( 575 const gfx::FontList& ResourceBundle::GetFontListWithDelta(
560 int size_delta, 576 int size_delta,
561 gfx::Font::FontStyle style, 577 gfx::Font::FontStyle style,
562 gfx::Font::Weight weight) { 578 gfx::Font::Weight weight) {
563 base::AutoLock lock_scope(*images_and_fonts_lock_); 579 base::AutoLock lock_scope(*images_and_fonts_lock_);
564 580
565 const FontKey styled_key(size_delta, style, weight); 581 const FontKey styled_key(size_delta, style, weight);
566 582
567 auto found = font_cache_.find(styled_key); 583 auto found = font_cache_.find(styled_key);
568 if (found != font_cache_.end()) 584 if (found != font_cache_.end())
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 // static 901 // static
886 bool ResourceBundle::DecodePNG(const unsigned char* buf, 902 bool ResourceBundle::DecodePNG(const unsigned char* buf,
887 size_t size, 903 size_t size,
888 SkBitmap* bitmap, 904 SkBitmap* bitmap,
889 bool* fell_back_to_1x) { 905 bool* fell_back_to_1x) {
890 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 906 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
891 return gfx::PNGCodec::Decode(buf, size, bitmap); 907 return gfx::PNGCodec::Decode(buf, size, bitmap);
892 } 908 }
893 909
894 } // namespace ui 910 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698