blob: 114cc6698e09c19ad52872364d69254142691f6e (
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
69
70
71
72
73
74
75
|
// Copyright 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_TAB_HELPER_H_
#define CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
#include "base/basictypes.h"
#include "chrome/browser/ui/search/search_model.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_user_data.h"
class OmniboxEditModel;
namespace content {
class WebContents;
}
namespace chrome {
namespace search {
// Per-tab search "helper". Acts as the owner and controller of the tab's
// search UI model.
class SearchTabHelper : public content::NotificationObserver,
public content::WebContentsUserData<SearchTabHelper> {
public:
virtual ~SearchTabHelper();
SearchModel* model() {
return &model_;
}
// Invoked when the OmniboxEditModel changes state in some way that might
// affect the search mode.
void OmniboxEditModelChanged(bool user_input_in_progress, bool cancelling);
// Invoked when the active navigation entry is updated in some way that might
// affect the search mode. This is used by Instant when it "fixes up" the
// virtual URL of the active entry. Regular navigations are captured through
// the notification system and shouldn't call this method.
void NavigationEntryUpdated();
// Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
private:
explicit SearchTabHelper(content::WebContents* web_contents);
friend class content::WebContentsUserData<SearchTabHelper>;
// Sets the mode of the model based on |url|.
void UpdateModelBasedOnURL(const GURL& url);
// Returns the web contents associated with the tab that owns this helper.
const content::WebContents* web_contents() const;
const bool is_search_enabled_;
// Tracks the last value passed to OmniboxEditModelChanged().
bool user_input_in_progress_;
// Model object for UI that cares about search state.
SearchModel model_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(SearchTabHelper);
};
} // namespace search
} // namespace chrome
#endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
|