OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/linked_ptr.h" | 15 #include "base/linked_ptr.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
17 #include "chrome/browser/renderer_host/backing_store.h" | 17 #include "chrome/browser/renderer_host/backing_store.h" |
18 #include "chrome/common/notification_observer.h" | 18 #include "chrome/common/notification_observer.h" |
19 #include "chrome/common/notification_registrar.h" | 19 #include "chrome/common/notification_registrar.h" |
20 | 20 |
21 class GURL; | 21 class GURL; |
| 22 class Profile; |
22 class RenderWidgetHost; | 23 class RenderWidgetHost; |
23 class SkBitmap; | 24 class SkBitmap; |
24 class TabContents; | 25 class TabContents; |
25 | 26 |
| 27 namespace history { |
| 28 class TopSites; |
| 29 } |
| 30 |
26 class ThumbnailGenerator : NotificationObserver { | 31 class ThumbnailGenerator : NotificationObserver { |
27 public: | 32 public: |
28 typedef Callback1<const SkBitmap&>::Type ThumbnailReadyCallback; | 33 typedef Callback1<const SkBitmap&>::Type ThumbnailReadyCallback; |
29 // The result of clipping. This can be used to determine if the | 34 // The result of clipping. This can be used to determine if the |
30 // generated thumbnail is good or not. | 35 // generated thumbnail is good or not. |
31 enum ClipResult { | 36 enum ClipResult { |
32 // The source image is smaller. | 37 // The source image is smaller. |
33 kSourceIsSmaller, | 38 kSourceIsSmaller, |
34 // Wider than tall, clip horizontally. | 39 // Wider than tall, clip horizontally. |
35 kWiderThanTall, | 40 kWiderThanTall, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // input bitmap (400x400). | 119 // input bitmap (400x400). |
115 static SkBitmap GetClippedBitmap(const SkBitmap& bitmap, | 120 static SkBitmap GetClippedBitmap(const SkBitmap& bitmap, |
116 int desired_width, | 121 int desired_width, |
117 int desired_height, | 122 int desired_height, |
118 ClipResult* clip_result); | 123 ClipResult* clip_result); |
119 | 124 |
120 // Update the thumbnail of the given URL if necessary. | 125 // Update the thumbnail of the given URL if necessary. |
121 static void UpdateThumbnailIfNecessary(TabContents* tab_contents, | 126 static void UpdateThumbnailIfNecessary(TabContents* tab_contents, |
122 const GURL& url); | 127 const GURL& url); |
123 | 128 |
| 129 // Returns true if we should update the thumbnail of the given URL. |
| 130 static bool ShouldUpdateThumbnail(Profile* profile, |
| 131 history::TopSites* top_sites, |
| 132 const GURL& url); |
| 133 |
124 private: | 134 private: |
125 // RenderWidgetHostPaintingObserver implementation. | 135 // RenderWidgetHostPaintingObserver implementation. |
126 virtual void WidgetWillDestroyBackingStore(RenderWidgetHost* widget, | 136 virtual void WidgetWillDestroyBackingStore(RenderWidgetHost* widget, |
127 BackingStore* backing_store); | 137 BackingStore* backing_store); |
128 virtual void WidgetDidUpdateBackingStore(RenderWidgetHost* widget); | 138 virtual void WidgetDidUpdateBackingStore(RenderWidgetHost* widget); |
129 | 139 |
130 virtual void WidgetDidReceivePaintAtSizeAck( | 140 virtual void WidgetDidReceivePaintAtSizeAck( |
131 RenderWidgetHost* widget, | 141 RenderWidgetHost* widget, |
132 int tag, | 142 int tag, |
133 const gfx::Size& size); | 143 const gfx::Size& size); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Map of callback objects by sequence number. | 180 // Map of callback objects by sequence number. |
171 struct AsyncRequestInfo; | 181 struct AsyncRequestInfo; |
172 typedef std::map<int, | 182 typedef std::map<int, |
173 linked_ptr<AsyncRequestInfo> > ThumbnailCallbackMap; | 183 linked_ptr<AsyncRequestInfo> > ThumbnailCallbackMap; |
174 ThumbnailCallbackMap callback_map_; | 184 ThumbnailCallbackMap callback_map_; |
175 | 185 |
176 DISALLOW_COPY_AND_ASSIGN(ThumbnailGenerator); | 186 DISALLOW_COPY_AND_ASSIGN(ThumbnailGenerator); |
177 }; | 187 }; |
178 | 188 |
179 #endif // CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_ | 189 #endif // CHROME_BROWSER_TAB_CONTENTS_THUMBNAIL_GENERATOR_H_ |
OLD | NEW |