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