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