summaryrefslogtreecommitdiffstats
path: root/chrome/browser/omnibox_search_hint.h
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 20:40:10 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 20:40:10 +0000
commitc8865483c216fbcaede15c4cd45e369643c8639b (patch)
tree075c9828944f3dff7c6ac6e0475eb878eef1e31c /chrome/browser/omnibox_search_hint.h
parent351355117f4cb4ee805961920a7c9d2ad0ae944c (diff)
downloadchromium_src-c8865483c216fbcaede15c4cd45e369643c8639b.zip
chromium_src-c8865483c216fbcaede15c4cd45e369643c8639b.tar.gz
chromium_src-c8865483c216fbcaede15c4cd45e369643c8639b.tar.bz2
This CL adds an infobar instructing users they can do search directly from the location bar when they navigate to their default search engine.The infobar is dismissed and not shown again if the user does a search from the omnibox or dismiss the infobar.This is part of a UX experiment and is behind a switch.BUG=NoneTEST=Start Chrome with a fresh profile. Navigate to www.google.com. An info bar should be shown. Click the 'show me' button, the location bar should display a message explaining search can be made from it.
Review URL: http://codereview.chromium.org/159242 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/omnibox_search_hint.h')
-rw-r--r--chrome/browser/omnibox_search_hint.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/chrome/browser/omnibox_search_hint.h b/chrome/browser/omnibox_search_hint.h
new file mode 100644
index 0000000..3d92011
--- /dev/null
+++ b/chrome/browser/omnibox_search_hint.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2009 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_OMNIBOX_SEARCH_HINT_
+#define CHROME_BROWSER_OMNIBOX_SEARCH_HINT_
+
+#include <map>
+#include <string>
+
+#include "base/scoped_ptr.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
+
+class Profile;
+class TabContents;
+
+// This class is responsible for showing an info-bar that tells the user she
+// can type her search query directly in the omnibox.
+// It is displayed when the user visits a known search engine URL and has not
+// searched from the omnibox before, or has not previously dismissed a similar
+// info-bar.
+class OmniboxSearchHint : public NotificationObserver {
+ public:
+ explicit OmniboxSearchHint(TabContents* tab);
+ ~OmniboxSearchHint();
+
+ // NotificationObserver method:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ // Focus the location bar and displays a message instructing that search
+ // queries can be typed directly in there.
+ void ShowEnteringQuery();
+
+ TabContents* tab() { return tab_; }
+
+ // Disables the hint infobar permanently, so that it does not show ever again.
+ void DisableHint();
+
+ // Returns true if the profile and current environment make the showing of the
+ // hint infobar possible.
+ static bool IsEnabled(Profile* profile);
+
+ private:
+ void ShowInfoBar();
+
+ NotificationRegistrar notification_registrar_;
+
+ // The tab we are associated with.
+ TabContents* tab_;
+
+ // A map containing the URLs of the search engine for which we want to
+ // trigger the hint.
+ std::map<std::string, int> search_engine_urls_;
+
+ DISALLOW_COPY_AND_ASSIGN(OmniboxSearchHint);
+};
+
+#endif // CHROME_BROWSER_OMNIBOX_SEARCH_HINT_