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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/ui/search/search_model_observer.h"
18 // The SearchDelegate class acts as a helper to the Browser class.
19 // It is responsible for routing the changes from the active tab's
20 // SearchModel through to the toolbar, tabstrip and other UI
22 // Changes are propagated from the active tab's model via this class to the
23 // Browser-level model.
24 class SearchDelegate
: public SearchModelObserver
{
26 explicit SearchDelegate(SearchModel
* browser_search_model
);
27 virtual ~SearchDelegate();
29 // Overrides for SearchModelObserver:
30 virtual void ModelChanged(const SearchModel::State
& old_state
,
31 const SearchModel::State
& new_state
) OVERRIDE
;
33 // When the active tab is changed, the model state of this new active tab is
34 // propagated to the browser.
35 void OnTabActivated(content::WebContents
* web_contents
);
37 // When a tab is deactivated, this class no longer observes changes to the
39 void OnTabDeactivated(content::WebContents
* web_contents
);
41 // When a tab is detached, this class no longer observes changes to the
43 void OnTabDetached(content::WebContents
* web_contents
);
46 // Stop observing tab.
47 void StopObservingTab(content::WebContents
* web_contents
);
49 // Weak. The Browser class owns this. The active |tab_model_| state is
50 // propagated to the |browser_model_|.
51 SearchModel
* browser_model_
;
53 // Weak. The WebContents owns this. It is the model of the active
54 // tab. Changes to this model are propagated through to the |browser_model_|.
55 SearchModel
* tab_model_
;
57 DISALLOW_COPY_AND_ASSIGN(SearchDelegate
);
60 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_