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

Side by Side Diff: trunk/src/chrome/browser/ui/webui/extensions/extension_icon_source.h

Issue 26511002: Revert 227477 "Refactored loading of applications / extensions i..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 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_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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int render_process_id, 77 int render_process_id,
78 int render_view_id, 78 int render_view_id,
79 const content::URLDataSource::GotDataCallback& callback) OVERRIDE; 79 const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
80 80
81 private: 81 private:
82 // Encapsulates the request parameters for |request_id|. 82 // Encapsulates the request parameters for |request_id|.
83 struct ExtensionIconRequest; 83 struct ExtensionIconRequest;
84 84
85 virtual ~ExtensionIconSource(); 85 virtual ~ExtensionIconSource();
86 86
87 // Loads the extension's icon for the given |request_id| and returns the 87 // Returns the bitmap for the default app image.
88 const SkBitmap* GetDefaultAppImage();
89
90 // Returns the bitmap for the default extension.
91 const SkBitmap* GetDefaultExtensionImage();
92
93 // Performs any remaining transformations (like desaturating the |image|),
94 // then returns the |image| to the client and clears up any temporary data
95 // associated with the |request_id|.
96 void FinalizeImage(const SkBitmap* image, int request_id);
97
98 // Loads the default image for |request_id| and returns to the client.
99 void LoadDefaultImage(int request_id);
100
101 // Loads the extension's |icon| for the given |request_id| and returns the
88 // image to the client. 102 // image to the client.
89 void LoadExtensionImage(int request_id); 103 void LoadExtensionImage(const ExtensionResource& icon,
104 int request_id);
90 105
91 // LoadExtensionImage() will load the icon using 106 // Loads the favicon image for the app associated with the |request_id|. If
92 // ImageLoader::LoadExtensionIconAsync(). OnIconLoaded will be called when 107 // the image does not exist, we fall back to the default image.
93 // the icon has been loaded. 108 void LoadFaviconImage(int request_id);
94 void OnIconLoaded(int request_id, const gfx::Image& image); 109
110 // FaviconService callback
111 void OnFaviconDataAvailable(
112 int request_id,
113 const chrome::FaviconBitmapResult& bitmap_result);
114
115 // ImageLoader callback
116 void OnImageLoaded(int request_id, const gfx::Image& image);
117
118 // Called when the extension doesn't have an icon. We fall back to multiple
119 // sources, using the following order:
120 // 1) The icons as listed in the extension / app manifests.
121 // 2) If a 16px icon and the extension has a launch URL, see if Chrome
122 // has a corresponding favicon.
123 // 3) If still no matches, load the default extension / application icon.
124 void LoadIconFailed(int request_id);
95 125
96 // Parses and savse an ExtensionIconRequest for the URL |path| for the 126 // Parses and savse an ExtensionIconRequest for the URL |path| for the
97 // specified |request_id|. 127 // specified |request_id|.
98 bool ParseData(const std::string& path, 128 bool ParseData(const std::string& path,
99 int request_id, 129 int request_id,
100 const content::URLDataSource::GotDataCallback& callback); 130 const content::URLDataSource::GotDataCallback& callback);
101 131
102 // Stores the parameters associated with the |request_id|, making them 132 // Stores the parameters associated with the |request_id|, making them
103 // as an ExtensionIconRequest via GetData. 133 // as an ExtensionIconRequest via GetData.
104 void SetData(int request_id, 134 void SetData(int request_id,
105 const content::URLDataSource::GotDataCallback& callback, 135 const content::URLDataSource::GotDataCallback& callback,
106 const Extension* extension, 136 const Extension* extension,
107 bool grayscale, 137 bool grayscale,
108 int size, 138 int size,
109 ExtensionIconSet::MatchType match); 139 ExtensionIconSet::MatchType match);
110 140
111 // Returns the ExtensionIconRequest for the given |request_id|. 141 // Returns the ExtensionIconRequest for the given |request_id|.
112 ExtensionIconRequest* GetData(int request_id); 142 ExtensionIconRequest* GetData(int request_id);
113 143
114 // Removes temporary data associated with |request_id|. 144 // Removes temporary data associated with |request_id|.
115 void ClearData(int request_id); 145 void ClearData(int request_id);
116 146
117 Profile* profile_; 147 Profile* profile_;
118 148
149 // Maps tracker ids to request ids.
150 std::map<int, int> tracker_map_;
151
119 // Maps request_ids to ExtensionIconRequests. 152 // Maps request_ids to ExtensionIconRequests.
120 std::map<int, ExtensionIconRequest*> request_map_; 153 std::map<int, ExtensionIconRequest*> request_map_;
121 154
155 scoped_ptr<SkBitmap> default_app_data_;
156
157 scoped_ptr<SkBitmap> default_extension_data_;
158
159 CancelableTaskTracker cancelable_task_tracker_;
160
122 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); 161 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource);
123 }; 162 };
124 163
125 } // namespace extensions 164 } // namespace extensions
126 165
127 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ 166 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698