Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / android / thumbnail / thumbnail.h
blob79ed868b5a24a42da0ae42564f1a158b84b33323
1 // Copyright 2014 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 CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_
6 #define CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h"
10 #include "cc/resources/ui_resource_bitmap.h"
11 #include "cc/resources/ui_resource_client.h"
12 #include "ui/android/resources/ui_resource_client_android.h"
13 #include "ui/gfx/geometry/size.h"
15 namespace base {
16 class Time;
19 namespace gfx {
20 class Size;
23 namespace ui {
24 class UIResourceProvider;
27 typedef int TabId;
29 class Thumbnail;
31 class ThumbnailDelegate {
32 public:
33 virtual void InvalidateCachedThumbnail(Thumbnail* thumbnail) = 0;
34 virtual ~ThumbnailDelegate() {}
37 class Thumbnail : public ui::UIResourceClientAndroid {
38 public:
39 static scoped_ptr<Thumbnail> Create(
40 TabId tab_id,
41 const base::Time& time_stamp,
42 float scale,
43 ui::UIResourceProvider* ui_resource_provider,
44 ThumbnailDelegate* thumbnail_delegate);
45 ~Thumbnail() override;
47 TabId tab_id() const { return tab_id_; }
48 base::Time time_stamp() const { return time_stamp_; }
49 float scale() const { return scale_; }
50 cc::UIResourceId ui_resource_id() const { return ui_resource_id_; }
51 const gfx::SizeF& scaled_content_size() const { return scaled_content_size_; }
52 const gfx::SizeF& scaled_data_size() const { return scaled_data_size_; }
54 void SetBitmap(const SkBitmap& bitmap);
55 void SetCompressedBitmap(skia::RefPtr<SkPixelRef> compressed_bitmap,
56 const gfx::Size& content_size);
57 void CreateUIResource();
59 // content::UIResourceClient implementation.
60 cc::UIResourceBitmap GetBitmap(cc::UIResourceId uid,
61 bool resource_lost) override;
63 // ui::UIResourceClientAndroid implementation.
64 void UIResourceIsInvalid() override;
66 protected:
67 Thumbnail(TabId tab_id,
68 const base::Time& time_stamp,
69 float scale,
70 ui::UIResourceProvider* ui_resource_provider,
71 ThumbnailDelegate* thumbnail_delegate);
73 void ClearUIResourceId();
75 TabId tab_id_;
76 base::Time time_stamp_;
77 float scale_;
79 gfx::SizeF scaled_content_size_;
80 gfx::SizeF scaled_data_size_;
82 cc::UIResourceBitmap bitmap_;
83 cc::UIResourceId ui_resource_id_;
85 bool retrieved_;
87 ui::UIResourceProvider* ui_resource_provider_;
88 ThumbnailDelegate* thumbnail_delegate_;
90 DISALLOW_COPY_AND_ASSIGN(Thumbnail);
93 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_THUMBNAIL_H_