Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / chromecast / common / cast_resource_delegate.h
blob3e4cac2e4cb4069a7a78bdc33d3b030a58cddf82
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 #ifndef CHROMECAST_COMMON_CAST_RESOURCE_DELEGATE_H_
6 #define CHROMECAST_COMMON_CAST_RESOURCE_DELEGATE_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/ref_counted_memory.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/base/resource/resource_bundle.h"
15 namespace base {
16 class FilePath;
19 namespace gfx {
20 class Image;
23 namespace chromecast {
25 // A singleton resource bundle delegate. Primary purpose is to indicate the
26 // correct locale pack file to load.
27 class CastResourceDelegate : public ui::ResourceBundle::Delegate {
28 public:
29 // Returns the singleton of delegate. It doesn't create an instance.
30 static CastResourceDelegate* GetInstance();
32 CastResourceDelegate();
33 ~CastResourceDelegate() override;
35 // ui:ResourceBundle::Delegate implementation:
36 base::FilePath GetPathForResourcePack(
37 const base::FilePath& pack_path,
38 ui::ScaleFactor scale_factor) override;
39 base::FilePath GetPathForLocalePack(
40 const base::FilePath& pack_path,
41 const std::string& locale) override;
42 gfx::Image GetImageNamed(int resource_id) override;
43 gfx::Image GetNativeImageNamed(
44 int resource_id,
45 ui::ResourceBundle::ImageRTL rtl) override;
46 base::RefCountedStaticMemory* LoadDataResourceBytes(
47 int resource_id,
48 ui::ScaleFactor scale_factor) override;
49 bool GetRawDataResource(int resource_id,
50 ui::ScaleFactor scale_factor,
51 base::StringPiece* value) override;
52 bool GetLocalizedString(int message_id, base::string16* value) override;
53 scoped_ptr<gfx::Font> GetFont(ui::ResourceBundle::FontStyle style) override;
55 // Adds/removes/clears extra localized strings.
56 void AddExtraLocalizedString(int resource_id,
57 const base::string16& localized);
58 void RemoveExtraLocalizedString(int resource_id);
59 void ClearAllExtraLocalizedStrings();
61 private:
62 typedef base::hash_map<int, base::string16> ExtraLocaledStringMap;
64 ExtraLocaledStringMap extra_localized_strings_;
66 DISALLOW_COPY_AND_ASSIGN(CastResourceDelegate);
69 } // namespace chromecast
71 #endif // CHROMECAST_COMMON_CAST_RESOURCE_DELEGATE_H_