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