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_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void OnImageLoaded(int request_id, const gfx::Image& image); | 115 void OnImageLoaded(int request_id, const gfx::Image& image); |
116 | 116 |
117 // Called when the extension doesn't have an icon. We fall back to multiple | 117 // Called when the extension doesn't have an icon. We fall back to multiple |
118 // sources, using the following order: | 118 // sources, using the following order: |
119 // 1) The icons as listed in the extension / app manifests. | 119 // 1) The icons as listed in the extension / app manifests. |
120 // 2) If a 16px icon and the extension has a launch URL, see if Chrome | 120 // 2) If a 16px icon and the extension has a launch URL, see if Chrome |
121 // has a corresponding favicon. | 121 // has a corresponding favicon. |
122 // 3) If still no matches, load the default extension / application icon. | 122 // 3) If still no matches, load the default extension / application icon. |
123 void LoadIconFailed(int request_id); | 123 void LoadIconFailed(int request_id); |
124 | 124 |
125 // Parses and savse an ExtensionIconRequest for the URL |path| for the | 125 // Parses and saves an ExtensionIconRequest for the URL |path| for the |
126 // specified |request_id|. | 126 // specified |request_id|. |
127 bool ParseData(const std::string& path, | 127 bool ParseData(const std::string& path, |
128 int request_id, | 128 int request_id, |
129 const content::URLDataSource::GotDataCallback& callback); | 129 const content::URLDataSource::GotDataCallback& callback); |
130 | 130 |
131 // Stores the parameters associated with the |request_id|, making them | 131 // Stores the parameters associated with the |request_id|, making them |
132 // as an ExtensionIconRequest via GetData. | 132 // as an ExtensionIconRequest via GetData. |
133 void SetData(int request_id, | 133 void SetData(int request_id, |
134 const content::URLDataSource::GotDataCallback& callback, | 134 const content::URLDataSource::GotDataCallback& callback, |
135 const Extension* extension, | 135 const Extension* extension, |
136 bool grayscale, | 136 bool grayscale, |
137 int size, | 137 int size, |
138 ExtensionIconSet::MatchType match); | 138 ExtensionIconSet::MatchType match); |
139 | 139 |
140 // Returns the ExtensionIconRequest for the given |request_id|. | 140 // Returns the ExtensionIconRequest for the given |request_id|. |
141 ExtensionIconRequest* GetData(int request_id); | 141 ExtensionIconRequest* GetData(int request_id); |
142 | 142 |
143 // Removes temporary data associated with |request_id|. | 143 // Removes temporary data associated with |request_id|. |
144 void ClearData(int request_id); | 144 void ClearData(int request_id); |
145 | 145 |
146 Profile* profile_; | 146 Profile* profile_; |
147 | 147 |
148 // Maps tracker ids to request ids. | 148 // Maps tracker ids to request ids. |
149 std::map<int, int> tracker_map_; | 149 std::map<int, int> tracker_map_; |
150 | 150 |
151 // Maps request_ids to ExtensionIconRequests. | 151 // Maps request_ids to ExtensionIconRequests. |
152 std::map<int, ExtensionIconRequest*> request_map_; | 152 std::map<int, std::unique_ptr<ExtensionIconRequest>> request_map_; |
153 | 153 |
154 std::unique_ptr<SkBitmap> default_app_data_; | 154 std::unique_ptr<SkBitmap> default_app_data_; |
155 | 155 |
156 std::unique_ptr<SkBitmap> default_extension_data_; | 156 std::unique_ptr<SkBitmap> default_extension_data_; |
157 | 157 |
158 base::CancelableTaskTracker cancelable_task_tracker_; | 158 base::CancelableTaskTracker cancelable_task_tracker_; |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); | 160 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); |
161 }; | 161 }; |
162 | 162 |
163 } // namespace extensions | 163 } // namespace extensions |
164 | 164 |
165 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 165 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
OLD | NEW |