- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / extensions / wallpaper_function_base.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_
7
8 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "chrome/browser/extensions/extension_function.h"
10 #include "ui/gfx/image/image_skia.h"
11
12 namespace wallpaper_api_util {
13 ash::WallpaperLayout GetLayoutEnum(const std::string& layout);
14 }  // namespace wallpaper_api_util
15
16 // Wallpaper manager function base. It contains a image decoder to decode
17 // wallpaper data.
18 class WallpaperFunctionBase : public AsyncExtensionFunction {
19  public:
20   WallpaperFunctionBase();
21
22  protected:
23   virtual ~WallpaperFunctionBase();
24
25   // A class to decode JPEG file.
26   class UnsafeWallpaperDecoder;
27
28   // Holds an instance of WallpaperDecoder.
29   static UnsafeWallpaperDecoder* unsafe_wallpaper_decoder_;
30
31   // Starts to decode |data|. Must run on UI thread.
32   void StartDecode(const std::string& data);
33
34   // Handles cancel case. No error message should be set.
35   void OnCancel();
36
37   // Handles failure case. Sets error message.
38   void OnFailure(const std::string& error);
39
40  private:
41   virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) = 0;
42 };
43
44 #endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_