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.
5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_
11 #include "ash/desktop_background/desktop_background_controller.h"
12 #include "components/wallpaper/wallpaper_layout.h"
13 #include "extensions/browser/extension_function.h"
14 #include "ui/gfx/image/image_skia.h"
16 namespace wallpaper_api_util
{
18 extern const char kCancelWallpaperMessage
[];
20 wallpaper::WallpaperLayout
GetLayoutEnum(const std::string
& layout
);
22 // This is used to record the wallpaper layout when the user sets a custom
23 // wallpaper or changes the existing custom wallpaper's layout.
24 void RecordCustomWallpaperLayout(const wallpaper::WallpaperLayout
& layout
);
26 } // namespace wallpaper_api_util
28 // Wallpaper manager function base. It contains a image decoder to decode
30 class WallpaperFunctionBase
: public AsyncExtensionFunction
{
32 WallpaperFunctionBase();
35 ~WallpaperFunctionBase() override
;
37 // A class to decode JPEG file.
38 class UnsafeWallpaperDecoder
;
40 // Holds an instance of WallpaperDecoder.
41 static UnsafeWallpaperDecoder
* unsafe_wallpaper_decoder_
;
43 // Starts to decode |data|. Must run on UI thread.
44 void StartDecode(const std::vector
<char>& data
);
46 // Handles cancel case. No error message should be set.
49 // Handles failure case. Sets error message.
50 void OnFailure(const std::string
& error
);
53 virtual void OnWallpaperDecoded(const gfx::ImageSkia
& wallpaper
) = 0;
56 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_