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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.h

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/sequenced_task_runner_helpers.h" 15 #include "base/sequenced_task_runner_helpers.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "ui/base/layout.h" 18 #include "ui/base/layout.h"
19 #include "ui/gfx/color_utils.h" 19 #include "ui/gfx/color_utils.h"
20 20
21 class FilePath;
22
23 namespace base { 21 namespace base {
24 class DictionaryValue; 22 class DictionaryValue;
23 class FilePath;
25 class RefCountedMemory; 24 class RefCountedMemory;
26 } 25 }
27 26
28 namespace extensions { 27 namespace extensions {
29 class Extensions; 28 class Extensions;
30 } 29 }
31 30
32 namespace gfx { 31 namespace gfx {
33 class Image; 32 class Image;
34 } 33 }
(...skipping 25 matching lines...) Expand all
60 // Builds the theme pack from all data from |extension|. This is often done 59 // Builds the theme pack from all data from |extension|. This is often done
61 // on a separate thread as it takes so long. This can fail and return NULL in 60 // on a separate thread as it takes so long. This can fail and return NULL in
62 // the case where the theme has invalid data. 61 // the case where the theme has invalid data.
63 static scoped_refptr<BrowserThemePack> BuildFromExtension( 62 static scoped_refptr<BrowserThemePack> BuildFromExtension(
64 const extensions::Extension* extension); 63 const extensions::Extension* extension);
65 64
66 // Builds the theme pack from a previously performed WriteToDisk(). This 65 // Builds the theme pack from a previously performed WriteToDisk(). This
67 // operation should be relatively fast, as it should be an mmap() and some 66 // operation should be relatively fast, as it should be an mmap() and some
68 // pointer swizzling. Returns NULL on any error attempting to read |path|. 67 // pointer swizzling. Returns NULL on any error attempting to read |path|.
69 static scoped_refptr<BrowserThemePack> BuildFromDataPack( 68 static scoped_refptr<BrowserThemePack> BuildFromDataPack(
70 const FilePath& path, const std::string& expected_id); 69 const base::FilePath& path, const std::string& expected_id);
71 70
72 // Builds a data pack on disk at |path| for future quick loading by 71 // Builds a data pack on disk at |path| for future quick loading by
73 // BuildFromDataPack(). Often (but not always) called from the file thread; 72 // BuildFromDataPack(). Often (but not always) called from the file thread;
74 // implementation should be threadsafe because neither thread will write to 73 // implementation should be threadsafe because neither thread will write to
75 // |image_memory_| and the worker thread will keep a reference to prevent 74 // |image_memory_| and the worker thread will keep a reference to prevent
76 // destruction. 75 // destruction.
77 bool WriteToDisk(const FilePath& path) const; 76 bool WriteToDisk(const base::FilePath& path) const;
78 77
79 // If this theme specifies data for the corresponding |id|, return true and 78 // If this theme specifies data for the corresponding |id|, return true and
80 // write the corresponding value to the output parameter. These functions 79 // write the corresponding value to the output parameter. These functions
81 // don't return the default data. These methods should only be called from 80 // don't return the default data. These methods should only be called from
82 // the UI thread. (But this isn't enforced because of unit tests). 81 // the UI thread. (But this isn't enforced because of unit tests).
83 bool GetTint(int id, color_utils::HSL* hsl) const; 82 bool GetTint(int id, color_utils::HSL* hsl) const;
84 bool GetColor(int id, SkColor* color) const; 83 bool GetColor(int id, SkColor* color) const;
85 bool GetDisplayProperty(int id, int* result) const; 84 bool GetDisplayProperty(int id, int* result) const;
86 85
87 // Returns an image if we have a custom image for |id|, otherwise NULL. 86 // Returns an image if we have a custom image for |id|, otherwise NULL.
(...skipping 17 matching lines...) Expand all
105 // track of the pointers. We own these and will delete them when we're done 104 // track of the pointers. We own these and will delete them when we're done
106 // using them. 105 // using them.
107 typedef std::map<int, const gfx::Image*> ImageCache; 106 typedef std::map<int, const gfx::Image*> ImageCache;
108 107
109 // The raw PNG memory associated with a certain id. 108 // The raw PNG memory associated with a certain id.
110 typedef std::map<int, scoped_refptr<base::RefCountedMemory> > RawImages; 109 typedef std::map<int, scoped_refptr<base::RefCountedMemory> > RawImages;
111 110
112 // The type passed to ui::DataPack::WritePack. 111 // The type passed to ui::DataPack::WritePack.
113 typedef std::map<uint16, base::StringPiece> RawDataForWriting; 112 typedef std::map<uint16, base::StringPiece> RawDataForWriting;
114 113
115 // An association between an id and the FilePath that has the image data. 114 // An association between an id and the base::FilePath that has the image data .
116 typedef std::map<int, FilePath> FilePathMap; 115 typedef std::map<int, base::FilePath> FilePathMap;
117 116
118 // Default. Everything is empty. 117 // Default. Everything is empty.
119 BrowserThemePack(); 118 BrowserThemePack();
120 119
121 virtual ~BrowserThemePack(); 120 virtual ~BrowserThemePack();
122 121
123 // Builds a header ready to write to disk. 122 // Builds a header ready to write to disk.
124 void BuildHeader(const extensions::Extension* extension); 123 void BuildHeader(const extensions::Extension* extension);
125 124
126 // Transforms the JSON tint values into their final versions in the |tints_| 125 // Transforms the JSON tint values into their final versions in the |tints_|
127 // array. 126 // array.
128 void BuildTintsFromJSON(base::DictionaryValue* tints_value); 127 void BuildTintsFromJSON(base::DictionaryValue* tints_value);
129 128
130 // Transforms the JSON color values into their final versions in the 129 // Transforms the JSON color values into their final versions in the
131 // |colors_| array and also fills in unspecified colors based on tint values. 130 // |colors_| array and also fills in unspecified colors based on tint values.
132 void BuildColorsFromJSON(base::DictionaryValue* color_value); 131 void BuildColorsFromJSON(base::DictionaryValue* color_value);
133 132
134 // Implementation details of BuildColorsFromJSON(). 133 // Implementation details of BuildColorsFromJSON().
135 void ReadColorsFromJSON(base::DictionaryValue* colors_value, 134 void ReadColorsFromJSON(base::DictionaryValue* colors_value,
136 std::map<int, SkColor>* temp_colors); 135 std::map<int, SkColor>* temp_colors);
137 void GenerateMissingColors(std::map<int, SkColor>* temp_colors); 136 void GenerateMissingColors(std::map<int, SkColor>* temp_colors);
138 137
139 // Transforms the JSON display properties into |display_properties_|. 138 // Transforms the JSON display properties into |display_properties_|.
140 void BuildDisplayPropertiesFromJSON(base::DictionaryValue* display_value); 139 void BuildDisplayPropertiesFromJSON(base::DictionaryValue* display_value);
141 140
142 // Parses the image names out of an extension. 141 // Parses the image names out of an extension.
143 void ParseImageNamesFromJSON(base::DictionaryValue* images_value, 142 void ParseImageNamesFromJSON(base::DictionaryValue* images_value,
144 const FilePath& images_path, 143 const base::FilePath& images_path,
145 FilePathMap* file_paths) const; 144 FilePathMap* file_paths) const;
146 145
147 // Creates the data for |source_images_| from |file_paths|. 146 // Creates the data for |source_images_| from |file_paths|.
148 void BuildSourceImagesArray(const FilePathMap& file_paths); 147 void BuildSourceImagesArray(const FilePathMap& file_paths);
149 148
150 // Loads the unmodified images packed in the extension to SkBitmaps. Returns 149 // Loads the unmodified images packed in the extension to SkBitmaps. Returns
151 // true if all images loaded. 150 // true if all images loaded.
152 bool LoadRawBitmapsTo(const FilePathMap& file_paths, 151 bool LoadRawBitmapsTo(const FilePathMap& file_paths,
153 ImageCache* image_cache); 152 ImageCache* image_cache);
154 153
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // Cache of images created in BuildFromExtension(). Once the theme pack is 256 // Cache of images created in BuildFromExtension(). Once the theme pack is
258 // created, this cache should only be accessed on the file thread. There 257 // created, this cache should only be accessed on the file thread. There
259 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| 258 // should be no IDs in |image_memory_| that are in |images_on_file_thread_|
260 // or vice versa. 259 // or vice versa.
261 ImageCache images_on_file_thread_; 260 ImageCache images_on_file_thread_;
262 261
263 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); 262 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack);
264 }; 263 };
265 264
266 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ 265 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_
OLDNEW
« no previous file with comments | « chrome/browser/task_profiler/task_profiler_data_serializer.h ('k') | chrome/browser/themes/theme_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698