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

Unified 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698