Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / wallpaper_function_base.h
blob8ad72cf3710d992892b4e2545e55e9098e497e05
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_
8 #include <string>
9 #include <vector>
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
29 // wallpaper data.
30 class WallpaperFunctionBase : public AsyncExtensionFunction {
31 public:
32 WallpaperFunctionBase();
34 protected:
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.
47 void OnCancel();
49 // Handles failure case. Sets error message.
50 void OnFailure(const std::string& error);
52 private:
53 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) = 0;
56 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_FUNCTION_BASE_H_