Home | History | Annotate | Download | only in frame
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_
      6 #define CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/compiler_specific.h"
     12 #include "ui/views/view.h"
     13 
     14 namespace content {
     15 class WebContents;
     16 }
     17 
     18 namespace gfx {
     19 class Rect;
     20 }
     21 
     22 namespace views {
     23 class WebView;
     24 };
     25 
     26 // ContentsContainer is responsible for managing the active WebContents view.
     27 // ContentsContainer has one child: the currently active WebContents.
     28 // TODO(kuan): Remove ContentsContainer since it has only one child now -
     29 // http://crbug.com/236587.
     30 class ContentsContainer : public views::View {
     31  public:
     32   // Internal class name
     33   static const char kViewClassName[];
     34 
     35   explicit ContentsContainer(views::View* active);
     36   virtual ~ContentsContainer();
     37 
     38   // Makes the overlay view the active view and nulls out the old active view.
     39   // The caller must delete or remove the old active view separately.
     40   // Called after |overlay| has been reparented to |ContentsContainer|.
     41   void SetActive(views::WebView* overlay);
     42 
     43   // Sets the active top margin; the active WebView's y origin would be
     44   // positioned at this |margin|, causing the active WebView to be pushed down
     45   // vertically by |margin| pixels in the |ContentsContainer|. Returns true
     46   // if the margin changed and this view needs Layout().
     47   bool SetActiveTopMargin(int margin);
     48 
     49   // Overridden from views::View:
     50   virtual void Layout() OVERRIDE;
     51   virtual const char* GetClassName() const OVERRIDE;
     52 
     53   // Testing interface:
     54   views::View* GetActiveWebViewForTest() { return active_; }
     55 
     56  private:
     57   views::View* active_;
     58 
     59   // The margin between the top and the active view. This is used to make the
     60   // overlay overlap the bookmark bar on the new tab page.
     61   int active_top_margin_;
     62 
     63   DISALLOW_COPY_AND_ASSIGN(ContentsContainer);
     64 };
     65 
     66 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_
     67