| 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 // A class to decode JPEG file. |
| 35 class WallpaperDecoder; |
| 36 |
| 37 // Holds an instance of WallpaperDecoder. |
| 38 static WallpaperDecoder* wallpaper_decoder_; |
| 39 |
| 40 private: |
| 41 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) = 0; |
| 42 virtual void OnFailure() = 0; |
| 43 }; |
| 44 |
| 45 class WallpaperSetWallpaperFunction : public WallpaperFunctionBase { |
| 26 public: | 46 public: |
| 27 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.setWallpaper"); | 47 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.setWallpaper"); |
| 28 | 48 |
| 29 WallpaperSetWallpaperFunction(); | 49 WallpaperSetWallpaperFunction(); |
| 30 | 50 |
| 31 protected: | 51 protected: |
| 32 virtual ~WallpaperSetWallpaperFunction(); | 52 virtual ~WallpaperSetWallpaperFunction(); |
| 33 | 53 |
| 34 // AsyncExtensionFunction overrides. | 54 // AsyncExtensionFunction overrides. |
| 35 virtual bool RunImpl() OVERRIDE; | 55 virtual bool RunImpl() OVERRIDE; |
| 36 | 56 |
| 37 private: | 57 private: |
| 38 class WallpaperDecoder; | 58 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) OVERRIDE; |
| 39 | 59 virtual void OnFailure() OVERRIDE; |
| 40 void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper); | |
| 41 void OnFail(); | |
| 42 | 60 |
| 43 // Saves the image data to a file. | 61 // Saves the image data to a file. |
| 44 void SaveToFile(); | 62 void SaveToFile(); |
| 45 | 63 |
| 46 // Sets wallpaper to the decoded image. | 64 // Sets wallpaper to the decoded image. |
| 47 void SetDecodedWallpaper(); | 65 void SetDecodedWallpaper(); |
| 48 | 66 |
| 49 // Layout of the downloaded wallpaper. | 67 // Layout of the downloaded wallpaper. |
| 50 ash::WallpaperLayout layout_; | 68 ash::WallpaperLayout layout_; |
| 51 | 69 |
| 52 // The decoded wallpaper. | 70 // The decoded wallpaper. |
| 53 gfx::ImageSkia wallpaper_; | 71 gfx::ImageSkia wallpaper_; |
| 54 | 72 |
| 55 // Email address of logged in user. | 73 // Email address of logged in user. |
| 56 std::string email_; | 74 std::string email_; |
| 57 | 75 |
| 58 // File name extracts from URL. | 76 // File name extracts from URL. |
| 59 std::string file_name_; | 77 std::string file_name_; |
| 60 | 78 |
| 61 // String representation of downloaded wallpaper. | 79 // String representation of downloaded wallpaper. |
| 62 std::string image_data_; | 80 std::string image_data_; |
| 81 }; |
| 63 | 82 |
| 64 // Holds an instance of WallpaperDecoder. | 83 class WallpaperSetCustomWallpaperFunction : public WallpaperFunctionBase { |
| 65 static WallpaperDecoder* wallpaper_decoder_; | 84 public: |
| 85 DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.setCustomWallpaper"); |
| 86 |
| 87 WallpaperSetCustomWallpaperFunction(); |
| 88 |
| 89 protected: |
| 90 virtual ~WallpaperSetCustomWallpaperFunction(); |
| 91 |
| 92 // AsyncExtensionFunction overrides. |
| 93 virtual bool RunImpl() OVERRIDE; |
| 94 |
| 95 private: |
| 96 virtual void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper) OVERRIDE; |
| 97 virtual void OnFailure() OVERRIDE; |
| 98 |
| 99 // Layout of the downloaded wallpaper. |
| 100 ash::WallpaperLayout layout_; |
| 101 |
| 102 // Email address of logged in user. |
| 103 std::string email_; |
| 104 |
| 105 // String representation of downloaded wallpaper. |
| 106 std::string image_data_; |
| 66 }; | 107 }; |
| 67 | 108 |
| 68 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_ | 109 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_ |
| OLD | NEW |