[email protected] | b3841c50 | 2011-03-09 01:21:31 | [diff] [blame] | 1 | // Copyright (c) 2011 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] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 8 | |
9 | #include <map> | ||||
10 | #include <string> | ||||
11 | |||||
[email protected] | b3841c50 | 2011-03-09 01:21:31 | [diff] [blame] | 12 | #include "content/common/notification_observer.h" |
13 | #include "content/common/notification_registrar.h" | ||||
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 14 | |
15 | class Profile; | ||||
[email protected] | 7abc9529 | 2011-05-18 00:18:09 | [diff] [blame] | 16 | class TabContentsWrapper; |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 17 | |
18 | // This class is responsible for showing an info-bar that tells the user she | ||||
19 | // can type her search query directly in the omnibox. | ||||
20 | // It is displayed when the user visits a known search engine URL and has not | ||||
21 | // searched from the omnibox before, or has not previously dismissed a similar | ||||
22 | // info-bar. | ||||
23 | class OmniboxSearchHint : public NotificationObserver { | ||||
24 | public: | ||||
[email protected] | 7abc9529 | 2011-05-18 00:18:09 | [diff] [blame] | 25 | explicit OmniboxSearchHint(TabContentsWrapper* tab); |
[email protected] | 3690ebe0 | 2011-05-25 09:08:19 | [diff] [blame^] | 26 | virtual ~OmniboxSearchHint(); |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 27 | |
28 | // NotificationObserver method: | ||||
29 | virtual void Observe(NotificationType type, | ||||
30 | const NotificationSource& source, | ||||
31 | const NotificationDetails& details); | ||||
32 | |||||
33 | // Focus the location bar and displays a message instructing that search | ||||
34 | // queries can be typed directly in there. | ||||
35 | void ShowEnteringQuery(); | ||||
36 | |||||
[email protected] | 7abc9529 | 2011-05-18 00:18:09 | [diff] [blame] | 37 | TabContentsWrapper* tab() { return tab_; } |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 38 | |
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: | ||||
47 | void ShowInfoBar(); | ||||
48 | |||||
49 | NotificationRegistrar notification_registrar_; | ||||
50 | |||||
51 | // The tab we are associated with. | ||||
[email protected] | 7abc9529 | 2011-05-18 00:18:09 | [diff] [blame] | 52 | TabContentsWrapper* tab_; |
[email protected] | c886548 | 2009-07-23 20:40:10 | [diff] [blame] | 53 | |
54 | // A map containing the URLs of the search engine for which we want to | ||||
55 | // trigger the hint. | ||||
56 | std::map<std::string, int> search_engine_urls_; | ||||
57 | |||||
58 | DISALLOW_COPY_AND_ASSIGN(OmniboxSearchHint); | ||||
59 | }; | ||||
60 | |||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 61 | #endif // CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_ |