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

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: 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698