| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "chrome/browser/ui/gtk/view_id_util.h" | 13 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "ui/base/gtk/gtk_signal.h" | 16 #include "ui/base/gtk/gtk_signal.h" |
| 17 #include "ui/base/gtk/owned_widget_gtk.h" | 17 #include "ui/base/gtk/owned_widget_gtk.h" |
| 18 | 18 |
| 19 class StatusBubbleGtk; | 19 class StatusBubbleGtk; |
| 20 class TabContents; | 20 class TabContents; |
| 21 typedef TabContents TabContentsWrapper; | |
| 22 | 21 |
| 23 namespace content { | 22 namespace content { |
| 24 class WebContents; | 23 class WebContents; |
| 25 } | 24 } |
| 26 | 25 |
| 27 typedef struct _GtkFloatingContainer GtkFloatingContainer; | 26 typedef struct _GtkFloatingContainer GtkFloatingContainer; |
| 28 | 27 |
| 29 class TabContentsContainerGtk : public content::NotificationObserver, | 28 class TabContentsContainerGtk : public content::NotificationObserver, |
| 30 public ViewIDUtil::Delegate { | 29 public ViewIDUtil::Delegate { |
| 31 public: | 30 public: |
| 32 explicit TabContentsContainerGtk(StatusBubbleGtk* status_bubble); | 31 explicit TabContentsContainerGtk(StatusBubbleGtk* status_bubble); |
| 33 virtual ~TabContentsContainerGtk(); | 32 virtual ~TabContentsContainerGtk(); |
| 34 | 33 |
| 35 void Init(); | 34 void Init(); |
| 36 | 35 |
| 37 // Make the specified tab visible. | 36 // Make the specified tab visible. |
| 38 void SetTab(TabContentsWrapper* tab); | 37 void SetTab(TabContents* tab); |
| 39 TabContentsWrapper* tab() const { return tab_; } | 38 TabContents* tab() const { return tab_; } |
| 40 | 39 |
| 41 // Returns the TabContentsWrapper currently displayed. | 40 // Returns the TabContents currently displayed. |
| 42 TabContentsWrapper* GetVisibleTab(); | 41 TabContents* GetVisibleTab(); |
| 43 | 42 |
| 44 bool HasPreview() const { return preview_ != NULL; } | 43 bool HasPreview() const { return preview_ != NULL; } |
| 45 | 44 |
| 46 void SetPreview(TabContentsWrapper* preview); | 45 void SetPreview(TabContents* preview); |
| 47 void PopPreview(); | 46 void PopPreview(); |
| 48 | 47 |
| 49 // Remove the tab from the hierarchy. | 48 // Remove the tab from the hierarchy. |
| 50 void DetachTab(TabContentsWrapper* tab); | 49 void DetachTab(TabContents* tab); |
| 51 | 50 |
| 52 // content::NotificationObserver implementation. | 51 // content::NotificationObserver implementation. |
| 53 virtual void Observe(int type, | 52 virtual void Observe(int type, |
| 54 const content::NotificationSource& source, | 53 const content::NotificationSource& source, |
| 55 const content::NotificationDetails& details) OVERRIDE; | 54 const content::NotificationDetails& details) OVERRIDE; |
| 56 | 55 |
| 57 GtkWidget* widget() { return floating_.get(); } | 56 GtkWidget* widget() { return floating_.get(); } |
| 58 | 57 |
| 59 // ViewIDUtil::Delegate implementation --------------------------------------- | 58 // ViewIDUtil::Delegate implementation --------------------------------------- |
| 60 virtual GtkWidget* GetWidgetForViewID(ViewID id) OVERRIDE; | 59 virtual GtkWidget* GetWidgetForViewID(ViewID id) OVERRIDE; |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 // Called when a WebContents is destroyed. This gives us a chance to clean | 62 // Called when a WebContents is destroyed. This gives us a chance to clean |
| 64 // up our internal state if the WebContents is somehow destroyed before we | 63 // up our internal state if the WebContents is somehow destroyed before we |
| 65 // get notified. | 64 // get notified. |
| 66 void WebContentsDestroyed(content::WebContents* contents); | 65 void WebContentsDestroyed(content::WebContents* contents); |
| 67 | 66 |
| 68 // Handler for |floating_|'s "set-floating-position" signal. During this | 67 // Handler for |floating_|'s "set-floating-position" signal. During this |
| 69 // callback, we manually set the position of the status bubble. | 68 // callback, we manually set the position of the status bubble. |
| 70 static void OnSetFloatingPosition( | 69 static void OnSetFloatingPosition( |
| 71 GtkFloatingContainer* container, GtkAllocation* allocation, | 70 GtkFloatingContainer* container, GtkAllocation* allocation, |
| 72 TabContentsContainerGtk* tab_contents_container); | 71 TabContentsContainerGtk* tab_contents_container); |
| 73 | 72 |
| 74 // Adds |tab| to the container and starts showing it. | 73 // Adds |tab| to the container and starts showing it. |
| 75 void PackTab(TabContentsWrapper* ); | 74 void PackTab(TabContents* tab); |
| 76 | 75 |
| 77 // Stops showing |tab|. | 76 // Stops showing |tab|. |
| 78 void HideTab(TabContentsWrapper* tab); | 77 void HideTab(TabContents* tab); |
| 79 | 78 |
| 80 // Removes |preview_|. | 79 // Removes |preview_|. |
| 81 void RemovePreview(); | 80 void RemovePreview(); |
| 82 | 81 |
| 83 // Handle focus traversal on the tab contents container. Focus should not | 82 // Handle focus traversal on the tab contents container. Focus should not |
| 84 // traverse to the preview contents. | 83 // traverse to the preview contents. |
| 85 CHROMEGTK_CALLBACK_1(TabContentsContainerGtk, gboolean, OnFocus, | 84 CHROMEGTK_CALLBACK_1(TabContentsContainerGtk, gboolean, OnFocus, |
| 86 GtkDirectionType); | 85 GtkDirectionType); |
| 87 | 86 |
| 88 content::NotificationRegistrar registrar_; | 87 content::NotificationRegistrar registrar_; |
| 89 | 88 |
| 90 // The TabContentsWrapper for the currently selected tab. This will be showing | 89 // The TabContents for the currently selected tab. This will be showing |
| 91 // unless there is a preview contents. | 90 // unless there is a preview contents. |
| 92 TabContentsWrapper* tab_; | 91 TabContents* tab_; |
| 93 | 92 |
| 94 // The current preview contents (for instant). If non-NULL, it will be | 93 // The current preview contents (for instant). If non-NULL, it will be |
| 95 // visible. | 94 // visible. |
| 96 TabContentsWrapper* preview_; | 95 TabContents* preview_; |
| 97 | 96 |
| 98 // The status bubble manager. Always non-NULL. | 97 // The status bubble manager. Always non-NULL. |
| 99 StatusBubbleGtk* status_bubble_; | 98 StatusBubbleGtk* status_bubble_; |
| 100 | 99 |
| 101 // Top of the TabContentsContainerGtk widget hierarchy. A cross between a | 100 // Top of the TabContentsContainerGtk widget hierarchy. A cross between a |
| 102 // GtkBin and a GtkFixed, |floating_| has |expanded_| as its one "real" child, | 101 // GtkBin and a GtkFixed, |floating_| has |expanded_| as its one "real" child, |
| 103 // and the various things that hang off the bottom (status bubble, etc) have | 102 // and the various things that hang off the bottom (status bubble, etc) have |
| 104 // their positions manually set in OnSetFloatingPosition. | 103 // their positions manually set in OnSetFloatingPosition. |
| 105 ui::OwnedWidgetGtk floating_; | 104 ui::OwnedWidgetGtk floating_; |
| 106 | 105 |
| 107 // We insert and remove WebContents GtkWidgets into this expanded_. This | 106 // We insert and remove WebContents GtkWidgets into this expanded_. This |
| 108 // should not be a GtkVBox since there were errors with timing where the vbox | 107 // should not be a GtkVBox since there were errors with timing where the vbox |
| 109 // was horizontally split with the top half displaying the current WebContents | 108 // was horizontally split with the top half displaying the current WebContents |
| 110 // and bottom half displaying the loading page. | 109 // and bottom half displaying the loading page. |
| 111 GtkWidget* expanded_; | 110 GtkWidget* expanded_; |
| 112 | 111 |
| 113 DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk); | 112 DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk); |
| 114 }; | 113 }; |
| 115 | 114 |
| 116 #endif // CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ | 115 #endif // CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| OLD | NEW |