- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / thumbnails / thumbnail_tab_helper.h
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.
4
5 #ifndef CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_
6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_
7
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"
14
15 namespace content {
16 class RenderViewHost;
17 class RenderWidgetHost;
18 }
19
20 class ThumbnailTabHelper
21     : public content::NotificationObserver,
22       public content::WebContentsObserver,
23       public content::WebContentsUserData<ThumbnailTabHelper> {
24  public:
25   virtual ~ThumbnailTabHelper();
26
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; }
31
32  private:
33   explicit ThumbnailTabHelper(content::WebContents* contents);
34   friend class content::WebContentsUserData<ThumbnailTabHelper>;
35
36   // content::NotificationObserver overrides.
37   virtual void Observe(int type,
38                        const content::NotificationSource& source,
39                        const content::NotificationDetails& details) OVERRIDE;
40
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;
47
48   // Update the thumbnail of the given tab contents if necessary.
49   void UpdateThumbnailIfNecessary(content::WebContents* web_contents);
50
51   // Called when a render view host was created for a WebContents.
52   void RenderViewHostCreated(content::RenderViewHost* renderer);
53
54   // Indicates that the given widget has changed is visibility.
55   void WidgetHidden(content::RenderWidgetHost* widget);
56
57   bool enabled_;
58
59   content::NotificationRegistrar registrar_;
60
61   bool load_interrupted_;
62
63   DISALLOW_COPY_AND_ASSIGN(ThumbnailTabHelper);
64 };
65
66 #endif  // CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_