Commit e9bbb8e5 authored by kmadhusu@chromium.org's avatar kmadhusu@chromium.org

Move SearchTermsData::ForceInstantResultsParam() to chrome::ForceInstantResultsParam().

Follow up of crrev.com/151813002.

BUG=none
TEST=none

Review URL: https://codereview.chromium.org/164493005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251456 0039d316-1c4b-4281-b951-d872f2087c98
parent aa1cb5a1
......@@ -239,8 +239,6 @@ class SearchTermsDataSnapshot : public SearchTermsData {
virtual std::string GetApplicationLocale() const OVERRIDE;
virtual base::string16 GetRlzParameterValue() const OVERRIDE;
virtual std::string GetSearchClient() const OVERRIDE;
virtual std::string ForceInstantResultsParam(
bool for_prerender) const OVERRIDE;
virtual std::string NTPIsThemedParam() const OVERRIDE;
private:
......@@ -248,7 +246,6 @@ class SearchTermsDataSnapshot : public SearchTermsData {
std::string application_locale_;
base::string16 rlz_parameter_value_;
std::string search_client_;
std::string force_instant_results_param_;
std::string ntp_is_themed_param_;
DISALLOW_COPY_AND_ASSIGN(SearchTermsDataSnapshot);
......@@ -260,8 +257,6 @@ SearchTermsDataSnapshot::SearchTermsDataSnapshot(
application_locale_(search_terms_data.GetApplicationLocale()),
rlz_parameter_value_(search_terms_data.GetRlzParameterValue()),
search_client_(search_terms_data.GetSearchClient()),
force_instant_results_param_(
search_terms_data.ForceInstantResultsParam(false)),
ntp_is_themed_param_(search_terms_data.NTPIsThemedParam()) {}
SearchTermsDataSnapshot::~SearchTermsDataSnapshot() {
......@@ -283,11 +278,6 @@ std::string SearchTermsDataSnapshot::GetSearchClient() const {
return search_client_;
}
std::string SearchTermsDataSnapshot::ForceInstantResultsParam(
bool for_prerender) const {
return force_instant_results_param_;
}
std::string SearchTermsDataSnapshot::NTPIsThemedParam() const {
return ntp_is_themed_param_;
}
......
......@@ -370,6 +370,11 @@ std::string InstantExtendedEnabledParam(bool for_search) {
base::Uint64ToString(EmbeddedSearchPageVersion()) + "&";
}
std::string ForceInstantResultsParam(bool for_prerender) {
return (for_prerender || !IsInstantExtendedAPIEnabled()) ?
"ion=1&" : std::string();
}
bool IsQueryExtractionEnabled() {
#if defined(OS_IOS) || defined(OS_ANDROID)
return true;
......
......@@ -86,6 +86,16 @@ uint64 EmbeddedSearchPageVersion();
// returns a non-empty string only if query extraction is enabled.
std::string InstantExtendedEnabledParam(bool for_search);
// Returns a string that will cause the search results page to update
// incrementally. Currently, Instant Extended passes a different param to
// search results pages that also has this effect, so by default this function
// returns the empty string when Instant Extended is enabled. However, when
// doing instant search result prerendering, we still need to pass this param,
// as Instant Extended does not cause incremental updates by default for the
// prerender page. Callers should set |for_prerender| in this case to force
// the returned string to be non-empty.
std::string ForceInstantResultsParam(bool for_prerender);
// Returns whether query extraction is enabled.
bool IsQueryExtractionEnabled();
......
......@@ -800,6 +800,14 @@ TEST_F(SearchTest, GetSearchResultPrefetchBaseURL) {
GetSearchResultPrefetchBaseURL(profile()));
}
TEST_F(SearchTest, ForceInstantResultsParam) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
"Group1 espv:2"));
EXPECT_TRUE(IsInstantExtendedAPIEnabled());
EXPECT_EQ("ion=1&", ForceInstantResultsParam(true));
EXPECT_EQ(std::string(), ForceInstantResultsParam(false));
}
struct ExtractSearchTermsTestCase {
const char* url;
const char* expected_result;
......
......@@ -78,11 +78,6 @@ std::string SearchTermsData::GetSuggestRequestIdentifier() const {
return std::string();
}
std::string SearchTermsData::ForceInstantResultsParam(
bool for_prerender) const {
return std::string();
}
std::string SearchTermsData::NTPIsThemedParam() const {
return std::string();
}
......@@ -172,14 +167,6 @@ std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const {
#endif
}
std::string UIThreadSearchTermsData::ForceInstantResultsParam(
bool for_prerender) const {
DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::UI));
return (for_prerender || !chrome::IsInstantExtendedAPIEnabled()) ? "ion=1&" :
std::string();
}
std::string UIThreadSearchTermsData::NTPIsThemedParam() const {
DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::UI));
......
......@@ -51,16 +51,6 @@ class SearchTermsData {
// This implementation returns the empty string.
virtual std::string GetSuggestRequestIdentifier() const;
// Returns a string that will cause the search results page to update
// incrementally. Currently, Instant Extended passes a different param to
// search results pages that also has this effect, so by default this function
// returns the empty string when Instant Extended is enabled. However, when
// doing instant search result prerendering, we still need to pass this param,
// as Instant Extended does not cause incremental updates by default for the
// prerender page. Callers should set |for_prerender| in this case to force
// the returned string to be non-empty.
virtual std::string ForceInstantResultsParam(bool for_prerender) const;
// Returns a string indicating whether a non-default theme is active,
// suitable for adding as a query string param to the homepage. This only
// applies if Instant Extended is enabled. Returns an empty string otherwise.
......@@ -85,8 +75,6 @@ class UIThreadSearchTermsData : public SearchTermsData {
virtual std::string GetSearchClient() const OVERRIDE;
virtual std::string GetSuggestClient() const OVERRIDE;
virtual std::string GetSuggestRequestIdentifier() const OVERRIDE;
virtual std::string ForceInstantResultsParam(
bool for_prerender) const OVERRIDE;
virtual std::string NTPIsThemedParam() const OVERRIDE;
// Used by tests to override the value for the Google base URL. Passing the
......
......@@ -891,7 +891,7 @@ std::string TemplateURLRef::HandleReplacements(
case GOOGLE_FORCE_INSTANT_RESULTS:
DCHECK(!i->is_post_param);
HandleReplacement(std::string(),
search_terms_data.ForceInstantResultsParam(
chrome::ForceInstantResultsParam(
search_terms_args.force_instant_results),
*i,
&url);
......
......@@ -131,7 +131,7 @@ class TemplateURLRef {
// If set, ReplaceSearchTerms() will append a param to the TemplateURLRef to
// update the search results page incrementally even if that is otherwise
// disabled by google.com preferences. See comments on
// SearchTermsData::ForceInstantResultsParam().
// chrome::ForceInstantResultsParam().
bool force_instant_results;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment