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

Side by Side Diff: chrome/browser/extensions/extension_icon_image.cc

Issue 12213093: Remove ImageLoadingTracker class (Closed) Base URL: https://git.chromium.org/chromium/src.git@Issue_163929
Patch Set: Fix merge conflict 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
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 #include "chrome/browser/extensions/extension_icon_image.h" 5 #include "chrome/browser/extensions/extension_icon_image.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "chrome/browser/extensions/image_loader.h" 10 #include "chrome/browser/extensions/image_loader.h"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/image/canvas_image_source.h" 15 #include "ui/gfx/image/canvas_image_source.h"
16 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/image/image_skia_operations.h" 17 #include "ui/gfx/image/image_skia_operations.h"
18 #include "ui/gfx/image/image_skia_source.h" 18 #include "ui/gfx/image/image_skia_source.h"
19 #include "ui/gfx/size.h" 19 #include "ui/gfx/size.h"
20 #include "ui/gfx/size_conversions.h" 20 #include "ui/gfx/size_conversions.h"
21 21
22 // The ImageSkia provided by extensions::IconImage contains ImageSkiaReps that 22 // The ImageSkia provided by extensions::IconImage contains ImageSkiaReps that
23 // are computed and updated using the following algorithm (if no default icon 23 // are computed and updated using the following algorithm (if no default icon
24 // was supplied, transparent icon is considered the default): 24 // was supplied, transparent icon is considered the default):
25 // - |LoadImageForScaleFactors()| searches the extension for an icon of an 25 // - |LoadImageForScaleFactors()| searches the extension for an icon of an
26 // appropriate size. If the extension doesn't have a icon resource needed for 26 // appropriate size. If the extension doesn't have a icon resource needed for
27 // the image representation, the default icon's representation for the 27 // the image representation, the default icon's representation for the
28 // requested scale factor is returned by ImageSkiaSource. 28 // requested scale factor is returned by ImageSkiaSource.
29 // - If the extension has the resource, IconImage tries to load it using 29 // - If the extension has the resource, IconImage tries to load it using
30 // ImageLoadingTracker. 30 // ImageLoader.
31 // - |ImageLoadingTracker| may return both synchronously and asynchronously. 31 // - |ImageLoader| is asynchronous.
32 // 1. |ImageLoadingTracker| is synchronous.
33 // - If image representation resource is successfully loaded, the
34 // representation returned by ImageSkiaSource is created from the loaded
35 // bitmap.
36 // - If resource loading fails, ImageSkiaSource returns default icon's
37 // representation.
38 // 2. |ImageLoadingTracker| is asynchronous.
39 // - ImageSkiaSource will initially return transparent image resource of the 32 // - ImageSkiaSource will initially return transparent image resource of the
40 // desired size. 33 // desired size.
41 // - The image will be updated with an appropriate image representation when 34 // - The image will be updated with an appropriate image representation when
42 // the |ImageLoadingTracker| finishes. The image representation is chosen 35 // the |ImageLoader| finishes. The image representation is chosen the same
43 // the same way as in the synchronous case. The observer is notified of the 36 // way as in the synchronous case. The observer is notified of the image
44 // image change, unless the added image representation is transparent (in 37 // change, unless the added image representation is transparent (in which
45 // which case the image had already contained the appropriate image 38 // case the image had already contained the appropriate image
46 // representation). 39 // representation).
47 40
48 namespace { 41 namespace {
49 42
50 const int kMatchBiggerTreshold = 32; 43 const int kMatchBiggerTreshold = 32;
51 44
52 ExtensionResource GetExtensionIconResource( 45 ExtensionResource GetExtensionIconResource(
53 const extensions::Extension* extension, 46 const extensions::Extension* extension,
54 const ExtensionIconSet& icons, 47 const ExtensionIconSet& icons,
55 int size, 48 int size,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED); 230 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED);
238 231
239 const Extension* extension = 232 const Extension* extension =
240 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; 233 content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
241 234
242 if (extension_ == extension) 235 if (extension_ == extension)
243 extension_ = NULL; 236 extension_ = NULL;
244 } 237 }
245 238
246 } // namespace extensions 239 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/webview/webview_api.cc ('k') | chrome/browser/extensions/extension_icon_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698