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