| 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 "chrome/browser/ui/search/search_model_observer.h" | 10 #include "chrome/browser/ui/search/search_model_observer.h" |
| 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" |
| 11 #include "ui/compositor/layer_animation_observer.h" | 13 #include "ui/compositor/layer_animation_observer.h" |
| 12 | 14 |
| 13 class ContentsContainer; | 15 class ContentsContainer; |
| 14 class LocationBarContainer; | 16 class LocationBarContainer; |
| 15 class TabContents; | 17 class TabContents; |
| 16 | 18 |
| 17 namespace chrome { | 19 namespace chrome { |
| 18 namespace search { | 20 namespace search { |
| 19 class SearchModel; | 21 class SearchModel; |
| 20 } | 22 } |
| 21 } | 23 } |
| 22 | 24 |
| 25 namespace content { |
| 26 class BrowserContext; |
| 27 } |
| 28 |
| 23 namespace views { | 29 namespace views { |
| 24 class View; | 30 class View; |
| 31 class WebView; |
| 25 } | 32 } |
| 26 | 33 |
| 27 // SearchViewController maintains the search overlay (native new tab page). | 34 // SearchViewController maintains the search overlay (native new tab page). |
| 28 // To avoid ordering dependencies this class listens directly to the | 35 // To avoid ordering dependencies this class listens directly to the |
| 29 // SearchModel of the active tab. BrowserView is responsible for telling this | 36 // SearchModel of the active tab. BrowserView is responsible for telling this |
| 30 // class when the active tab changes. | 37 // class when the active tab changes. |
| 31 class SearchViewController | 38 class SearchViewController |
| 32 : public chrome::search::SearchModelObserver, | 39 : public chrome::search::SearchModelObserver, |
| 33 public ui::ImplicitAnimationObserver { | 40 public ui::ImplicitAnimationObserver, |
| 41 public content::NotificationObserver { |
| 34 public: | 42 public: |
| 35 explicit SearchViewController(ContentsContainer* contents_container); | 43 explicit SearchViewController(chrome::search::SearchModel* search_model, |
| 44 content::BrowserContext* browser_context, |
| 45 ContentsContainer* contents_container); |
| 36 virtual ~SearchViewController(); | 46 virtual ~SearchViewController(); |
| 37 | 47 |
| 38 views::View* omnibox_popup_view_parent(); | 48 views::View* omnibox_popup_view_parent(); |
| 39 | 49 |
| 40 void set_location_bar_container( | 50 void set_location_bar_container( |
| 41 LocationBarContainer* location_bar_container) { | 51 LocationBarContainer* location_bar_container) { |
| 42 location_bar_container_ = location_bar_container; | 52 location_bar_container_ = location_bar_container; |
| 43 } | 53 } |
| 44 | 54 |
| 45 // Sets the active tab. | 55 // Sets the active tab. |
| 46 void SetTabContents(TabContents* tab); | 56 void SetTabContents(TabContents* tab_contents); |
| 47 | 57 |
| 48 // Stacks the overlay at the top. | 58 // Stacks the overlay at the top. |
| 49 void StackAtTop(); | 59 void StackAtTop(); |
| 50 | 60 |
| 51 // Invoked when the instant preview is ready to be shown. | 61 // Invoked when the instant preview is ready to be shown. |
| 52 void InstantReady(); | 62 void InstantReady(); |
| 53 | 63 |
| 54 // chrome::search::SearchModelObserver overrides: | 64 // chrome::search::SearchModelObserver overrides: |
| 55 virtual void ModeChanged(const chrome::search::Mode& mode) OVERRIDE; | 65 virtual void ModeChanged(const chrome::search::Mode& mode) OVERRIDE; |
| 56 | 66 |
| 57 // ui::ImplicitAnimationObserver overrides: | 67 // ui::ImplicitAnimationObserver overrides: |
| 58 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | 68 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
| 59 | 69 |
| 70 // content::NotificationObserver overrides. |
| 71 virtual void Observe(int type, |
| 72 const content::NotificationSource& source, |
| 73 const content::NotificationDetails& details) OVERRIDE; |
| 60 private: | 74 private: |
| 61 enum State { | 75 enum State { |
| 62 // Search/ntp is not visible. | 76 // Search/ntp is not visible. |
| 63 STATE_NOT_VISIBLE, | 77 STATE_NOT_VISIBLE, |
| 64 | 78 |
| 65 // Layout for the new tab page. | 79 // Layout for the new tab page. |
| 66 STATE_NTP, | 80 STATE_NTP, |
| 67 | 81 |
| 68 // Animating between STATE_NTP and STATE_SEARCH. | 82 // Animating between STATE_NTP and STATE_SEARCH. |
| 69 STATE_ANIMATING, | 83 STATE_ANIMATING, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 // Create the various views and installs them as an overlay on | 102 // Create the various views and installs them as an overlay on |
| 89 // |contents_container_|. | 103 // |contents_container_|. |
| 90 void CreateViews(); | 104 void CreateViews(); |
| 91 | 105 |
| 92 // Destroys the various views. | 106 // Destroys the various views. |
| 93 void DestroyViews(); | 107 void DestroyViews(); |
| 94 | 108 |
| 95 // Invoked when the visibility of the omnibox popup changes. | 109 // Invoked when the visibility of the omnibox popup changes. |
| 96 void PopupVisibilityChanged(); | 110 void PopupVisibilityChanged(); |
| 97 | 111 |
| 98 // Returns the SearchModel for the current tab, or NULL if there | 112 // The browser's search model. Weak. |
| 99 // is no current tab. | 113 chrome::search::SearchModel* search_model_; |
| 100 chrome::search::SearchModel* search_model(); | |
| 101 | 114 |
| 102 // Where the overlay is placed. | 115 // The profile. Weak. |
| 116 content::BrowserContext* browser_context_; |
| 117 |
| 118 // Where the overlay is placed. Weak. |
| 103 ContentsContainer* contents_container_; | 119 ContentsContainer* contents_container_; |
| 104 | 120 |
| 121 // Weak. |
| 105 LocationBarContainer* location_bar_container_; | 122 LocationBarContainer* location_bar_container_; |
| 106 | 123 |
| 107 State state_; | 124 State state_; |
| 108 | 125 |
| 109 // The active TabContents; may be NULL. | |
| 110 TabContents* tab_; | |
| 111 | |
| 112 // The following views are created to render the NTP. Visually they look | 126 // The following views are created to render the NTP. Visually they look |
| 113 // something like: | 127 // something like: |
| 114 // | 128 // |
| 115 // |---SearchContainerView------------------------------| | 129 // |---SearchContainerView------------------------------| |
| 116 // ||-----NTPView & OmniboxPopupViewParent-------------|| | 130 // ||-----NTPView & OmniboxPopupViewParent-------------|| |
| 117 // || || | 131 // || || |
| 118 // || |--LogoView----------------------------| || | 132 // || |--LogoView----------------------------| || |
| 119 // || | | || | 133 // || | | || |
| 120 // || | | || | 134 // || | | || |
| 121 // || |--------------------------------------| || | 135 // || |--------------------------------------| || |
| (...skipping 12 matching lines...) Expand all Loading... |
| 134 // of any of these views. | 148 // of any of these views. |
| 135 // | 149 // |
| 136 // NTPView and OmniboxPopupViewParent are siblings. When on the NTP the | 150 // NTPView and OmniboxPopupViewParent are siblings. When on the NTP the |
| 137 // OmniboxPopupViewParent is obscured by the NTPView. When on a search page | 151 // OmniboxPopupViewParent is obscured by the NTPView. When on a search page |
| 138 // the NTPView is hidden. | 152 // the NTPView is hidden. |
| 139 // | 153 // |
| 140 // | 154 // |
| 141 views::View* search_container_; | 155 views::View* search_container_; |
| 142 views::View* ntp_view_; | 156 views::View* ntp_view_; |
| 143 views::View* logo_view_; | 157 views::View* logo_view_; |
| 144 views::View* content_view_; | 158 views::WebView* content_view_; |
| 145 OmniboxPopupViewParent* omnibox_popup_view_parent_; | 159 OmniboxPopupViewParent* omnibox_popup_view_parent_; |
| 146 | 160 |
| 161 // A scoped notification registrar. |
| 162 content::NotificationRegistrar registrar_; |
| 163 |
| 147 DISALLOW_COPY_AND_ASSIGN(SearchViewController); | 164 DISALLOW_COPY_AND_ASSIGN(SearchViewController); |
| 148 }; | 165 }; |
| 149 | 166 |
| 150 #endif // CHROME_BROWSER_UI_VIEWS_SEARCH_VIEW_CONTROLLER_H_ | 167 #endif // CHROME_BROWSER_UI_VIEWS_SEARCH_VIEW_CONTROLLER_H_ |
| OLD | NEW |