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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/common/cast_resource_delegate.h ('k') | chromecast/shell/app/cast_main_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ce7af5150cf3e1d1cbcbc4aedb9721667bd46812
--- /dev/null
+++ b/chromecast/common/cast_resource_delegate.cc
@@ -0,0 +1,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
« no previous file with comments | « chromecast/common/cast_resource_delegate.h ('k') | chromecast/shell/app/cast_main_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698