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_LOADER_H_ | 5 #ifndef EXTENSIONS_BROWSER_IMAGE_LOADER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_IMAGE_LOADER_H_ | 6 #define EXTENSIONS_BROWSER_IMAGE_LOADER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
14 #include "extensions/common/extension_resource.h" | 14 #include "extensions/common/extension_resource.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "ui/base/layout.h" | 16 #include "ui/base/layout.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 struct LoadResult; | 69 struct LoadResult; |
70 | 70 |
71 // Returns the instance for the given |context| or NULL if none. This is | 71 // Returns the instance for the given |context| or NULL if none. This is |
72 // a convenience wrapper around ImageLoaderFactory::GetForBrowserContext. | 72 // a convenience wrapper around ImageLoaderFactory::GetForBrowserContext. |
73 static ImageLoader* Get(content::BrowserContext* context); | 73 static ImageLoader* Get(content::BrowserContext* context); |
74 | 74 |
75 ImageLoader(); | 75 ImageLoader(); |
76 virtual ~ImageLoader(); | 76 virtual ~ImageLoader(); |
77 | 77 |
78 // Checks whether image is a component extension resource. Returns false | |
79 // if a given |resource| does not have a corresponding image in bundled | |
80 // resources. Otherwise fills |resource_id|. This doesn't check if the | |
81 // extension the resource is in is actually a component extension. | |
82 static bool IsComponentExtensionResource( | |
83 const base::FilePath& extension_path, | |
84 const base::FilePath& resource_path, | |
85 int* resource_id); | |
86 | |
87 // Specify image resource to load. If the loaded image is larger than | 78 // Specify image resource to load. If the loaded image is larger than |
88 // |max_size| it will be resized to those dimensions. IMPORTANT NOTE: this | 79 // |max_size| it will be resized to those dimensions. IMPORTANT NOTE: this |
89 // function may call back your callback synchronously (ie before it returns) | 80 // function may call back your callback synchronously (ie before it returns) |
90 // if the image was found in the cache. | 81 // if the image was found in the cache. |
91 // Note this method loads a raw bitmap from the resource. All sizes given are | 82 // Note this method loads a raw bitmap from the resource. All sizes given are |
92 // assumed to be in pixels. | 83 // assumed to be in pixels. |
93 void LoadImageAsync(const extensions::Extension* extension, | 84 void LoadImageAsync(const extensions::Extension* extension, |
94 const ExtensionResource& resource, | 85 const ExtensionResource& resource, |
95 const gfx::Size& max_size, | 86 const gfx::Size& max_size, |
96 const ImageLoaderImageCallback& callback); | 87 const ImageLoaderImageCallback& callback); |
(...skipping 23 matching lines...) Expand all Loading... |
120 void ReplyBackWithImageFamily(const ImageLoaderImageFamilyCallback& callback, | 111 void ReplyBackWithImageFamily(const ImageLoaderImageFamilyCallback& callback, |
121 const std::vector<LoadResult>& load_result); | 112 const std::vector<LoadResult>& load_result); |
122 | 113 |
123 base::WeakPtrFactory<ImageLoader> weak_ptr_factory_; | 114 base::WeakPtrFactory<ImageLoader> weak_ptr_factory_; |
124 | 115 |
125 DISALLOW_COPY_AND_ASSIGN(ImageLoader); | 116 DISALLOW_COPY_AND_ASSIGN(ImageLoader); |
126 }; | 117 }; |
127 | 118 |
128 } // namespace extensions | 119 } // namespace extensions |
129 | 120 |
130 #endif // CHROME_BROWSER_EXTENSIONS_IMAGE_LOADER_H_ | 121 #endif // EXTENSIONS_BROWSER_IMAGE_LOADER_H_ |
OLD | NEW |