OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_ |
7 | 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
8 #include "ash/desktop_background/desktop_background_controller.h" | 11 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "components/wallpaper/wallpaper_layout.h" | 12 #include "components/wallpaper/wallpaper_layout.h" |
10 #include "extensions/browser/extension_function.h" | 13 #include "extensions/browser/extension_function.h" |
11 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
12 | 15 |
13 namespace wallpaper_api_util { | 16 namespace wallpaper_api_util { |
14 extern const char kCancelWallpaperMessage[]; | 17 extern const char kCancelWallpaperMessage[]; |
15 wallpaper::WallpaperLayout GetLayoutEnum(const std::string& layout); | 18 wallpaper::WallpaperLayout GetLayoutEnum(const std::string& layout); |
16 } // namespace wallpaper_api_util | 19 } // namespace wallpaper_api_util |
17 | 20 |
18 // Wallpaper manager function base. It contains a image decoder to decode | 21 // Wallpaper manager function base. It contains a image decoder to decode |
19 // wallpaper data. | 22 // wallpaper data. |
20 class WallpaperFunctionBase : public AsyncExtensionFunction { | 23 class WallpaperFunctionBase : public AsyncExtensionFunction { |
21 public: | 24 public: |
22 WallpaperFunctionBase(); | 25 WallpaperFunctionBase(); |
23 | 26 |
24 protected: | 27 protected: |
25 ~WallpaperFunctionBase() override; | 28 ~WallpaperFunctionBase() override; |
26 | 29 |
27 // A class to decode JPEG file. | 30 // A class to decode JPEG file. |
28 class UnsafeWallpaperDecoder; | 31 class UnsafeWallpaperDecoder; |
29 | 32 |
30 // Holds an instance of WallpaperDecoder. | 33 // Holds an instance of WallpaperDecoder. |
31 static UnsafeWallpaperDecoder* unsafe_wallpaper_decoder_; | 34 static UnsafeWallpaperDecoder* unsafe_wallpaper_decoder_; |
32 | 35 |
33 // Starts to decode |data|. Must run on UI thread. | 36 // Starts to decode |data|. Must run on UI thread. |
34 void StartDecode(const std::string& data); | 37 void StartDecode(const std::vector<char>& data); |
35 | 38 |
36 // Handles cancel case. No error message should be set. | 39 // Handles cancel case. No error message should be set. |
37 void OnCancel(); | 40 void OnCancel(); |
38 | 41 |
39 // Handles failure case. Sets error message. | 42 // Handles failure case. Sets error message. |
40 void OnFailure(const std::string& error); | 43 void OnFailure(const std::string& error); |
41 | 44 |
42 private: | 45 private: |
43 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) = 0; | 46 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) = 0; |
44 }; | 47 }; |
45 | 48 |
46 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_ | 49 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_ |
OLD | NEW |