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

Side by Side Diff: chrome/browser/extensions/image_utils.h

Issue 11027044: Add a class to replace ImageLoadingTracker with a nicer API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_IMAGE_UTILS_H_
6 #define CHROME_BROWSER_EXTENSIONS_IMAGE_UTILS_H_
7
8 #include <vector>
9
10 #include "base/callback_forward.h"
11 #include "chrome/common/extensions/extension_resource.h"
12 #include "ui/base/layout.h"
13 #include "ui/gfx/size.h"
14
15 namespace extensions {
16 class Extension;
17 }
18
19 namespace gfx {
20 class Image;
21 }
22
23 namespace extension_image_utils {
24
25 void LoadImageAsync(const extensions::Extension* extension,
26 const ExtensionResource& resource,
27 const gfx::Size& max_size,
28 const base::Callback<void(const gfx::Image&)>& callback);
29
30 // Information about a singe image representation to load from an extension
31 // resource.
32 struct ImageRepresentation {
33 // Enum values to indicate whether to resize loaded bitmap when it is larger
34 // than |desired_size| or always resize it.
35 enum ResizeCondition {
36 RESIZE_WHEN_LARGER,
37 ALWAYS_RESIZE,
38 };
39
40 ImageRepresentation(const ExtensionResource& resource,
41 ResizeCondition resize_condition,
42 const gfx::Size& desired_size,
43 ui::ScaleFactor scale_factor);
44 ~ImageRepresentation();
45
46 // Extension resource to load.
47 ExtensionResource resource;
48
49 ResizeCondition resize_condition;
50
51 // When |resize_method| is ALWAYS_RESIZE or when the loaded image is larger
52 // than |desired_size| it will be resized to these dimensions.
53 gfx::Size desired_size;
54
55 // |scale_factor| is used to construct the loaded gfx::ImageSkia.
56 ui::ScaleFactor scale_factor;
57 };
58
59 void LoadImagesAsync(const extensions::Extension* extension,
60 const std::vector<ImageRepresentation>& info_list,
61 const base::Callback<void(const gfx::Image&)>& callback);
62
63 } // namespace extension_image_utils
64
65 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698