Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/omnibox_search_hint.h

Issue 10951008: Switch OmniboxSearchHint to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/omnibox_search_hint.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_ 5 #ifndef CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_
6 #define CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_ 6 #define CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "chrome/browser/tab_contents/web_contents_user_data.h"
12 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
14 15
15 class Profile; 16 class Profile;
16 class TabContents; 17
18 namespace content {
19 class WebContents;
20 }
17 21
18 // This class is responsible for showing an info-bar that tells the user she 22 // This class is responsible for showing an info-bar that tells the user she
19 // can type her search query directly in the omnibox. 23 // 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 24 // 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 25 // searched from the omnibox before, or has not previously dismissed a similar
22 // info-bar. 26 // info-bar.
23 class OmniboxSearchHint : public content::NotificationObserver { 27 class OmniboxSearchHint : public content::NotificationObserver,
28 public WebContentsUserData<OmniboxSearchHint> {
24 public: 29 public:
25 explicit OmniboxSearchHint(TabContents* tab);
26 virtual ~OmniboxSearchHint(); 30 virtual ~OmniboxSearchHint();
27 31
28 // content::NotificationObserver method: 32 // content::NotificationObserver method:
29 virtual void Observe(int type, 33 virtual void Observe(int type,
30 const content::NotificationSource& source, 34 const content::NotificationSource& source,
31 const content::NotificationDetails& details) OVERRIDE; 35 const content::NotificationDetails& details) OVERRIDE;
32 36
33 // Focus the location bar and displays a message instructing that search 37 // Focus the location bar and displays a message instructing that search
34 // queries can be typed directly in there. 38 // queries can be typed directly in there.
35 void ShowEnteringQuery(); 39 void ShowEnteringQuery();
36 40
37 TabContents* tab() { return tab_; }
38
39 // Disables the hint infobar permanently, so that it does not show ever again. 41 // Disables the hint infobar permanently, so that it does not show ever again.
40 void DisableHint(); 42 void DisableHint();
41 43
42 // Returns true if the profile and current environment make the showing of the 44 // Returns true if the profile and current environment make the showing of the
43 // hint infobar possible. 45 // hint infobar possible.
44 static bool IsEnabled(Profile* profile); 46 static bool IsEnabled(Profile* profile);
45 47
46 private: 48 private:
49 explicit OmniboxSearchHint(content::WebContents* web_contents);
50 static int kUserDataKey;
51 friend class WebContentsUserData<OmniboxSearchHint>;
52
47 void ShowInfoBar(); 53 void ShowInfoBar();
48 54
49 content::NotificationRegistrar notification_registrar_; 55 content::NotificationRegistrar notification_registrar_;
50 56
51 // The tab we are associated with. 57 // The contents we are associated with.
52 TabContents* tab_; 58 content::WebContents* web_contents_;
53 59
54 // A map containing the URLs of the search engine for which we want to 60 // A map containing the URLs of the search engine for which we want to
55 // trigger the hint. 61 // trigger the hint.
56 std::map<std::string, int> search_engine_urls_; 62 std::map<std::string, int> search_engine_urls_;
57 63
58 DISALLOW_COPY_AND_ASSIGN(OmniboxSearchHint); 64 DISALLOW_COPY_AND_ASSIGN(OmniboxSearchHint);
59 }; 65 };
60 66
61 #endif // CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_ 67 #endif // CHROME_BROWSER_OMNIBOX_SEARCH_HINT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/omnibox_search_hint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698