| 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_SEARCH_VIEW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_SEARCH_VIEW_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_SEARCH_VIEW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_SEARCH_VIEW_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/ui/search/search_model_observer.h" | 11 #include "chrome/browser/ui/search/search_model_observer.h" |
| 11 #include "ui/compositor/layer_animation_observer.h" | 12 #include "ui/compositor/layer_animation_observer.h" |
| 12 | 13 |
| 13 class ContentsContainer; | 14 class ContentsContainer; |
| 14 class LocationBarContainer; | 15 class LocationBarContainer; |
| 15 class TabContents; | 16 class TabContents; |
| 16 | 17 |
| 17 namespace chrome { | 18 namespace chrome { |
| 18 namespace search { | 19 namespace search { |
| 19 class SearchModel; | 20 class SearchModel; |
| 20 } | 21 } |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 class BrowserContext; | 25 class BrowserContext; |
| 25 class WebContents; | 26 class WebContents; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace views { | 29 namespace views { |
| 30 class ImageView; |
| 31 class Label; |
| 29 class View; | 32 class View; |
| 30 class WebView; | 33 class WebView; |
| 31 } | 34 } |
| 32 | 35 |
| 33 // SearchViewController maintains the search overlay (native new tab page). | 36 // SearchViewController maintains the search overlay (native new tab page). |
| 34 // To avoid ordering dependencies this class listens directly to the | 37 // To avoid ordering dependencies this class listens directly to the |
| 35 // SearchModel of the active tab. BrowserView is responsible for telling this | 38 // SearchModel of the active tab. BrowserView is responsible for telling this |
| 36 // class when the active tab changes. | 39 // class when the active tab changes. |
| 37 class SearchViewController | 40 class SearchViewController |
| 38 : public chrome::search::SearchModelObserver, | 41 : public chrome::search::SearchModelObserver, |
| 39 public ui::ImplicitAnimationObserver { | 42 public ui::ImplicitAnimationObserver { |
| 40 public: | 43 public: |
| 41 explicit SearchViewController(ContentsContainer* contents_container); | 44 SearchViewController(content::BrowserContext* browser_context, |
| 45 ContentsContainer* contents_container); |
| 42 virtual ~SearchViewController(); | 46 virtual ~SearchViewController(); |
| 43 | 47 |
| 44 views::View* omnibox_popup_view_parent(); | 48 views::View* omnibox_popup_view_parent(); |
| 45 | 49 |
| 46 void set_location_bar_container( | 50 void set_location_bar_container( |
| 47 LocationBarContainer* location_bar_container) { | 51 LocationBarContainer* location_bar_container) { |
| 48 location_bar_container_ = location_bar_container; | 52 location_bar_container_ = location_bar_container; |
| 49 } | 53 } |
| 50 | 54 |
| 51 // Sets the active tab. | 55 // Sets the active tab. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // from the current state of the SearchModel. | 93 // from the current state of the SearchModel. |
| 90 void SetState(State state); | 94 void SetState(State state); |
| 91 | 95 |
| 92 // Starts the animation. | 96 // Starts the animation. |
| 93 void StartAnimation(); | 97 void StartAnimation(); |
| 94 | 98 |
| 95 // Create the various views and installs them as an overlay on | 99 // Create the various views and installs them as an overlay on |
| 96 // |contents_container_|. | 100 // |contents_container_|. |
| 97 void CreateViews(); | 101 void CreateViews(); |
| 98 | 102 |
| 103 // Returns the logo image view, or a name label if an image is not available. |
| 104 views::View* GetLogoView() const; |
| 105 |
| 99 // Destroys the various views. | 106 // Destroys the various views. |
| 100 void DestroyViews(); | 107 void DestroyViews(); |
| 101 | 108 |
| 102 // Invoked when the visibility of the omnibox popup changes. | 109 // Invoked when the visibility of the omnibox popup changes. |
| 103 void PopupVisibilityChanged(); | 110 void PopupVisibilityChanged(); |
| 104 | 111 |
| 105 // Access active search model. | 112 // Access active search model. |
| 106 chrome::search::SearchModel* search_model(); | 113 chrome::search::SearchModel* search_model(); |
| 107 | 114 |
| 108 // Access active web contents. | 115 // Access active web contents. |
| 109 content::WebContents* web_contents(); | 116 content::WebContents* web_contents(); |
| 110 | 117 |
| 118 // The profile. Weak. |
| 119 content::BrowserContext* browser_context_; |
| 120 |
| 111 // Where the overlay is placed. Weak. | 121 // Where the overlay is placed. Weak. |
| 112 ContentsContainer* contents_container_; | 122 ContentsContainer* contents_container_; |
| 113 | 123 |
| 114 // Weak. | 124 // Weak. |
| 115 LocationBarContainer* location_bar_container_; | 125 LocationBarContainer* location_bar_container_; |
| 116 | 126 |
| 117 State state_; | 127 State state_; |
| 118 | 128 |
| 119 // The active TabContents. Weak. May be NULL. | 129 // The active TabContents. Weak. May be NULL. |
| 120 TabContents* tab_contents_; | 130 TabContents* tab_contents_; |
| 121 | 131 |
| 122 // The following views are created to render the NTP. Visually they look | 132 // The following views are created to render the NTP. Visually they look |
| 123 // something like: | 133 // something like: |
| 124 // | 134 // |
| 125 // |---SearchContainerView------------------------------| | 135 // |---SearchContainerView------------------------------| |
| 126 // ||-----NTPView & OmniboxPopupViewParent-------------|| | 136 // ||-----NTPView & OmniboxPopupViewParent-------------|| |
| 127 // || || | 137 // || || |
| 128 // || |--LogoView----------------------------| || | 138 // || |--Logo or Name------------------------| || |
| 129 // || | | || | 139 // || | | || |
| 130 // || | | || | 140 // || | | || |
| 131 // || |--------------------------------------| || | 141 // || |--------------------------------------| || |
| 132 // || || | 142 // || || |
| 133 // || * || | 143 // || * || |
| 134 // || || | 144 // || || |
| 135 // || |--ContentView-------------------------| || | 145 // || |--ContentView-------------------------| || |
| 136 // || | | || | 146 // || | | || |
| 137 // || | | || | 147 // || | | || |
| 138 // || |--------------------------------------| || | 148 // || |--------------------------------------| || |
| 139 // || || | 149 // || || |
| 140 // ||--------------------------------------------------|| | 150 // ||--------------------------------------------------|| |
| 141 // |----------------------------------------------------| | 151 // |----------------------------------------------------| |
| 142 // | 152 // |
| 143 // * - the LocationBarContainer gets positioned here, but it is not a child | 153 // * - the LocationBarContainer gets positioned here, but it is not a child |
| 144 // of any of these views. | 154 // of any of these views. |
| 145 // | 155 // |
| 146 // NTPView and OmniboxPopupViewParent are siblings. When on the NTP the | 156 // NTPView and OmniboxPopupViewParent are siblings. When on the NTP the |
| 147 // OmniboxPopupViewParent is obscured by the NTPView. When on a search page | 157 // OmniboxPopupViewParent is obscured by the NTPView. When on a search page |
| 148 // the NTPView is hidden. | 158 // the NTPView is hidden. |
| 149 // | 159 // |
| 150 // | 160 // |
| 151 views::View* search_container_; | 161 views::View* search_container_; |
| 152 views::View* ntp_view_; | 162 views::View* ntp_view_; |
| 153 views::View* logo_view_; | 163 // The default provider's logo, may be NULL. |
| 154 | 164 scoped_ptr<views::ImageView> default_provider_logo_; |
| 165 // The default provider's name. Used as a fallback if the logo is NULL. |
| 166 scoped_ptr<views::Label> default_provider_name_; |
| 155 // An alias to |contents_container_->active()|, but reparented within | 167 // An alias to |contents_container_->active()|, but reparented within |
| 156 // |ntp_view_| when in the NTP state. | 168 // |ntp_view_| when in the NTP state. |
| 157 views::WebView* content_view_; | 169 views::WebView* content_view_; |
| 158 | 170 |
| 159 OmniboxPopupViewParent* omnibox_popup_view_parent_; | 171 OmniboxPopupViewParent* omnibox_popup_view_parent_; |
| 160 | 172 |
| 161 DISALLOW_COPY_AND_ASSIGN(SearchViewController); | 173 DISALLOW_COPY_AND_ASSIGN(SearchViewController); |
| 162 }; | 174 }; |
| 163 | 175 |
| 164 #endif // CHROME_BROWSER_UI_VIEWS_SEARCH_VIEW_CONTROLLER_H_ | 176 #endif // CHROME_BROWSER_UI_VIEWS_SEARCH_VIEW_CONTROLLER_H_ |
| OLD | NEW |