OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 5 #ifndef CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 static void GetThemeableImageIDRs(std::set<int>* result); | 72 static void GetThemeableImageIDRs(std::set<int>* result); |
73 | 73 |
74 // Builds a data pack on disk at |path| for future quick loading by | 74 // Builds a data pack on disk at |path| for future quick loading by |
75 // BuildFromDataPack(). Often (but not always) called from the file thread; | 75 // BuildFromDataPack(). Often (but not always) called from the file thread; |
76 // implementation should be threadsafe because neither thread will write to | 76 // implementation should be threadsafe because neither thread will write to |
77 // |image_memory_| and the worker thread will keep a reference to prevent | 77 // |image_memory_| and the worker thread will keep a reference to prevent |
78 // destruction. | 78 // destruction. |
79 bool WriteToDisk(const base::FilePath& path) const; | 79 bool WriteToDisk(const base::FilePath& path) const; |
80 | 80 |
81 // Overridden from CustomThemeSupplier: | 81 // Overridden from CustomThemeSupplier: |
82 virtual bool GetTint(int id, color_utils::HSL* hsl) const override; | 82 bool GetTint(int id, color_utils::HSL* hsl) const override; |
83 virtual bool GetColor(int id, SkColor* color) const override; | 83 bool GetColor(int id, SkColor* color) const override; |
84 virtual bool GetDisplayProperty(int id, int* result) const override; | 84 bool GetDisplayProperty(int id, int* result) const override; |
85 virtual gfx::Image GetImageNamed(int id) override; | 85 gfx::Image GetImageNamed(int id) override; |
86 virtual base::RefCountedMemory* GetRawData( | 86 base::RefCountedMemory* GetRawData(int id, ui::ScaleFactor scale_factor) |
87 int id, ui::ScaleFactor scale_factor) const override; | 87 const override; |
88 virtual bool HasCustomImage(int id) const override; | 88 bool HasCustomImage(int id) const override; |
89 | 89 |
90 private: | 90 private: |
91 friend class BrowserThemePackTest; | 91 friend class BrowserThemePackTest; |
92 | 92 |
93 // Cached images. | 93 // Cached images. |
94 typedef std::map<int, gfx::Image> ImageCache; | 94 typedef std::map<int, gfx::Image> ImageCache; |
95 | 95 |
96 // The raw PNG memory associated with a certain id. | 96 // The raw PNG memory associated with a certain id. |
97 typedef std::map<int, scoped_refptr<base::RefCountedMemory> > RawImages; | 97 typedef std::map<int, scoped_refptr<base::RefCountedMemory> > RawImages; |
98 | 98 |
99 // The type passed to ui::DataPack::WritePack. | 99 // The type passed to ui::DataPack::WritePack. |
100 typedef std::map<uint16, base::StringPiece> RawDataForWriting; | 100 typedef std::map<uint16, base::StringPiece> RawDataForWriting; |
101 | 101 |
102 // Maps scale factors (enum values) to file paths. | 102 // Maps scale factors (enum values) to file paths. |
103 typedef std::map<ui::ScaleFactor, base::FilePath> ScaleFactorToFileMap; | 103 typedef std::map<ui::ScaleFactor, base::FilePath> ScaleFactorToFileMap; |
104 | 104 |
105 // Maps image ids to maps of scale factors to file paths. | 105 // Maps image ids to maps of scale factors to file paths. |
106 typedef std::map<int, ScaleFactorToFileMap> FilePathMap; | 106 typedef std::map<int, ScaleFactorToFileMap> FilePathMap; |
107 | 107 |
108 // Default. Everything is empty. | 108 // Default. Everything is empty. |
109 BrowserThemePack(); | 109 BrowserThemePack(); |
110 | 110 |
111 virtual ~BrowserThemePack(); | 111 ~BrowserThemePack() override; |
112 | 112 |
113 // Builds a header ready to write to disk. | 113 // Builds a header ready to write to disk. |
114 void BuildHeader(const extensions::Extension* extension); | 114 void BuildHeader(const extensions::Extension* extension); |
115 | 115 |
116 // Transforms the JSON tint values into their final versions in the |tints_| | 116 // Transforms the JSON tint values into their final versions in the |tints_| |
117 // array. | 117 // array. |
118 void BuildTintsFromJSON(const base::DictionaryValue* tints_value); | 118 void BuildTintsFromJSON(const base::DictionaryValue* tints_value); |
119 | 119 |
120 // Transforms the JSON color values into their final versions in the | 120 // Transforms the JSON color values into their final versions in the |
121 // |colors_| array and also fills in unspecified colors based on tint values. | 121 // |colors_| array and also fills in unspecified colors based on tint values. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // Cache of images created in BuildFromExtension(). Once the theme pack is | 268 // Cache of images created in BuildFromExtension(). Once the theme pack is |
269 // created, this cache should only be accessed on the file thread. There | 269 // created, this cache should only be accessed on the file thread. There |
270 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| | 270 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| |
271 // or vice versa. | 271 // or vice versa. |
272 ImageCache images_on_file_thread_; | 272 ImageCache images_on_file_thread_; |
273 | 273 |
274 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); | 274 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); |
275 }; | 275 }; |
276 | 276 |
277 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 277 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
OLD | NEW |