| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include "ash/desktop_background/desktop_background_resources.h" | 8 #include "ash/desktop_background/desktop_background_resources.h" |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 #include "net/url_request/url_fetcher_delegate.h" | 10 #include "net/url_request/url_fetcher_delegate.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 11 #include "ui/gfx/image/image_skia.h" |
| 12 | 12 |
| 13 // Wallpaper manager strings. | 13 // Wallpaper manager strings. |
| 14 class WallpaperStringsFunction : public SyncExtensionFunction { | 14 class WallpaperStringsFunction : public SyncExtensionFunction { |
| 15 public: | 15 public: |
| 16 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.getStrings"); | 16 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.getStrings"); |
| 17 | 17 |
| 18 protected: | 18 protected: |
| 19 virtual ~WallpaperStringsFunction() {} | 19 virtual ~WallpaperStringsFunction() {} |
| 20 | 20 |
| 21 // SyncExtensionFunction overrides. | 21 // SyncExtensionFunction overrides. |
| 22 virtual bool RunImpl() OVERRIDE; | 22 virtual bool RunImpl() OVERRIDE; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 class WallpaperSetWallpaperFunction : public AsyncExtensionFunction { | 25 // Wallpaper manager function base. It contains a JPEG decoder to decode |
| 26 // wallpaper data. |
| 27 class WallpaperFunctionBase : public AsyncExtensionFunction { |
| 28 public: |
| 29 WallpaperFunctionBase(); |
| 30 |
| 31 protected: |
| 32 virtual ~WallpaperFunctionBase(); |
| 33 |
| 34 // AsyncExtensionFunction overrides. |
| 35 virtual bool RunImpl() OVERRIDE; |
| 36 |
| 37 // A class to decode JPEG file. |
| 38 class WallpaperDecoder; |
| 39 |
| 40 // Holds an instance of WallpaperDecoder. |
| 41 static WallpaperDecoder* wallpaper_decoder_; |
| 42 |
| 43 private: |
| 44 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) = 0; |
| 45 virtual void OnFailure() = 0; |
| 46 }; |
| 47 |
| 48 class WallpaperSetWallpaperFunction : public WallpaperFunctionBase { |
| 26 public: | 49 public: |
| 27 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.setWallpaper"); | 50 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.setWallpaper"); |
| 28 | 51 |
| 29 WallpaperSetWallpaperFunction(); | 52 WallpaperSetWallpaperFunction(); |
| 30 | 53 |
| 31 protected: | 54 protected: |
| 32 virtual ~WallpaperSetWallpaperFunction(); | 55 virtual ~WallpaperSetWallpaperFunction(); |
| 33 | 56 |
| 34 // AsyncExtensionFunction overrides. | 57 // AsyncExtensionFunction overrides. |
| 35 virtual bool RunImpl() OVERRIDE; | 58 virtual bool RunImpl() OVERRIDE; |
| 36 | 59 |
| 37 private: | 60 private: |
| 38 class WallpaperDecoder; | 61 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) OVERRIDE; |
| 39 | 62 virtual void OnFailure() OVERRIDE; |
| 40 void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper); | |
| 41 void OnFail(); | |
| 42 | 63 |
| 43 // Saves the image data to a file. | 64 // Saves the image data to a file. |
| 44 void SaveToFile(); | 65 void SaveToFile(); |
| 45 | 66 |
| 46 // Sets wallpaper to the decoded image. | 67 // Sets wallpaper to the decoded image. |
| 47 void SetDecodedWallpaper(); | 68 void SetDecodedWallpaper(); |
| 48 | 69 |
| 49 // Layout of the downloaded wallpaper. | 70 // Layout of the downloaded wallpaper. |
| 50 ash::WallpaperLayout layout_; | 71 ash::WallpaperLayout layout_; |
| 51 | 72 |
| 52 // The decoded wallpaper. | 73 // The decoded wallpaper. |
| 53 gfx::ImageSkia wallpaper_; | 74 gfx::ImageSkia wallpaper_; |
| 54 | 75 |
| 55 // Email address of logged in user. | 76 // Email address of logged in user. |
| 56 std::string email_; | 77 std::string email_; |
| 57 | 78 |
| 58 // File name extracts from URL. | 79 // File name extracts from URL. |
| 59 std::string file_name_; | 80 std::string file_name_; |
| 60 | 81 |
| 61 // String representation of downloaded wallpaper. | 82 // String representation of downloaded wallpaper. |
| 62 std::string image_data_; | 83 std::string image_data_; |
| 84 }; |
| 63 | 85 |
| 64 // Holds an instance of WallpaperDecoder. | 86 class WallpaperSetCustomWallpaperFunction : public WallpaperFunctionBase { |
| 65 static WallpaperDecoder* wallpaper_decoder_; | 87 public: |
| 88 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.setCustomWallpaper"); |
| 89 |
| 90 WallpaperSetCustomWallpaperFunction(); |
| 91 |
| 92 protected: |
| 93 virtual ~WallpaperSetCustomWallpaperFunction(); |
| 94 |
| 95 // AsyncExtensionFunction overrides. |
| 96 virtual bool RunImpl() OVERRIDE; |
| 97 |
| 98 private: |
| 99 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) OVERRIDE; |
| 100 virtual void OnFailure() OVERRIDE; |
| 101 |
| 102 // Layout of the downloaded wallpaper. |
| 103 ash::WallpaperLayout layout_; |
| 104 |
| 105 // Email address of logged in user. |
| 106 std::string email_; |
| 107 |
| 108 // String representation of downloaded wallpaper. |
| 109 std::string image_data_; |
| 66 }; | 110 }; |
| 67 | 111 |
| 68 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_ | 112 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_ |
| OLD | NEW |