OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "chrome/browser/thumbnails/thumbnailing_context.h" | 9 #include "chrome/browser/thumbnails/thumbnailing_context.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
13 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class RenderViewHost; | 16 class RenderViewHost; |
17 class RenderWidgetHost; | 17 class RenderWidgetHost; |
18 } | 18 } |
19 | 19 |
20 class ThumbnailTabHelper | 20 class ThumbnailTabHelper |
21 : public content::NotificationObserver, | 21 : public content::NotificationObserver, |
22 public content::WebContentsObserver, | 22 public content::WebContentsObserver, |
23 public content::WebContentsUserData<ThumbnailTabHelper> { | 23 public content::WebContentsUserData<ThumbnailTabHelper> { |
24 public: | 24 public: |
25 virtual ~ThumbnailTabHelper(); | 25 ~ThumbnailTabHelper() override; |
26 | 26 |
27 // Enables or disables the function of taking thumbnails. | 27 // Enables or disables the function of taking thumbnails. |
28 // A disabled ThumbnailTabHelper generates no thumbnails although it still | 28 // A disabled ThumbnailTabHelper generates no thumbnails although it still |
29 // continues to receive the notifications from the web contents. | 29 // continues to receive the notifications from the web contents. |
30 void set_enabled(bool enabled) { enabled_ = enabled; } | 30 void set_enabled(bool enabled) { enabled_ = enabled; } |
31 | 31 |
32 private: | 32 private: |
33 explicit ThumbnailTabHelper(content::WebContents* contents); | 33 explicit ThumbnailTabHelper(content::WebContents* contents); |
34 friend class content::WebContentsUserData<ThumbnailTabHelper>; | 34 friend class content::WebContentsUserData<ThumbnailTabHelper>; |
35 | 35 |
36 // content::NotificationObserver overrides. | 36 // content::NotificationObserver overrides. |
37 virtual void Observe(int type, | 37 void Observe(int type, |
38 const content::NotificationSource& source, | 38 const content::NotificationSource& source, |
39 const content::NotificationDetails& details) override; | 39 const content::NotificationDetails& details) override; |
40 | 40 |
41 // content::WebContentsObserver overrides. | 41 // content::WebContentsObserver overrides. |
42 virtual void RenderViewDeleted( | 42 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; |
43 content::RenderViewHost* render_view_host) override; | 43 void DidStartLoading(content::RenderViewHost* render_view_host) override; |
44 virtual void DidStartLoading( | 44 void NavigationStopped() override; |
45 content::RenderViewHost* render_view_host) override; | |
46 virtual void NavigationStopped() override; | |
47 | 45 |
48 // Update the thumbnail of the given tab contents if necessary. | 46 // Update the thumbnail of the given tab contents if necessary. |
49 void UpdateThumbnailIfNecessary(content::WebContents* web_contents); | 47 void UpdateThumbnailIfNecessary(content::WebContents* web_contents); |
50 | 48 |
51 // Called when a render view host was created for a WebContents. | 49 // Called when a render view host was created for a WebContents. |
52 void RenderViewHostCreated(content::RenderViewHost* renderer); | 50 void RenderViewHostCreated(content::RenderViewHost* renderer); |
53 | 51 |
54 // Indicates that the given widget has changed is visibility. | 52 // Indicates that the given widget has changed is visibility. |
55 void WidgetHidden(content::RenderWidgetHost* widget); | 53 void WidgetHidden(content::RenderWidgetHost* widget); |
56 | 54 |
57 bool enabled_; | 55 bool enabled_; |
58 | 56 |
59 content::NotificationRegistrar registrar_; | 57 content::NotificationRegistrar registrar_; |
60 | 58 |
61 bool load_interrupted_; | 59 bool load_interrupted_; |
62 | 60 |
63 DISALLOW_COPY_AND_ASSIGN(ThumbnailTabHelper); | 61 DISALLOW_COPY_AND_ASSIGN(ThumbnailTabHelper); |
64 }; | 62 }; |
65 | 63 |
66 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_ | 64 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_ |
OLD | NEW |