Update To 11.40.268.0
[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   ~ThumbnailTabHelper() override;
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   void Observe(int type,
38                const content::NotificationSource& source,
39                const content::NotificationDetails& details) override;
40
41   // content::WebContentsObserver overrides.
42   void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
43   void DidStartLoading(content::RenderViewHost* render_view_host) override;
44   void NavigationStopped() override;
45
46   // Update the thumbnail of the given tab contents if necessary.
47   void UpdateThumbnailIfNecessary(content::WebContents* web_contents);
48
49   // Called when a render view host was created for a WebContents.
50   void RenderViewHostCreated(content::RenderViewHost* renderer);
51
52   // Indicates that the given widget has changed is visibility.
53   void WidgetHidden(content::RenderWidgetHost* widget);
54
55   bool enabled_;
56
57   content::NotificationRegistrar registrar_;
58
59   bool load_interrupted_;
60
61   DISALLOW_COPY_AND_ASSIGN(ThumbnailTabHelper);
62 };
63
64 #endif  // CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_