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