summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/ui/search/instant_controller.cc6
-rw-r--r--chrome/browser/ui/search/instant_controller.h2
-rw-r--r--chrome/browser/ui/search/instant_extended_interactive_uitest.cc62
3 files changed, 69 insertions, 1 deletions
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc
index 210c2f0..0e3f48c 100644
--- a/chrome/browser/ui/search/instant_controller.cc
+++ b/chrome/browser/ui/search/instant_controller.cc
@@ -617,8 +617,12 @@ void InstantController::HandleAutocompleteResults(
result.type = UTF8ToUTF16(AutocompleteMatch::TypeToString(match->type));
result.description = match->description;
result.destination_url = UTF8ToUTF16(match->destination_url.spec());
- if (from_search_provider)
+
+ // Setting the search_query field tells the Instant page to treat the
+ // suggestion as a query.
+ if (AutocompleteMatch::IsSearchType(match->type))
result.search_query = match->contents;
+
result.transition = match->transition;
result.relevance = match->relevance;
DVLOG(1) << " " << result.relevance << " " << result.type << " "
diff --git a/chrome/browser/ui/search/instant_controller.h b/chrome/browser/ui/search/instant_controller.h
index 6822b28..3a54db0 100644
--- a/chrome/browser/ui/search/instant_controller.h
+++ b/chrome/browser/ui/search/instant_controller.h
@@ -203,6 +203,8 @@ class InstantController : public InstantPage::Delegate,
private:
FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant);
+ FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
+ SearchQueryNotDisplayedForNavsuggest);
FRIEND_TEST_ALL_PREFIXES(InstantTest, SetWithTemplateURL);
FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider);
FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefresh);
diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
index b9d31d6..c2a4111 100644
--- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
+++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
@@ -7,6 +7,7 @@
#include "base/prefs/pref_service.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/strings/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_controller.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
@@ -37,6 +38,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/url_constants.h"
@@ -831,6 +833,66 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) {
active_tab->GetRenderProcessHost()->GetID()));
}
+// Test that a search query will not be displayed for navsuggest queries.
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
+ SearchQueryNotDisplayedForNavsuggest) {
+ // Use only the local overlay.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableLocalOnlyInstantExtendedAPI);
+ ASSERT_TRUE(chrome::IsLocalOnlyInstantExtendedAPIEnabled());
+
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+
+ // The second argument indicates to use only the local overlay and NTP.
+ instant()->SetInstantEnabled(true, true);
+
+ // Focus omnibox and confirm overlay isn't shown.
+ FocusOmniboxAndWaitForInstantOverlaySupport();
+
+ // Typing in the omnibox should show the overlay.
+ SetOmniboxText("face");
+
+ content::WebContents* overlay = instant()->GetOverlayContents();
+
+ // Add a navsuggest suggestion.
+ instant()->SetSuggestions(
+ overlay,
+ std::vector<InstantSuggestion>(
+ 1,
+ InstantSuggestion(ASCIIToUTF16("http://facemash.com/"),
+ INSTANT_COMPLETE_NOW,
+ INSTANT_SUGGESTION_URL,
+ ASCIIToUTF16("face"))));
+
+ while (!omnibox()->model()->autocomplete_controller()->done()) {
+ content::WindowedNotificationObserver autocomplete_observer(
+ chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
+ content::NotificationService::AllSources());
+ autocomplete_observer.Wait();
+ }
+
+ EXPECT_TRUE(ExecuteScript(
+ "var sorted = chrome.embeddedSearch.searchBox.nativeSuggestions.sort("
+ "function (a,b) {"
+ "return b.rankingData.relevance - a.rankingData.relevance;"
+ "});"));
+
+ int suggestions_count = -1;
+ EXPECT_TRUE(GetIntFromJS(
+ overlay, "sorted.length", &suggestions_count));
+ ASSERT_GT(suggestions_count, 0);
+
+ std::string type;
+ EXPECT_TRUE(
+ GetStringFromJS(overlay, "sorted[0].type", &type));
+ ASSERT_EQ("navsuggest", type);
+
+ bool is_search;
+ EXPECT_TRUE(GetBoolFromJS(
+ overlay, "!!sorted[0].is_search", &is_search));
+ EXPECT_FALSE(is_search);
+}
+
// Verification of fix for BUG=176365. Ensure that each Instant WebContents in
// a tab uses a new BrowsingInstance, to avoid conflicts in the
// NavigationController.