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_OMNIBOX_SEARCH_HINT_H_
6 #define CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_
11 #include "base/compiler_specific.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "content/public/browser/web_contents_user_data.h"
22 // This class is responsible for showing an info-bar that tells the user she
23 // can type her search query directly in the omnibox.
24 // It is displayed when the user visits a known search engine URL and has not
25 // searched from the omnibox before, or has not previously dismissed a similar
27 class OmniboxSearchHint
28 : public content::NotificationObserver
,
29 public content::WebContentsUserData
<OmniboxSearchHint
> {
31 virtual ~OmniboxSearchHint();
33 // content::NotificationObserver method:
34 virtual void Observe(int type
,
35 const content::NotificationSource
& source
,
36 const content::NotificationDetails
& details
) OVERRIDE
;
38 // Focus the location bar and displays a message instructing that search
39 // queries can be typed directly in there.
40 void ShowEnteringQuery();
42 // Disables the hint infobar permanently, so that it does not show ever again.
45 // Returns true if the profile and current environment make the showing of the
46 // hint infobar possible.
47 static bool IsEnabled(Profile
* profile
);
50 explicit OmniboxSearchHint(content::WebContents
* web_contents
);
51 friend class content::WebContentsUserData
<OmniboxSearchHint
>;
55 content::NotificationRegistrar notification_registrar_
;
57 // The contents we are associated with.
58 content::WebContents
* web_contents_
;
60 // A map containing the URLs of the search engine for which we want to
62 std::map
<std::string
, int> search_engine_urls_
;
64 DISALLOW_COPY_AND_ASSIGN(OmniboxSearchHint
);
67 #endif // CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_