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

Side by Side Diff: chromecast/common/cast_resource_delegate.cc

Issue 467043002: Adds locale strings to Chromecast build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove build/gyp_chromium Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromecast/common/cast_resource_delegate.h"
6
7 #include "base/files/file_path.h"
8 #include "base/path_service.h"
9 #include "ui/gfx/image/image.h"
10
11 namespace chromecast {
12
13 // static
14 CastResourceDelegate* CastResourceDelegate::g_instance_ = NULL;
15
16 // static
17 CastResourceDelegate* CastResourceDelegate::GetInstance() {
18 return g_instance_;
byungchul 2014/08/14 20:34:11 DCHECK(g_instance)?
gunsch 2014/08/15 00:04:27 Done.
19 }
20
21 CastResourceDelegate::CastResourceDelegate()
22 : Delegate() {
byungchul 2014/08/14 20:34:11 Not necessary
gunsch 2014/08/15 00:04:27 Done.
23 DCHECK(!g_instance_) << "Cannot initialize resource bundle delegate twice.";
24 g_instance_ = this;
25 }
26
27 CastResourceDelegate::~CastResourceDelegate() {
28 g_instance_ = NULL;
byungchul 2014/08/14 20:34:11 DCHECK_EQ(this, g_instance_)
gunsch 2014/08/15 00:04:27 Done.
29 }
30
31 base::FilePath CastResourceDelegate::GetPathForResourcePack(
32 const base::FilePath& pack_path,
33 ui::ScaleFactor scale_factor) {
34 return pack_path;
35 };
36
37 base::FilePath CastResourceDelegate::GetPathForLocalePack(
38 const base::FilePath& pack_path,
39 const std::string& locale) {
40 base::FilePath locale_file;
byungchul 2014/08/14 20:34:11 Moce this to line 45.
gunsch 2014/08/15 00:04:27 Done.
41 base::FilePath product_dir;
42 if (!PathService::Get(base::DIR_MODULE, &product_dir)) {
43 NOTREACHED();
44 }
45 locale_file = product_dir.
46 Append(FILE_PATH_LITERAL("chromecast_locales")).
47 Append(FILE_PATH_LITERAL(locale)).
48 AddExtension(FILE_PATH_LITERAL("pak"));
49 return locale_file;
50 };
51
52 gfx::Image CastResourceDelegate::GetImageNamed(int resource_id) {
53 return gfx::Image();
54 };
55
56 gfx::Image CastResourceDelegate::GetNativeImageNamed(
57 int resource_id,
58 ui::ResourceBundle::ImageRTL rtl) {
59 return gfx::Image();
60 };
61
62 base::RefCountedStaticMemory* CastResourceDelegate::LoadDataResourceBytes(
63 int resource_id,
64 ui::ScaleFactor scale_factor) {
65 return NULL;
66 };
67
68 bool CastResourceDelegate::GetRawDataResource(int resource_id,
69 ui::ScaleFactor scale_factor,
70 base::StringPiece* value) {
71 return false;
72 };
73
74 bool CastResourceDelegate::GetLocalizedString(int message_id,
75 base::string16* value) {
76 ExtraLocaledStringMap::const_iterator it =
77 extra_localized_strings_.find(message_id);
78 if (it != extra_localized_strings_.end()) {
79 *value = it->second;
80 return true;
81 }
82 return false;
83 };
84
85 void CastResourceDelegate::AddExtraLocalizedString(
86 int resource_id,
87 const base::string16& localized) {
88 RemoveExtraLocalizedString(resource_id);
89 extra_localized_strings_.insert(std::make_pair(resource_id, localized));
90 }
91
92 void CastResourceDelegate::RemoveExtraLocalizedString(int resource_id) {
93 extra_localized_strings_.erase(resource_id);
94 }
95
96 void CastResourceDelegate::ClearAllExtraLocalizedStrings() {
97 extra_localized_strings_.clear();
98 }
99
100 scoped_ptr<gfx::Font> CastResourceDelegate::GetFont(
101 ui::ResourceBundle::FontStyle style) {
102 return scoped_ptr<gfx::Font>();
103 };
104
105 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698