| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ | 6 #define CHROME_BROWSER_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "chrome/common/notification_observer.h" | 11 #include "chrome/common/notification_observer.h" |
| 12 | 12 |
| 13 class FindBarGtk; |
| 13 class RenderViewHost; | 14 class RenderViewHost; |
| 14 class TabContents; | 15 class TabContents; |
| 15 | 16 |
| 16 class TabContentsContainerGtk : public NotificationObserver { | 17 class TabContentsContainerGtk : public NotificationObserver { |
| 17 public: | 18 public: |
| 18 TabContentsContainerGtk(); | 19 TabContentsContainerGtk(); |
| 19 ~TabContentsContainerGtk(); | 20 ~TabContentsContainerGtk(); |
| 20 | 21 |
| 21 // Inserts our GtkWidget* hierarchy into a GtkBox managed by our owner. | 22 // Inserts our GtkWidget* hierarchy into a GtkBox managed by our owner. |
| 22 void AddContainerToBox(GtkWidget* widget); | 23 void AddContainerToBox(GtkWidget* widget); |
| 23 | 24 |
| 24 // Add the findbar to the top of the tab contents container. | |
| 25 void AddFindBar(GtkWidget* widget); | |
| 26 | |
| 27 // Make the specified tab visible. | 25 // Make the specified tab visible. |
| 28 void SetTabContents(TabContents* tab_contents); | 26 void SetTabContents(TabContents* tab_contents); |
| 29 TabContents* GetTabContents() const { return tab_contents_; } | 27 TabContents* GetTabContents() const { return tab_contents_; } |
| 30 | 28 |
| 31 // NotificationObserver implementation. | 29 // NotificationObserver implementation. |
| 32 virtual void Observe(NotificationType type, | 30 virtual void Observe(NotificationType type, |
| 33 const NotificationSource& source, | 31 const NotificationSource& source, |
| 34 const NotificationDetails& details); | 32 const NotificationDetails& details); |
| 35 | 33 |
| 34 void set_find_bar(FindBarGtk* findbar) { findbar_ = findbar; } |
| 35 |
| 36 private: | 36 private: |
| 37 // Add or remove observers for events that we care about. | 37 // Add or remove observers for events that we care about. |
| 38 void AddObservers(); | 38 void AddObservers(); |
| 39 void RemoveObservers(); | 39 void RemoveObservers(); |
| 40 | 40 |
| 41 // Called when the RenderViewHost of the hosted TabContents has changed, e.g. | 41 // Called when the RenderViewHost of the hosted TabContents has changed, e.g. |
| 42 // to show an interstitial page. | 42 // to show an interstitial page. |
| 43 void RenderViewHostChanged(RenderViewHost* old_host, | 43 void RenderViewHostChanged(RenderViewHost* old_host, |
| 44 RenderViewHost* new_host); | 44 RenderViewHost* new_host); |
| 45 | 45 |
| 46 // Called when a TabContents is destroyed. This gives us a chance to clean | 46 // Called when a TabContents is destroyed. This gives us a chance to clean |
| 47 // up our internal state if the TabContents is somehow destroyed before we | 47 // up our internal state if the TabContents is somehow destroyed before we |
| 48 // get notified. | 48 // get notified. |
| 49 void TabContentsDestroyed(TabContents* contents); | 49 void TabContentsDestroyed(TabContents* contents); |
| 50 | 50 |
| 51 // Called when |fixed_| changes sizes. Used to position the findbar. | |
| 52 static void OnSizeAllocate(GtkWidget* fixed, | |
| 53 GtkAllocation* allocation, | |
| 54 TabContentsContainerGtk* contents_container); | |
| 55 | |
| 56 // The currently visible TabContents. | 51 // The currently visible TabContents. |
| 57 TabContents* tab_contents_; | 52 TabContents* tab_contents_; |
| 58 | 53 |
| 59 // We keep a GtkVBox which is inserted into this object's owner's GtkWidget | 54 // We keep a GtkVBox which is inserted into this object's owner's GtkWidget |
| 60 // hierarchy. We then insert and remove WebContents GtkWidgets into this | 55 // hierarchy. We then insert and remove WebContents GtkWidgets into this |
| 61 // vbox_. | 56 // vbox_. |
| 62 GtkWidget* vbox_; | 57 GtkWidget* vbox_; |
| 63 | 58 |
| 64 // This GtkFixed widget helps us position the find bar. | 59 // We have to make sure we are always underneath the findbar, hence this |
| 65 GtkWidget* fixed_; | 60 // pointer. |
| 66 | 61 FindBarGtk* findbar_; |
| 67 // The findbar widget. We do not own it. | |
| 68 GtkWidget* findbar_; | |
| 69 | 62 |
| 70 DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk); | 63 DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk); |
| 71 }; | 64 }; |
| 72 | 65 |
| 73 #endif // CHROME_BROWSER_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ | 66 #endif // CHROME_BROWSER_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| OLD | NEW |