search: Log when bookmark bar is pinned.
We want to understand how showing search terms in the omnibox interacts
with the presence of the bookmark bar. For users in a field trial that's
showing search terms, this change adds a CGI arg &bmbp=1 to search URLs
if the bookmark bar is pinned and &bmbp=0 otherwise.
This isn't privacy-sensitive, because in theory we could get this
information by looking at outerHeight - innerHeight from search page
Javascript. Logging it explicitly this way is just more reliable than
doing that.
BUG=291244
TEST=unit tests,manual
Review URL: https://codereview.chromium.org/25324003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226506 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc
index 5882e5dc..99f5b906 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -1233,3 +1233,29 @@
search_provider.IsSearchURL(GURL(url_data[i].url)));
}
}
+
+TEST_F(TemplateURLTest, ReflectsBookmarkBarPinned) {
+ TemplateURLData data;
+ data.input_encodings.push_back("UTF-8");
+ data.SetURL("{google:baseURL}?{google:bookmarkBarPinned}q={searchTerms}");
+ TemplateURL url(NULL, data);
+ EXPECT_TRUE(url.url_ref().IsValid());
+ ASSERT_TRUE(url.url_ref().SupportsReplacement());
+ TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo"));
+
+ // Do not add the param when InstantExtended is suppressed on SRPs.
+ url.url_ref_.showing_search_terms_ = false;
+ std::string result = url.url_ref().ReplaceSearchTerms(search_terms_args);
+ EXPECT_EQ("http://www.google.com/?q=foo", result);
+
+ // Add the param when InstantExtended is not suppressed on SRPs.
+ url.url_ref_.showing_search_terms_ = true;
+ search_terms_args.bookmark_bar_pinned = false;
+ result = url.url_ref().ReplaceSearchTerms(search_terms_args);
+ EXPECT_EQ("http://www.google.com/?bmbp=0&q=foo", result);
+
+ url.url_ref_.showing_search_terms_ = true;
+ search_terms_args.bookmark_bar_pinned = true;
+ result = url.url_ref().ReplaceSearchTerms(search_terms_args);
+ EXPECT_EQ("http://www.google.com/?bmbp=1&q=foo", result);
+}