Index: chrome/browser/extensions/image_utils.h |
diff --git a/chrome/browser/extensions/image_utils.h b/chrome/browser/extensions/image_utils.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5b1a362c7637c4bf46f84a7c106b1a4c700fc052 |
--- /dev/null |
+++ b/chrome/browser/extensions/image_utils.h |
@@ -0,0 +1,65 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_IMAGE_UTILS_H_ |
+#define CHROME_BROWSER_EXTENSIONS_IMAGE_UTILS_H_ |
+ |
+#include <vector> |
+ |
+#include "base/callback_forward.h" |
+#include "chrome/common/extensions/extension_resource.h" |
+#include "ui/base/layout.h" |
+#include "ui/gfx/size.h" |
+ |
+namespace extensions { |
+class Extension; |
+} |
+ |
+namespace gfx { |
+class Image; |
+} |
+ |
+namespace extension_image_utils { |
+ |
+void LoadImageAsync(const extensions::Extension* extension, |
+ const ExtensionResource& resource, |
+ const gfx::Size& max_size, |
+ const base::Callback<void(const gfx::Image&)>& callback); |
+ |
+// Information about a singe image representation to load from an extension |
+// resource. |
+struct ImageRepresentation { |
+ // Enum values to indicate whether to resize loaded bitmap when it is larger |
+ // than |desired_size| or always resize it. |
+ enum ResizeCondition { |
+ RESIZE_WHEN_LARGER, |
+ ALWAYS_RESIZE, |
+ }; |
+ |
+ ImageRepresentation(const ExtensionResource& resource, |
+ ResizeCondition resize_condition, |
+ const gfx::Size& desired_size, |
+ ui::ScaleFactor scale_factor); |
+ ~ImageRepresentation(); |
+ |
+ // Extension resource to load. |
+ ExtensionResource resource; |
+ |
+ ResizeCondition resize_condition; |
+ |
+ // When |resize_method| is ALWAYS_RESIZE or when the loaded image is larger |
+ // than |desired_size| it will be resized to these dimensions. |
+ gfx::Size desired_size; |
+ |
+ // |scale_factor| is used to construct the loaded gfx::ImageSkia. |
+ ui::ScaleFactor scale_factor; |
+}; |
+ |
+void LoadImagesAsync(const extensions::Extension* extension, |
+ const std::vector<ImageRepresentation>& info_list, |
+ const base::Callback<void(const gfx::Image&)>& callback); |
+ |
+} // namespace extension_image_utils |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_IMAGE_UTILS_H_ |