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