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