Chromium Code Reviews| Index: chromecast/common/cast_resource_delegate.cc |
| diff --git a/chromecast/common/cast_resource_delegate.cc b/chromecast/common/cast_resource_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fab88d6f8ec8a487ab0578829ceb1a0ba53043e1 |
| --- /dev/null |
| +++ b/chromecast/common/cast_resource_delegate.cc |
| @@ -0,0 +1,105 @@ |
| +// 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 { |
| + |
| +// static |
| +CastResourceDelegate* CastResourceDelegate::g_instance_ = NULL; |
| + |
| +// static |
| +CastResourceDelegate* CastResourceDelegate::GetInstance() { |
| + return g_instance_; |
|
byungchul
2014/08/14 20:34:11
DCHECK(g_instance)?
gunsch
2014/08/15 00:04:27
Done.
|
| +} |
| + |
| +CastResourceDelegate::CastResourceDelegate() |
| + : Delegate() { |
|
byungchul
2014/08/14 20:34:11
Not necessary
gunsch
2014/08/15 00:04:27
Done.
|
| + DCHECK(!g_instance_) << "Cannot initialize resource bundle delegate twice."; |
| + g_instance_ = this; |
| +} |
| + |
| +CastResourceDelegate::~CastResourceDelegate() { |
| + g_instance_ = NULL; |
|
byungchul
2014/08/14 20:34:11
DCHECK_EQ(this, g_instance_)
gunsch
2014/08/15 00:04:27
Done.
|
| +} |
| + |
| +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 locale_file; |
|
byungchul
2014/08/14 20:34:11
Moce this to line 45.
gunsch
2014/08/15 00:04:27
Done.
|
| + base::FilePath product_dir; |
| + if (!PathService::Get(base::DIR_MODULE, &product_dir)) { |
| + NOTREACHED(); |
| + } |
| + locale_file = product_dir. |
| + Append(FILE_PATH_LITERAL("chromecast_locales")). |
| + Append(FILE_PATH_LITERAL(locale)). |
| + AddExtension(FILE_PATH_LITERAL("pak")); |
| + return locale_file; |
| +}; |
| + |
| +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 |