| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_WALLPAPER_SOURCE_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_WALLPAPER_SOURCE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/memory/ref_counted_memory.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | |
| 15 | |
| 16 namespace chromeos { | |
| 17 namespace options { | |
| 18 | |
| 19 // A DataSource for chrome://wallpaper/ URL, provides current user's wallpaper. | |
| 20 class WallpaperImageSource : public ChromeURLDataManager::DataSource { | |
| 21 public: | |
| 22 WallpaperImageSource(); | |
| 23 | |
| 24 // ChromeURLDataManager::DataSource implementation. | |
| 25 virtual void StartDataRequest(const std::string& path, | |
| 26 bool is_incognito, | |
| 27 int request_id) OVERRIDE; | |
| 28 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | |
| 29 | |
| 30 private: | |
| 31 class WallpaperEncodingOperation; | |
| 32 | |
| 33 virtual ~WallpaperImageSource(); | |
| 34 | |
| 35 // Get wallpaper for request identified by |request_id| in UI thread | |
| 36 // and pass it to encoding phase. | |
| 37 void GetCurrentUserWallpaper(int request_id); | |
| 38 | |
| 39 // Callback is called when image is obtained from UI thread to | |
| 40 // encode and send reply to request identified by |request_id|. | |
| 41 void ImageAcquired(SkBitmap image, int request_id); | |
| 42 | |
| 43 // Cancel current image encoding operation. | |
| 44 void CancelPendingEncodingOperation(); | |
| 45 | |
| 46 // Send image stored in |data| as a reply to request | |
| 47 // identifed by |request_id|. | |
| 48 void SendCurrentUserWallpaper(int request_id, | |
| 49 scoped_refptr<base::RefCountedBytes> data); | |
| 50 | |
| 51 scoped_refptr<WallpaperEncodingOperation> wallpaper_encoding_op_; | |
| 52 | |
| 53 base::WeakPtrFactory<WallpaperImageSource> weak_ptr_factory_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(WallpaperImageSource); | |
| 56 }; | |
| 57 | |
| 58 } // namespace options | |
| 59 } // namespace chromeos | |
| 60 | |
| 61 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_WALLPAPER_SOURCE_H_ | |
| OLD | NEW |