[email protected] | 871dc68 | 2012-06-11 19:35:33 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_ |
6 | #define CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_ | ||||
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 7 | |
[email protected] | 49fd7e2 | 2011-11-21 16:52:21 | [diff] [blame] | 8 | #include "base/compiler_specific.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 9 | #include "content/public/browser/notification_observer.h" |
10 | #include "content/public/browser/notification_registrar.h" | ||||
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 11 | #include "content/public/browser/web_contents_user_data.h" |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 12 | |
13 | class Profile; | ||||
[email protected] | ef01920d | 2012-09-18 19:05:07 | [diff] [blame] | 14 | |
15 | namespace content { | ||||
16 | class WebContents; | ||||
17 | } | ||||
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 18 | |
19 | // This class is responsible for showing an info-bar that tells the user she | ||||
20 | // can type her search query directly in the omnibox. | ||||
21 | // It is displayed when the user visits a known search engine URL and has not | ||||
22 | // searched from the omnibox before, or has not previously dismissed a similar | ||||
23 | // info-bar. | ||||
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 24 | class OmniboxSearchHint |
25 | : public content::NotificationObserver, | ||||
26 | public content::WebContentsUserData<OmniboxSearchHint> { | ||||
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 27 | public: |
[email protected] | 3690ebe0 | 2011-05-25 09:08:19 | [diff] [blame] | 28 | virtual ~OmniboxSearchHint(); |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 29 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 30 | // content::NotificationObserver method: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 31 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 32 | const content::NotificationSource& source, |
[email protected] | 49fd7e2 | 2011-11-21 16:52:21 | [diff] [blame] | 33 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 34 | |
35 | // Focus the location bar and displays a message instructing that search | ||||
36 | // queries can be typed directly in there. | ||||
37 | void ShowEnteringQuery(); | ||||
38 | |||||
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 39 | // Disables the hint infobar permanently, so that it does not show ever again. |
40 | void DisableHint(); | ||||
41 | |||||
42 | // Returns true if the profile and current environment make the showing of the | ||||
43 | // hint infobar possible. | ||||
44 | static bool IsEnabled(Profile* profile); | ||||
45 | |||||
46 | private: | ||||
[email protected] | ef01920d | 2012-09-18 19:05:07 | [diff] [blame] | 47 | explicit OmniboxSearchHint(content::WebContents* web_contents); |
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 48 | friend class content::WebContentsUserData<OmniboxSearchHint>; |
[email protected] | ef01920d | 2012-09-18 19:05:07 | [diff] [blame] | 49 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 50 | content::NotificationRegistrar notification_registrar_; |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 51 | |
[email protected] | ef01920d | 2012-09-18 19:05:07 | [diff] [blame] | 52 | // The contents we are associated with. |
53 | content::WebContents* web_contents_; | ||||
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 54 | |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 55 | DISALLOW_COPY_AND_ASSIGN(OmniboxSearchHint); |
56 | }; | ||||
57 | |||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 58 | #endif // CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_ |