| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_VIEWS_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_VIEWS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h" | |
| 10 #include "chrome/common/notification_observer.h" | 9 #include "chrome/common/notification_observer.h" |
| 11 #include "chrome/common/notification_registrar.h" | 10 #include "chrome/common/notification_registrar.h" |
| 12 #include "views/view.h" | 11 #include "views/view.h" |
| 13 | 12 |
| 14 class NativeTabContentsContainer; | 13 class NativeTabContentsContainer; |
| 15 class RenderViewHost; | 14 class RenderViewHost; |
| 16 class RenderWidgetHostView; | 15 class RenderWidgetHostView; |
| 17 class TabContents; | 16 class TabContents; |
| 18 | 17 |
| 19 class TabContentsContainer : public views::View, | 18 class TabContentsContainer : public views::View, |
| 20 public NotificationObserver { | 19 public NotificationObserver { |
| 21 public: | 20 public: |
| 22 TabContentsContainer(); | 21 TabContentsContainer(); |
| 23 virtual ~TabContentsContainer(); | 22 virtual ~TabContentsContainer(); |
| 24 | 23 |
| 25 // Changes the TabContents associated with this view. | 24 // Changes the TabContents associated with this view. |
| 26 void ChangeTabContents(TabContents* contents); | 25 void ChangeTabContents(TabContents* contents); |
| 27 | 26 |
| 28 View* GetFocusView() { return native_container_->GetView(); } | 27 View* GetFocusView() { return this; } |
| 29 | 28 |
| 30 // Accessor for |tab_contents_|. | 29 // Accessor for |tab_contents_|. |
| 31 TabContents* tab_contents() const { return tab_contents_; } | 30 TabContents* tab_contents() const { return tab_contents_; } |
| 32 | 31 |
| 33 // Called by the BrowserView to notify that |tab_contents| got the focus. | 32 // Called by the BrowserView to notify that |tab_contents| got the focus. |
| 34 void TabContentsFocused(TabContents* tab_contents); | 33 void TabContentsFocused(TabContents* tab_contents); |
| 35 | 34 |
| 36 // Tells the container to update less frequently during resizing operations | 35 // Tells the container to update less frequently during resizing operations |
| 37 // so performance is better. | 36 // so performance is better. |
| 38 void SetFastResize(bool fast_resize); | 37 void SetFastResize(bool fast_resize); |
| 39 | 38 |
| 40 // Updates the current reserved rect in view coordinates where contents | 39 // Updates the current reserved rect in view coordinates where contents |
| 41 // should not be rendered to draw the resize corner, sidebar mini tabs etc. | 40 // should not be rendered to draw the resize corner, sidebar mini tabs etc. |
| 42 void SetReservedContentsRect(const gfx::Rect& reserved_rect); | 41 void SetReservedContentsRect(const gfx::Rect& reserved_rect); |
| 43 | 42 |
| 44 // Overridden from NotificationObserver: | 43 // Overridden from NotificationObserver: |
| 45 virtual void Observe(NotificationType type, | 44 virtual void Observe(NotificationType type, |
| 46 const NotificationSource& source, | 45 const NotificationSource& source, |
| 47 const NotificationDetails& details); | 46 const NotificationDetails& details); |
| 48 | 47 |
| 49 // Overridden from views::View: | |
| 50 virtual void Layout(); | |
| 51 virtual AccessibilityTypes::Role GetAccessibleRole(); | 48 virtual AccessibilityTypes::Role GetAccessibleRole(); |
| 52 | 49 |
| 53 protected: | |
| 54 // Overridden from views::View: | |
| 55 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, | |
| 56 views::View* child); | |
| 57 | |
| 58 private: | 50 private: |
| 59 // Add or remove observers for events that we care about. | 51 // Add or remove observers for events that we care about. |
| 60 void AddObservers(); | 52 void AddObservers(); |
| 61 void RemoveObservers(); | 53 void RemoveObservers(); |
| 62 | 54 |
| 63 // Called when the RenderViewHost of the hosted TabContents has changed, e.g. | 55 // Called when the RenderViewHost of the hosted TabContents has changed, e.g. |
| 64 // to show an interstitial page. | 56 // to show an interstitial page. |
| 65 void RenderViewHostChanged(RenderViewHost* old_host, | 57 void RenderViewHostChanged(RenderViewHost* old_host, |
| 66 RenderViewHost* new_host); | 58 RenderViewHost* new_host); |
| 67 | 59 |
| 68 // Called when a TabContents is destroyed. This gives us a chance to clean | 60 // Called when a TabContents is destroyed. This gives us a chance to clean |
| 69 // up our internal state if the TabContents is somehow destroyed before we | 61 // up our internal state if the TabContents is somehow destroyed before we |
| 70 // get notified. | 62 // get notified. |
| 71 void TabContentsDestroyed(TabContents* contents); | 63 void TabContentsDestroyed(TabContents* contents); |
| 72 | 64 |
| 73 // Called when the RenderWidgetHostView of the hosted TabContents has changed. | 65 // Called when the RenderWidgetHostView of the hosted TabContents has changed. |
| 74 void RenderWidgetHostViewChanged(RenderWidgetHostView* new_view); | 66 void RenderWidgetHostViewChanged(RenderWidgetHostView* new_view); |
| 75 | 67 |
| 76 // An instance of a NativeTabContentsContainer object that holds the native | |
| 77 // view handle associated with the attached TabContents. | |
| 78 NativeTabContentsContainer* native_container_; | |
| 79 | |
| 80 // The attached TabContents. | 68 // The attached TabContents. |
| 81 TabContents* tab_contents_; | 69 TabContents* tab_contents_; |
| 82 | 70 |
| 83 // Handles registering for our notifications. | 71 // Handles registering for our notifications. |
| 84 NotificationRegistrar registrar_; | 72 NotificationRegistrar registrar_; |
| 85 | 73 |
| 86 // The current reserved rect in view coordinates where contents should not be | 74 // The current reserved rect in view coordinates where contents should not be |
| 87 // rendered to draw the resize corner, sidebar mini tabs etc. | 75 // rendered to draw the resize corner, sidebar mini tabs etc. |
| 88 // Cached here to update ever changing renderers. | 76 // Cached here to update ever changing renderers. |
| 89 gfx::Rect cached_reserved_rect_; | 77 gfx::Rect cached_reserved_rect_; |
| 90 | 78 |
| 91 DISALLOW_COPY_AND_ASSIGN(TabContentsContainer); | 79 DISALLOW_COPY_AND_ASSIGN(TabContentsContainer); |
| 92 }; | 80 }; |
| 93 | 81 |
| 94 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_ | 82 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_VIEWS_H_ |
| OLD | NEW |