Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromecast / common / cast_resource_delegate.cc
blobce7af5150cf3e1d1cbcbc4aedb9721667bd46812
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.
5 #include "chromecast/common/cast_resource_delegate.h"
7 #include "base/files/file_path.h"
8 #include "base/path_service.h"
9 #include "ui/gfx/image/image.h"
11 namespace chromecast {
13 namespace {
15 CastResourceDelegate* g_instance = NULL;
17 } // namespace
19 // static
20 CastResourceDelegate* CastResourceDelegate::GetInstance() {
21 DCHECK(g_instance);
22 return g_instance;
25 CastResourceDelegate::CastResourceDelegate() {
26 DCHECK(!g_instance) << "Cannot initialize resource bundle delegate twice.";
27 g_instance = this;
30 CastResourceDelegate::~CastResourceDelegate() {
31 DCHECK_EQ(g_instance, this);
32 g_instance = NULL;
35 base::FilePath CastResourceDelegate::GetPathForResourcePack(
36 const base::FilePath& pack_path,
37 ui::ScaleFactor scale_factor) {
38 return pack_path;
41 base::FilePath CastResourceDelegate::GetPathForLocalePack(
42 const base::FilePath& pack_path,
43 const std::string& locale) {
44 base::FilePath product_dir;
45 if (!PathService::Get(base::DIR_MODULE, &product_dir)) {
46 NOTREACHED();
48 return product_dir.
49 Append(FILE_PATH_LITERAL("chromecast_locales")).
50 Append(FILE_PATH_LITERAL(locale)).
51 AddExtension(FILE_PATH_LITERAL("pak"));
54 gfx::Image CastResourceDelegate::GetImageNamed(int resource_id) {
55 return gfx::Image();
58 gfx::Image CastResourceDelegate::GetNativeImageNamed(
59 int resource_id,
60 ui::ResourceBundle::ImageRTL rtl) {
61 return gfx::Image();
64 base::RefCountedStaticMemory* CastResourceDelegate::LoadDataResourceBytes(
65 int resource_id,
66 ui::ScaleFactor scale_factor) {
67 return NULL;
70 bool CastResourceDelegate::GetRawDataResource(int resource_id,
71 ui::ScaleFactor scale_factor,
72 base::StringPiece* value) {
73 return false;
76 bool CastResourceDelegate::GetLocalizedString(int message_id,
77 base::string16* value) {
78 ExtraLocaledStringMap::const_iterator it =
79 extra_localized_strings_.find(message_id);
80 if (it != extra_localized_strings_.end()) {
81 *value = it->second;
82 return true;
84 return false;
87 void CastResourceDelegate::AddExtraLocalizedString(
88 int resource_id,
89 const base::string16& localized) {
90 RemoveExtraLocalizedString(resource_id);
91 extra_localized_strings_.insert(std::make_pair(resource_id, localized));
94 void CastResourceDelegate::RemoveExtraLocalizedString(int resource_id) {
95 extra_localized_strings_.erase(resource_id);
98 void CastResourceDelegate::ClearAllExtraLocalizedStrings() {
99 extra_localized_strings_.clear();
102 scoped_ptr<gfx::Font> CastResourceDelegate::GetFont(
103 ui::ResourceBundle::FontStyle style) {
104 return scoped_ptr<gfx::Font>();
107 } // namespace chromecast