Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / browser / test_image_loader.h
blob89003286514ed55740d1e996c59a16ae4d2d7d2a
1 // Copyright 2015 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.
5 #ifndef EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_
6 #define EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_
8 #include "base/run_loop.h"
9 #include "ui/gfx/image/image.h"
11 namespace extensions {
13 class Extension;
15 // Helper class for synchronously loading an extension image resource.
16 class TestImageLoader {
17 public:
18 TestImageLoader();
19 ~TestImageLoader();
21 // Loads an image to be used in test from |extension|.
22 // The image will be loaded from the relative path |image_path|.
23 static SkBitmap LoadAndGetExtensionBitmap(const Extension* extension,
24 const std::string& image_path,
25 int size);
27 private:
28 void OnImageLoaded(const gfx::Image& image);
30 SkBitmap LoadAndGetBitmap(const Extension* extension,
31 const std::string& path,
32 int size);
34 gfx::Image image_;
35 base::Closure loader_message_loop_quit_;
36 bool waiting_;
37 bool image_loaded_;
39 DISALLOW_COPY_AND_ASSIGN(TestImageLoader);
42 } // namespace extensions
44 #endif // EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_