blob: 7b0ff13c929168030b4268cbd594dca5c77696ae (
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
76
77
78
79
80
81
82
83
|
// 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 "base/compiler_specific.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_observer.h"
#include "content/public/browser/web_contents_user_data.h"
namespace content {
class WebContents;
}
// Per-tab search "helper". Acts as the owner and controller of the tab's
// search UI model.
class SearchTabHelper : public content::NotificationObserver,
public content::WebContentsObserver,
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,
bool popup_is_open,
bool user_text_is_empty);
// 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();
private:
friend class content::WebContentsUserData<SearchTabHelper>;
explicit SearchTabHelper(content::WebContents* web_contents);
// Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// Overridden from contents::WebContentsObserver:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// Sets the mode of the model based on the current URL of web_contents().
void UpdateMode();
// Handlers for SearchBox API to show and hide top bars (bookmark and info
// bars).
void OnSearchBoxShowBars(int page_id);
void OnSearchBoxHideBars(int page_id);
const bool is_search_enabled_;
// Tracks the last value passed to OmniboxEditModelChanged().
bool user_input_in_progress_;
bool popup_is_open_;
bool user_text_is_empty_;
// Model object for UI that cares about search state.
SearchModel model_;
content::NotificationRegistrar registrar_;
content::WebContents* web_contents_;
DISALLOW_COPY_AND_ASSIGN(SearchTabHelper);
};
#endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
|