- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / gtk / tab_contents_container_gtk.h
1 // Copyright 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_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_
7
8 #include <gtk/gtk.h>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/ui/gtk/view_id_util.h"
13 #include "content/public/browser/web_contents_observer.h"
14 #include "ui/base/gtk/owned_widget_gtk.h"
15
16 class StatusBubbleGtk;
17
18 typedef struct _GtkFloatingContainer GtkFloatingContainer;
19
20 class TabContentsContainerGtk : protected content::WebContentsObserver,
21                                 public ViewIDUtil::Delegate {
22  public:
23   TabContentsContainerGtk(StatusBubbleGtk* status_bubble,
24                           bool embed_fullscreen_widget);
25   virtual ~TabContentsContainerGtk();
26
27   // Make the specified tab visible.
28   void SetTab(content::WebContents* tab);
29   content::WebContents* tab() const { return web_contents(); }
30
31   // Remove the tab from the hierarchy.
32   void DetachTab(content::WebContents* tab);
33
34   GtkWidget* widget() { return floating_.get(); }
35
36   // ViewIDUtil::Delegate implementation ---------------------------------------
37   virtual GtkWidget* GetWidgetForViewID(ViewID id) OVERRIDE;
38
39  private:
40   // Overridden from content::WebContentsObserver:
41   virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE;
42   virtual void DidShowFullscreenWidget(int routing_id) OVERRIDE;
43   virtual void DidDestroyFullscreenWidget(int routing_id) OVERRIDE;
44
45   // Handler for |floating_|'s "set-floating-position" signal. During this
46   // callback, we manually set the position of the status bubble.
47   static void OnSetFloatingPosition(
48       GtkFloatingContainer* container, GtkAllocation* allocation,
49       TabContentsContainerGtk* tab_contents_container);
50
51   // Helper to add the WebContents view (or fullscreen view) to |expanded_|.
52   void PackTab();
53
54   // Helper to hide the WebContents view (or fullscreen view) in |expanded_|.
55   void HideTab();
56
57   // The status bubble manager.  Always non-NULL.
58   StatusBubbleGtk* status_bubble_;
59
60   // Top of the TabContentsContainerGtk widget hierarchy. A cross between a
61   // GtkBin and a GtkFixed, |floating_| has |expanded_| as its one "real" child,
62   // and the various things that hang off the bottom (status bubble, etc) have
63   // their positions manually set in OnSetFloatingPosition.
64   ui::OwnedWidgetGtk floating_;
65
66   // We insert and remove WebContents GtkWidgets into this expanded_. This
67   // should not be a GtkVBox since there were errors with timing where the vbox
68   // was horizontally split with the top half displaying the current WebContents
69   // and bottom half displaying the loading page.
70   GtkWidget* expanded_;
71
72   // When true, TabContentsContainerGtk auto-embeds fullscreen widgets as a
73   // child view in response to DidShow/DidDestroyFullscreenWidget events.
74   bool should_embed_fullscreen_widgets_;
75
76   // Set to true while TabContentsContainerGtk is embedding a fullscreen widget
77   // view in |expanded_|, with the normal WebContentsView render view hidden.
78   bool is_embedding_fullscreen_widget_;
79
80   DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk);
81 };
82
83 #endif  // CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_