| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/common/instant_types.h" | 12 #include "chrome/common/instant_types.h" |
| 13 #include "chrome/common/search_types.h" |
| 13 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 class WebContents; | 17 class WebContents; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace gfx { | 20 namespace gfx { |
| 20 class Rect; | 21 class Rect; |
| 21 } | 22 } |
| 22 | 23 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 explicit ContentsContainer(views::WebView* active); | 36 explicit ContentsContainer(views::WebView* active); |
| 36 virtual ~ContentsContainer(); | 37 virtual ~ContentsContainer(); |
| 37 | 38 |
| 38 // 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. |
| 39 // The caller must delete or remove the old active view separately. | 40 // The caller must delete or remove the old active view separately. |
| 40 void MakePreviewContentsActiveContents(); | 41 void MakePreviewContentsActiveContents(); |
| 41 | 42 |
| 42 // Sets the preview view. This does not delete the old. | 43 // Sets the preview view. This does not delete the old. |
| 43 void SetPreview(views::WebView* preview, | 44 void SetPreview(views::WebView* preview, |
| 44 content::WebContents* preview_web_contents, | 45 content::WebContents* preview_web_contents, |
| 46 const chrome::search::Mode& search_mode, |
| 45 int height, | 47 int height, |
| 46 InstantSizeUnits units, | 48 InstantSizeUnits units, |
| 47 bool draw_drop_shadow); | 49 bool draw_drop_shadow); |
| 48 | 50 |
| 49 // When the active content is reset and we have a visible preview, | 51 // When the active content is reset and we have a visible preview, |
| 50 // the preview must be stacked back at top. | 52 // the preview must be stacked back at top. |
| 51 void MaybeStackPreviewAtTop(); | 53 void MaybeStackPreviewAtTop(); |
| 52 | 54 |
| 53 content::WebContents* preview_web_contents() const { | 55 content::WebContents* preview_web_contents() const { |
| 54 return preview_web_contents_; | 56 return preview_web_contents_; |
| 55 } | 57 } |
| 56 | 58 |
| 57 // Sets the active top margin. | 59 // Sets the active top margin. |
| 58 void SetActiveTopMargin(int margin); | 60 void SetActiveTopMargin(int margin); |
| 59 | 61 |
| 60 // Returns the bounds the preview would be shown at. | 62 // Returns the bounds the preview would be shown at. |
| 61 gfx::Rect GetPreviewBounds() const; | 63 gfx::Rect GetPreviewBounds() const; |
| 62 | 64 |
| 63 // Set/Get an extra content height, so that room is left at the bottom of the | |
| 64 // contents view for other views to draw on top of the extended child web | |
| 65 // view. Note that this doesn't cause a layout invalidation, it's up to the | |
| 66 // caller to make sure that a Layout() will be done so that the | |
| 67 // |extra_content_height_| gets taken into account. | |
| 68 int extra_content_height() const { return extra_content_height_; } | |
| 69 void SetExtraContentHeight(int height); | |
| 70 | |
| 71 // Returns true if preview occupies full height of content page. | 65 // Returns true if preview occupies full height of content page. |
| 72 bool IsPreviewFullHeight(int preview_height, | 66 bool IsPreviewFullHeight(int preview_height, |
| 73 InstantSizeUnits preview_height_units) const; | 67 InstantSizeUnits preview_height_units) const; |
| 74 | 68 |
| 75 private: | 69 private: |
| 76 // Returns true if |shadow_view_| was a child of |ContentsContainer| and | 70 // Returns true if |shadow_view_| was a child of |ContentsContainer| and |
| 77 // successfully removed from view hierarchy. | 71 // successfully removed from view hierarchy. |
| 78 // If |delete_view| is true, |shadow_view_| is deleted regardless if it is a | 72 // If |delete_view| is true, |shadow_view_| is deleted regardless if it is a |
| 79 // child of |ContentsContainer|. | 73 // child of |ContentsContainer|. |
| 80 bool RemoveShadowView(bool delete_view); | 74 bool RemoveShadowView(bool delete_view); |
| 81 | 75 |
| 82 // Overridden from views::View: | 76 // Overridden from views::View: |
| 83 virtual void Layout() OVERRIDE; | 77 virtual void Layout() OVERRIDE; |
| 84 virtual std::string GetClassName() const OVERRIDE; | 78 virtual std::string GetClassName() const OVERRIDE; |
| 85 | 79 |
| 86 views::WebView* active_; | 80 views::WebView* active_; |
| 87 views::WebView* preview_; | 81 views::WebView* preview_; |
| 88 scoped_ptr<views::View> shadow_view_; | 82 scoped_ptr<views::View> shadow_view_; |
| 89 content::WebContents* preview_web_contents_; | 83 content::WebContents* preview_web_contents_; |
| 84 chrome::search::Mode search_mode_; |
| 90 bool draw_drop_shadow_; | 85 bool draw_drop_shadow_; |
| 91 | 86 |
| 92 // The margin between the top and the active view. This is used to make the | 87 // The margin between the top and the active view. This is used to make the |
| 93 // preview overlap the bookmark bar on the new tab page. | 88 // preview overlap the bookmark bar on the new tab page. |
| 94 int active_top_margin_; | 89 int active_top_margin_; |
| 95 | 90 |
| 96 // The desired height of the preview and units. | 91 // The desired height of the preview and units. |
| 97 int preview_height_; | 92 int preview_height_; |
| 98 InstantSizeUnits preview_height_units_; | 93 InstantSizeUnits preview_height_units_; |
| 99 | 94 |
| 100 // Used to extend the child WebView beyond the contents view bottom bound. | |
| 101 int extra_content_height_; | |
| 102 | |
| 103 DISALLOW_COPY_AND_ASSIGN(ContentsContainer); | 95 DISALLOW_COPY_AND_ASSIGN(ContentsContainer); |
| 104 }; | 96 }; |
| 105 | 97 |
| 106 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ | 98 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ |
| OLD | NEW |