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

Unified Diff: chromecast/common/cast_resource_delegate.h

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.h
diff --git a/chromecast/common/cast_resource_delegate.h b/chromecast/common/cast_resource_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..131726a099a764de6565e66b5affd2e6d0e9bff2
--- /dev/null
+++ b/chromecast/common/cast_resource_delegate.h
@@ -0,0 +1,76 @@
+// 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.
+
+#ifndef CHROMECAST_COMMON_CAST_RESOURCE_DELEGATE_H_
+#define CHROMECAST_COMMON_CAST_RESOURCE_DELEGATE_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/base/resource/resource_bundle.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace gfx {
+class Image;
+}
+
+namespace chromecast {
+
+// A singleton resource bundle delegate. Primary purpose is to indicate the
+// correct locale pack file to load.
+class CastResourceDelegate : public ui::ResourceBundle::Delegate {
+ public:
+ // Returns the singleton of delegate. It doesn't create an instance.
+ static CastResourceDelegate* GetInstance();
+
+ CastResourceDelegate();
+ virtual ~CastResourceDelegate();
+
+ // ui:ResourceBundle::Delegate implementation:
+ virtual base::FilePath GetPathForResourcePack(
+ const base::FilePath& pack_path,
+ ui::ScaleFactor scale_factor) OVERRIDE;
+ virtual base::FilePath GetPathForLocalePack(
+ const base::FilePath& pack_path,
+ const std::string& locale) OVERRIDE;
+ virtual gfx::Image GetImageNamed(int resource_id) OVERRIDE;
+ virtual gfx::Image GetNativeImageNamed(
+ int resource_id,
+ ui::ResourceBundle::ImageRTL rtl) OVERRIDE;
+ virtual base::RefCountedStaticMemory* LoadDataResourceBytes(
+ int resource_id,
+ ui::ScaleFactor scale_factor) OVERRIDE;
+ virtual bool GetRawDataResource(int resource_id,
+ ui::ScaleFactor scale_factor,
+ base::StringPiece* value) OVERRIDE;
+ virtual bool GetLocalizedString(int message_id,
+ base::string16* value) OVERRIDE;
+ virtual scoped_ptr<gfx::Font> GetFont(
+ ui::ResourceBundle::FontStyle style) OVERRIDE;
+
+ // Adds/removes/clears extra localized strings.
+ void AddExtraLocalizedString(int resource_id,
+ const base::string16& localized);
+ void RemoveExtraLocalizedString(int resource_id);
+ void ClearAllExtraLocalizedStrings();
+
+ private:
+ typedef base::hash_map<int, base::string16> ExtraLocaledStringMap;
+
+ // Sigleton instance.
+ static CastResourceDelegate* g_instance_;
lcwu1 2014/08/14 22:38:46 Instead of exposing g_instance_ here as a static m
gunsch 2014/08/15 00:04:27 Done.
+
+ ExtraLocaledStringMap extra_localized_strings_;
+
+ DISALLOW_COPY_AND_ASSIGN(CastResourceDelegate);
+};
+
+} // namespace chromecast
+
+#endif // CHROMECAST_COMMON_CAST_RESOURCE_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698