OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_VIEWS_FRAME_CONTENTS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ |
7 | 7 |
8 #include "ui/views/view.h" | 8 #include "ui/views/view.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 class WebContents; | 11 class WebContents; |
12 } | 12 } |
13 | 13 |
| 14 namespace views { |
| 15 class WebView; |
| 16 } |
| 17 |
14 // ContentsContainer is responsible for managing the WebContents views. | 18 // ContentsContainer is responsible for managing the WebContents views. |
15 // ContentsContainer has up to two children: one for the currently active | 19 // ContentsContainer has up to two children: one for the currently active |
16 // WebContents and one for instant's WebContents. | 20 // WebContents and one for instant's WebContents. |
17 class ContentsContainer : public views::View { | 21 class ContentsContainer : public views::View { |
18 public: | 22 public: |
19 // Internal class name | 23 // Internal class name |
20 static const char kViewClassName[]; | 24 static const char kViewClassName[]; |
21 | 25 |
22 explicit ContentsContainer(views::View* active); | 26 explicit ContentsContainer(views::WebView* active); |
23 virtual ~ContentsContainer(); | 27 virtual ~ContentsContainer(); |
24 | 28 |
| 29 // Sets the active web view first in stacking order. This view is deactivated |
| 30 // when the |SearchViewController| is displaying the NTP, and activated |
| 31 // otherwise. Deactivation removes the active view from the view hierarchy. |
| 32 void SetActive(views::WebView* active); |
| 33 views::WebView* active() { return active_; } |
| 34 |
25 // Sets the overlay. The overlay is sized to the bounds of this view. | 35 // Sets the overlay. The overlay is sized to the bounds of this view. |
26 void SetOverlay(views::View* overlay); | 36 void SetOverlay(views::View* overlay); |
27 views::View* overlay() { return overlay_; } | 37 views::View* overlay() { return overlay_; } |
28 | 38 |
29 // Makes the preview view the active view and nulls out the old active view. | 39 // Makes the preview view the active view and nulls out the old active view. |
30 // It's assumed the caller will delete or remove the old active view | 40 // It's assumed the caller will delete or remove the old active view |
31 // separately. | 41 // separately. |
32 void MakePreviewContentsActiveContents(); | 42 void MakePreviewContentsActiveContents(); |
33 | 43 |
34 // Sets the preview view. This does not delete the old. | 44 // Sets the preview view. This does not delete the old. |
35 void SetPreview(views::View* preview, | 45 void SetPreview(views::WebView* preview, |
36 content::WebContents* preview_web_contents); | 46 content::WebContents* preview_web_contents); |
37 | 47 |
38 content::WebContents* preview_web_contents() const { | 48 content::WebContents* preview_web_contents() const { |
39 return preview_web_contents_; | 49 return preview_web_contents_; |
40 } | 50 } |
41 | 51 |
42 // Sets the active top margin. | 52 // Sets the active top margin. |
43 void SetActiveTopMargin(int margin); | 53 void SetActiveTopMargin(int margin); |
44 | 54 |
45 // Returns the bounds of the preview. If the preview isn't active this | 55 // Returns the bounds of the preview. If the preview isn't active this |
46 // retuns the bounds the preview would be shown at. | 56 // retuns the bounds the preview would be shown at. |
47 gfx::Rect GetPreviewBounds(); | 57 gfx::Rect GetPreviewBounds(); |
48 | 58 |
49 // View overrides: | 59 // View overrides: |
50 virtual void Layout() OVERRIDE; | 60 virtual void Layout() OVERRIDE; |
51 virtual std::string GetClassName() const OVERRIDE; | 61 virtual std::string GetClassName() const OVERRIDE; |
52 | 62 |
53 private: | 63 private: |
54 views::View* active_; | 64 views::WebView* active_; |
55 views::View* overlay_; | 65 views::View* overlay_; |
56 views::View* preview_; | 66 views::WebView* preview_; |
57 content::WebContents* preview_web_contents_; | 67 content::WebContents* preview_web_contents_; |
58 | 68 |
59 // The margin between the top and the active view. This is used to make the | 69 // The margin between the top and the active view. This is used to make the |
60 // preview overlap the bookmark bar on the new tab page. | 70 // preview overlap the bookmark bar on the new tab page. |
61 int active_top_margin_; | 71 int active_top_margin_; |
62 | 72 |
63 DISALLOW_COPY_AND_ASSIGN(ContentsContainer); | 73 DISALLOW_COPY_AND_ASSIGN(ContentsContainer); |
64 }; | 74 }; |
65 | 75 |
66 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ | 76 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ |
OLD | NEW |