Hook up PushSubscriptionOptions on the Chromium side.
[chromium-blink-merge.git] / components / wallpaper / wallpaper_resizer.h
bloba7ec1f00aba960c02b54a4f005406bbd1c8c9c91
1 // Copyright (c) 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 COMPONENTS_WALLPAPER_WALLPAPER_RESIZER_H_
6 #define COMPONENTS_WALLPAPER_WALLPAPER_RESIZER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/observer_list.h"
10 #include "components/wallpaper/wallpaper_layout.h"
11 #include "components/wallpaper/wallpaper_resizer_observer.h"
12 #include "skia/ext/image_operations.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/image/image_skia.h"
18 namespace base {
19 class SequencedWorkerPool;
22 namespace wallpaper {
24 class WallpaperResizerObserver;
26 // Stores the current wallpaper data and resize it to |target_size| if needed.
27 class WALLPAPER_EXPORT WallpaperResizer {
28 public:
29 // Returns a unique identifier corresponding to |image|, suitable for
30 // comparison against the value returned by original_image_id(). If the image
31 // is modified, its ID will change.
32 static uint32_t GetImageId(const gfx::ImageSkia& image);
34 WallpaperResizer(const gfx::ImageSkia& image,
35 const gfx::Size& target_size,
36 WallpaperLayout layout,
37 base::SequencedWorkerPool* worker_pool_ptr);
39 ~WallpaperResizer();
41 const gfx::ImageSkia& image() const { return image_; }
42 uint32_t original_image_id() const { return original_image_id_; }
43 WallpaperLayout layout() const { return layout_; }
44 base::SequencedWorkerPool* worker_pool() const { return worker_pool_; }
46 // Called on the UI thread to run Resize() on the worker pool and post an
47 // OnResizeFinished() task back to the UI thread on completion.
48 void StartResize();
50 // Add/Remove observers.
51 void AddObserver(WallpaperResizerObserver* observer);
52 void RemoveObserver(WallpaperResizerObserver* observer);
54 private:
55 // Copies |resized_bitmap| to |image_| and notifies observers after Resize()
56 // has finished running.
57 void OnResizeFinished(SkBitmap* resized_bitmap);
59 ObserverList<WallpaperResizerObserver> observers_;
61 // Image that should currently be used for wallpaper. It initially
62 // contains the original image and is updated to contain the resized
63 // image by OnResizeFinished().
64 gfx::ImageSkia image_;
66 // Unique identifier corresponding to the original (i.e. pre-resize) |image_|.
67 uint32_t original_image_id_;
69 gfx::Size target_size_;
71 WallpaperLayout layout_;
73 base::SequencedWorkerPool* worker_pool_;
75 base::WeakPtrFactory<WallpaperResizer> weak_ptr_factory_;
77 DISALLOW_COPY_AND_ASSIGN(WallpaperResizer);
80 } // namespace wallpaper
82 #endif // COMPONENTS_WALLPAPER_WALLPAPER_RESIZER_H_