| 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_SEARCH_SEARCH_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_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 "chrome/browser/ui/search/toolbar_search_animator.h" | 11 #include "chrome/browser/ui/search/toolbar_search_animator.h" |
| 12 | 12 |
| 13 class TabContents; | |
| 14 class ToolbarModel; | 13 class ToolbarModel; |
| 15 | 14 |
| 15 namespace content { |
| 16 class WebContents; |
| 17 } |
| 18 |
| 16 namespace chrome { | 19 namespace chrome { |
| 17 namespace search { | 20 namespace search { |
| 18 | 21 |
| 19 class SearchModel; | 22 class SearchModel; |
| 20 | 23 |
| 21 // The SearchDelegate class acts as a helper to the Browser class. | 24 // The SearchDelegate class acts as a helper to the Browser class. |
| 22 // It is responsible for routing the changes from the active tab's | 25 // It is responsible for routing the changes from the active tab's |
| 23 // SearchModel through to the toolbar, tabstrip and other UI | 26 // SearchModel through to the toolbar, tabstrip and other UI |
| 24 // observers. | 27 // observers. |
| 25 // Changes are propagated from the active tab's model via this class to the | 28 // Changes are propagated from the active tab's model via this class to the |
| 26 // Browser-level model. | 29 // Browser-level model. |
| 27 class SearchDelegate : public SearchModelObserver { | 30 class SearchDelegate : public SearchModelObserver { |
| 28 public: | 31 public: |
| 29 SearchDelegate(SearchModel* browser_search_model, | 32 SearchDelegate(SearchModel* browser_search_model, |
| 30 ToolbarModel* toolbar_model); | 33 ToolbarModel* toolbar_model); |
| 31 virtual ~SearchDelegate(); | 34 virtual ~SearchDelegate(); |
| 32 | 35 |
| 33 // Overrides for SearchModelObserver: | 36 // Overrides for SearchModelObserver: |
| 34 virtual void ModeChanged(const Mode& old_mode, const Mode& new_mode) OVERRIDE; | 37 virtual void ModeChanged(const Mode& old_mode, const Mode& new_mode) OVERRIDE; |
| 35 | 38 |
| 36 // When the active tab is changed, the model state of this new active tab is | 39 // When the active tab is changed, the model state of this new active tab is |
| 37 // propagated to the browser. | 40 // propagated to the browser. |
| 38 void OnTabActivated(TabContents* contents); | 41 void OnTabActivated(content::WebContents* web_contents); |
| 39 | 42 |
| 40 // When a tab is deactivated, this class no longer observes changes to the | 43 // When a tab is deactivated, this class no longer observes changes to the |
| 41 // tab's model. | 44 // tab's model. |
| 42 void OnTabDeactivated(TabContents* contents); | 45 void OnTabDeactivated(content::WebContents* web_contents); |
| 43 | 46 |
| 44 // When a tab is detached, this class no longer observes changes to the | 47 // When a tab is detached, this class no longer observes changes to the |
| 45 // tab's model. | 48 // tab's model. |
| 46 void OnTabDetached(TabContents* contents); | 49 void OnTabDetached(content::WebContents* web_contents); |
| 47 | 50 |
| 48 ToolbarSearchAnimator& toolbar_search_animator() { | 51 ToolbarSearchAnimator& toolbar_search_animator() { |
| 49 return toolbar_search_animator_; | 52 return toolbar_search_animator_; |
| 50 } | 53 } |
| 51 | 54 |
| 52 private: | 55 private: |
| 53 // Stop observing tab. | 56 // Stop observing tab. |
| 54 void StopObserveringTab(TabContents* contents); | 57 void StopObservingTab(content::WebContents* web_contents); |
| 55 | 58 |
| 56 // Weak. The Browser class owns this. The active |tab_model_| state is | 59 // Weak. The Browser class owns this. The active |tab_model_| state is |
| 57 // propagated to the |browser_model_|. | 60 // propagated to the |browser_model_|. |
| 58 SearchModel* browser_model_; | 61 SearchModel* browser_model_; |
| 59 | 62 |
| 60 // Weak. The TabContents owns this. It is the model of the active | 63 // Weak. The TabContents owns this. It is the model of the active |
| 61 // tab. Changes to this model are propagated through to the |browser_model_|. | 64 // tab. Changes to this model are propagated through to the |browser_model_|. |
| 62 SearchModel* tab_model_; | 65 SearchModel* tab_model_; |
| 63 | 66 |
| 64 // Animator for fading in toolbar and tab backgrounds when mode changes from | 67 // Animator for fading in toolbar and tab backgrounds when mode changes from |
| 65 // NTP to SEARCH. | 68 // NTP to SEARCH. |
| 66 ToolbarSearchAnimator toolbar_search_animator_; | 69 ToolbarSearchAnimator toolbar_search_animator_; |
| 67 | 70 |
| 68 DISALLOW_COPY_AND_ASSIGN(SearchDelegate); | 71 DISALLOW_COPY_AND_ASSIGN(SearchDelegate); |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 } // namespace search | 74 } // namespace search |
| 72 } // namespace chrome | 75 } // namespace chrome |
| 73 | 76 |
| 74 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_ | 77 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_ |
| OLD | NEW |