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_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 // When an image has finished loaded and been resized on the file thread, it | 116 // When an image has finished loaded and been resized on the file thread, it |
117 // is posted back to this method on the original thread. This method then | 117 // is posted back to this method on the original thread. This method then |
118 // calls the observer's OnImageLoaded and deletes the ImageLoadingTracker if | 118 // calls the observer's OnImageLoaded and deletes the ImageLoadingTracker if |
119 // it was the last image in the list. The |original_size| should be the size | 119 // it was the last image in the list. The |original_size| should be the size |
120 // of the image before any resizing was done. | 120 // of the image before any resizing was done. |
121 // |image| may be null if the file failed to decode. | 121 // |image| may be null if the file failed to decode. |
122 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 122 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, |
123 const gfx::Size& original_size, int id, bool should_cache); | 123 const gfx::Size& original_size, int id, bool should_cache); |
124 | 124 |
| 125 // Tries loading component extension image. These usually come from resources |
| 126 // instead of file system. Returns NULL if a given |resource| does not have |
| 127 // a corresponding image in bundled resources. |
| 128 SkBitmap *TryLoadingComponentExtensionImage( |
| 129 const Extension* extension, |
| 130 const ExtensionResource& resource); |
| 131 |
125 // content::NotificationObserver method. If an extension is uninstalled while | 132 // content::NotificationObserver method. If an extension is uninstalled while |
126 // we're waiting for the image we remove the entry from load_map_. | 133 // we're waiting for the image we remove the entry from load_map_. |
127 virtual void Observe(int type, | 134 virtual void Observe(int type, |
128 const content::NotificationSource& source, | 135 const content::NotificationSource& source, |
129 const content::NotificationDetails& details) OVERRIDE; | 136 const content::NotificationDetails& details) OVERRIDE; |
130 | 137 |
131 // The view that is waiting for the image to load. | 138 // The view that is waiting for the image to load. |
132 Observer* observer_; | 139 Observer* observer_; |
133 | 140 |
134 // ID to use for next image requested. This is an ever increasing integer. | 141 // ID to use for next image requested. This is an ever increasing integer. |
135 int next_id_; | 142 int next_id_; |
136 | 143 |
137 // The object responsible for loading the image on the File thread. | 144 // The object responsible for loading the image on the File thread. |
138 scoped_refptr<ImageLoader> loader_; | 145 scoped_refptr<ImageLoader> loader_; |
139 | 146 |
140 // Information for each LoadImage request is cached here. The integer | 147 // Information for each LoadImage request is cached here. The integer |
141 // identifies the id assigned to the request. | 148 // identifies the id assigned to the request. |
142 LoadMap load_map_; | 149 LoadMap load_map_; |
143 | 150 |
144 content::NotificationRegistrar registrar_; | 151 content::NotificationRegistrar registrar_; |
145 | 152 |
146 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); | 153 DISALLOW_COPY_AND_ASSIGN(ImageLoadingTracker); |
147 }; | 154 }; |
148 | 155 |
149 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ | 156 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADING_TRACKER_H_ |
OLD | NEW |