Skip to content

Commit

Permalink
Field trial to disable google logo on local ntp.
Browse files Browse the repository at this point in the history
Adds a field trial option to disable the custom treatment on the local
NTP when Google is the DSP. It's unclear if we need this config now.

BUG=
R=samarth@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249208 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jered@chromium.org committed Feb 6, 2014
1 parent a5a711b commit 620ff56
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion chrome/browser/search/local_ntp_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ std::string GetConfigData(Profile* profile) {
base::DictionaryValue config_data;
config_data.Set("translatedStrings", GetTranslatedStrings().release());
config_data.SetBoolean("isGooglePage",
DefaultSearchProviderIsGoogle(profile));
DefaultSearchProviderIsGoogle(profile) &&
chrome::ShouldShowGoogleLocalNTP());

// Serialize the dictionary.
std::string js_text;
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/search/search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const char kOriginChipFlagName[] = "origin_chip";
#if !defined(OS_IOS) && !defined(OS_ANDROID)
const char kEnableQueryExtractionFlagName[] = "query_extraction";
#endif
const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp";

// Constants for the field trial name and group prefix.
// Note in M30 and below this field trial was named "InstantExtended" and in
Expand Down Expand Up @@ -611,6 +612,12 @@ OriginChipPosition GetOriginChipPosition() {
ORIGIN_CHIP_DISABLED;
}

bool ShouldShowGoogleLocalNTP() {
FieldTrialFlags flags;
return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault(
kShouldShowGoogleLocalNTPFlagName, true, flags);
}

GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
CHECK(ShouldAssignURLToInstantRenderer(url, profile))
<< "Error granting Instant access.";
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/search/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ bool ShouldDisplayOriginChip();
// toolbar.
OriginChipPosition GetOriginChipPosition();

// Returns true if the local new tab page should show a Google logo and search
// box for users whose default search provider is Google, or false if not.
bool ShouldShowGoogleLocalNTP();

// Transforms the input |url| into its "effective URL". The returned URL
// facilitates grouping process-per-site. The |url| is transformed, for
// example, from
Expand Down
16 changes: 16 additions & 0 deletions chrome/browser/search/search_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,22 @@ TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_DisabledViaFinch) {
EXPECT_EQ(89ul, EmbeddedSearchPageVersion());
}

TEST_F(SearchTest, ShouldShowGoogleLocalNTP_Default) {
EXPECT_TRUE(ShouldShowGoogleLocalNTP());
}

TEST_F(SearchTest, ShouldShowGoogleLocalNTP_EnabledViaFinch) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2 google_local_ntp:1"));
EXPECT_TRUE(ShouldShowGoogleLocalNTP());
}

TEST_F(SearchTest, ShouldShowGoogleLocalNTP_DisabledViaFinch) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2 google_local_ntp:0"));
EXPECT_FALSE(ShouldShowGoogleLocalNTP());
}

TEST_F(SearchTest, IsNTPURL) {
GURL invalid_url;
GURL ntp_url(chrome::kChromeUINewTabURL);
Expand Down

0 comments on commit 620ff56

Please sign in to comment.