blob: f88e29113ebae4057033c6c3a70c1cac784f0672 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_
#define CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/search/search_model_observer.h"
class ToolbarModel;
namespace content {
class WebContents;
}
namespace chrome {
namespace search {
class SearchModel;
// The SearchDelegate class acts as a helper to the Browser class.
// It is responsible for routing the changes from the active tab's
// SearchModel through to the toolbar, tabstrip and other UI
// observers.
// Changes are propagated from the active tab's model via this class to the
// Browser-level model.
class SearchDelegate : public SearchModelObserver {
public:
SearchDelegate(SearchModel* browser_search_model,
ToolbarModel* toolbar_model);
virtual ~SearchDelegate();
// Overrides for SearchModelObserver:
virtual void ModeChanged(const Mode& old_mode, const Mode& new_mode) OVERRIDE;
// When the active tab is changed, the model state of this new active tab is
// propagated to the browser.
void OnTabActivated(content::WebContents* web_contents);
// When a tab is deactivated, this class no longer observes changes to the
// tab's model.
void OnTabDeactivated(content::WebContents* web_contents);
// When a tab is detached, this class no longer observes changes to the
// tab's model.
void OnTabDetached(content::WebContents* web_contents);
private:
// Stop observing tab.
void StopObservingTab(content::WebContents* web_contents);
// Weak. The Browser class owns this. The active |tab_model_| state is
// propagated to the |browser_model_|.
SearchModel* browser_model_;
// Weak. The WebContents owns this. It is the model of the active
// tab. Changes to this model are propagated through to the |browser_model_|.
SearchModel* tab_model_;
DISALLOW_COPY_AND_ASSIGN(SearchDelegate);
};
} // namespace search
} // namespace chrome
#endif // CHROME_BROWSER_UI_SEARCH_SEARCH_DELEGATE_H_
|