Commit 982ecc2f authored by mathp@chromium.org's avatar mathp@chromium.org

[Most Visited] Removing Most Visited Tiles experiment code, which is obsolete.

Experiment is no longer running and is in many ways obsolete. Removing the code.

BUG=None
TEST=manual

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287624 0039d316-1c4b-4281-b951-d872f2087c98
parent a826db6d
// Copyright 2013 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.
#include "chrome/browser/history/most_visited_tiles_experiment.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
#include "chrome/common/instant_types.h"
namespace history {
namespace {
// Constants for the most visited tile placement field trial.
// ex:
// "OneEightGroup_Flipped" --> Will cause tile 1 and 8 to be flipped.
// "OneEightGroup_NoChange" --> Will not flip anything.
//
// See field trial config (MostVisitedTilePlacement.json) for details.
const char kMostVisitedFieldTrialName[] = "MostVisitedTilePlacement";
// Name of histogram tracking types of actions carried out by the field trial.
const char kMostVisitedExperimentHistogramName[] =
"NewTabPage.MostVisitedTilePlacementExperiment";
const char kOneEightGroupPrefix[] = "OneEight";
const char kOneFourGroupPrefix[] = "OneFour";
const char kFlippedSuffix[] = "Flipped";
const char kDontShowOpenURLsGroupName[] = "DontShowOpenTabs";
// Minimum number of Most Visited suggestions required in order for the Most
// Visited Field Trial to remove a URL already open in the browser.
const size_t kMinUrlSuggestions = 8;
} // namespace
// static
void MostVisitedTilesExperiment::MaybeShuffle(MostVisitedURLList* data) {
const std::string group_name =
base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName);
// Depending on the study group of the client, we might flip the 1st and 4th
// tiles, or the 1st and 8th, or do nothing.
if (!EndsWith(group_name, kFlippedSuffix, true))
return;
size_t index_to_flip = 0;
if (StartsWithASCII(group_name, kOneEightGroupPrefix, true)) {
if (data->size() < 8) {
LogInHistogram(NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_8);
return;
}
index_to_flip = 7;
} else if (StartsWithASCII(group_name, kOneFourGroupPrefix, true)) {
if (data->size() < 4) {
LogInHistogram(NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_4);
return;
}
index_to_flip = 3;
}
std::swap((*data)[0], (*data)[index_to_flip]);
}
// static
bool MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled() {
return base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName) ==
kDontShowOpenURLsGroupName;
}
// static
void MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs(
const std::set<std::string>& open_urls,
std::vector<InstantMostVisitedItem>* items) {
for (size_t i = 0; i < items->size(); ) {
const std::string& url = (*items)[i].url.spec();
if (ShouldRemoveURL(open_urls, url, items->size()))
items->erase(items->begin() + i);
else
++i;
}
}
// static
void MostVisitedTilesExperiment::RemovePageValuesMatchingOpenTabs(
const std::set<std::string>& open_urls,
base::ListValue* pages_value) {
for (size_t i = 0; i < pages_value->GetSize(); ) {
base::DictionaryValue* page_value;
std::string url;
if (pages_value->GetDictionary(i, &page_value) &&
page_value->GetString("url", &url) &&
ShouldRemoveURL(open_urls, url, pages_value->GetSize())) {
pages_value->Remove(*page_value, &i);
} else {
++i;
}
}
}
// static
void MostVisitedTilesExperiment::LogInHistogram(
NtpTileExperimentActions action) {
UMA_HISTOGRAM_ENUMERATION(kMostVisitedExperimentHistogramName,
action,
NUM_NTP_TILE_EXPERIMENT_ACTIONS);
}
// static
bool MostVisitedTilesExperiment::ShouldRemoveURL(
const std::set<std::string>& open_urls,
const std::string& url,
const size_t size) {
if (open_urls.count(url) == 0)
return false;
if (size <= kMinUrlSuggestions) {
LogInHistogram(NTP_TILE_EXPERIMENT_ACTION_DID_NOT_REMOVE_URL);
return false;
}
LogInHistogram(NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL);
return true;
}
} // namespace history
// Copyright 2013 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_HISTORY_MOST_VISITED_TILES_EXPERIMENT_H_
#define CHROME_BROWSER_HISTORY_MOST_VISITED_TILES_EXPERIMENT_H_
#include "base/values.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/common/instant_types.h"
namespace history {
// This enum is also defined in histograms.xml. These values represent the
// types of actions carried out by the Most Visited Tile Placement experiment.
enum NtpTileExperimentActions {
NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL = 0,
NTP_TILE_EXPERIMENT_ACTION_DID_NOT_REMOVE_URL = 1,
NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_8 = 2,
NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_4 = 3,
// The number of Most Visited Tile Placement experiment actions logged.
NUM_NTP_TILE_EXPERIMENT_ACTIONS
};
// Class for implementing the Most Visited Tile Placement experiment.
class MostVisitedTilesExperiment {
public:
// Helper method to shuffle MostVisited tiles for A/B testing purposes.
static void MaybeShuffle(MostVisitedURLList* data);
// Returns true if this user is part of the Most Visited Tile Placement
// experiment group where URLs currently open in another browser tab are not
// displayed on an NTP tile. Note: the experiment targets only the top-level
// of sites i.e. if www.foo.com/bar is open in browser, and www.foo.com is a
// recommended URL, www.foo.com will still appear on the next NTP open. The
// experiment will not remove a URL if doing so would cause the number of Most
// Visited recommendations to drop below eight.
static bool IsDontShowOpenURLsEnabled();
// Removes URLs already open in browser, for 1993 clients, if part of
// experiment described for IsDontShowOpenURLsEnabled().
static void RemoveItemsMatchingOpenTabs(
const std::set<std::string>& open_urls,
std::vector<InstantMostVisitedItem>* items);
// Removes URLs already open in browser, for non-1993 clients, if part of
// experiment described for IsDontShowOpenURLsEnabled().
static void RemovePageValuesMatchingOpenTabs(
const std::set<std::string>& open_urls,
base::ListValue* pages_value);
private:
// Helper method to log the actions carried out by the Most Visited Tile
// Placement experiment.
static void LogInHistogram(NtpTileExperimentActions action);
// Helper method to determine whether |url| is in |open_urls|.
static bool ShouldRemoveURL(const std::set<std::string>& open_urls,
const std::string& url,
const size_t size);
DISALLOW_IMPLICIT_CONSTRUCTORS(MostVisitedTilesExperiment);
};
} // namespace history
#endif // CHROME_BROWSER_HISTORY_MOST_VISITED_TILES_EXPERIMENT_H_
// Copyright 2013 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.
#include "chrome/browser/history/most_visited_tiles_experiment.h"
#include <algorithm>
#include <sstream>
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/metrics/statistics_recorder.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/common/instant_types.h"
#include "components/variations/entropy_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace history {
namespace {
// Constants for the most visited tile placement field trial.
// See field trial config (MostVisitedTilePlacement.json) for details.
const char kMostVisitedFieldTrialName[] = "MostVisitedTilePlacement";
const char kOneEightAGroupName[] = "OneEight_A_Flipped";
const char kOneFourAGroupName[] = "OneFour_A_Flipped";
const char kDontShowOpenURLsGroupName[] = "DontShowOpenTabs";
const char kGmailURL[] = "http://www.gmail.com/";
// Name of histogram tracking types of actions carried out by the field trial.
const char kMostVisitedExperimentHistogramName[] =
"NewTabPage.MostVisitedTilePlacementExperiment";
// Minimum number of Most Visited suggestions required in order for the Most
// Visited Field Trial to remove a URL already open in the browser.
const size_t kMinUrlSuggestions = 8;
// The indexes of the tiles that are affected in the experiment.
enum FlippedIndexes {
TILE_ONE = 0,
TILE_FOUR = 3,
TILE_EIGHT = 7
};
// Creates a DictionaryValue using |url| and appends to |list|.
void AppendURLToListValue(const std::string& url_string,
base::ListValue* list) {
base::DictionaryValue* page_value = new base::DictionaryValue();
page_value->SetString("url", url_string);
list->Append(page_value);
}
// Creates an InstantMostVisitedItem using |url| and appends to |list|.
void AppendInstantURLToVector(const std::string& url_string,
std::vector<InstantMostVisitedItem>* list) {
InstantMostVisitedItem item;
item.url = GURL(url_string);
list->push_back(item);
}
// Creates an MostVisitedURL using |url| and appends to |list|.
void AppendMostVisitedURLToVector(const std::string& url_string,
std::vector<history::MostVisitedURL>* list) {
history::MostVisitedURL most_visited;
most_visited.url = GURL(url_string);
list->push_back(most_visited);
}
void SetUpMaybeShuffle(const int& max_urls,
MostVisitedURLList* most_visited_urls,
MostVisitedURLList* test_urls) {
// |most_visited_urls| must have > 8 MostVisitedURLs for any URLs to be
// flipped by experiment.
for (int i = 0; i < max_urls; ++i) {
std::string url;
base::SStringPrintf(&url, "http://www.test%d.com", i);
AppendMostVisitedURLToVector(url, most_visited_urls);
AppendMostVisitedURLToVector(url, test_urls);
}
}
} // namespace
class MostVisitedTilesExperimentTest : public testing::Test {
public:
MostVisitedTilesExperimentTest()
: histogram_(NULL),
field_trial_list_(new metrics::SHA1EntropyProvider("foo")) {}
virtual ~MostVisitedTilesExperimentTest() {}
protected:
virtual void SetUp() OVERRIDE {
base::StatisticsRecorder::Initialize();
previous_metrics_count_.resize(NUM_NTP_TILE_EXPERIMENT_ACTIONS, 0);
base::HistogramBase* histogram = GetHistogram();
if (histogram) {
scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
if (samples.get()) {
for (int state = NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL;
state < NUM_NTP_TILE_EXPERIMENT_ACTIONS;
++state) {
previous_metrics_count_[state] = samples->GetCount(state);
}
}
}
}
void ValidateMetrics(const base::HistogramBase::Sample& value) {
base::HistogramBase* histogram = GetHistogram();
ASSERT_TRUE(histogram != NULL);
scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
if (samples.get()) {
for (int state = NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL;
state < NUM_NTP_TILE_EXPERIMENT_ACTIONS;
++state) {
if (state == value) {
EXPECT_EQ(previous_metrics_count_[state] + 1,
samples->GetCount(state));
} else {
EXPECT_EQ(previous_metrics_count_[state], samples->GetCount(state));
}
}
}
}
private:
base::HistogramBase* GetHistogram() {
if (!histogram_) {
histogram_ = base::StatisticsRecorder::FindHistogram(
kMostVisitedExperimentHistogramName);
}
return histogram_;
}
// Owned by base::StatisticsRecorder
base::HistogramBase* histogram_;
base::FieldTrialList field_trial_list_;
std::vector<int> previous_metrics_count_;
DISALLOW_COPY_AND_ASSIGN(MostVisitedTilesExperimentTest);
};
// For pre-instant extended clients.
TEST_F(MostVisitedTilesExperimentTest,
RemovePageValuesMatchingOpenTabsTooFewURLs) {
base::FieldTrialList::CreateFieldTrial(kMostVisitedFieldTrialName,
kDontShowOpenURLsGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_TRUE(MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled());
std::set<std::string> open_urls;
open_urls.insert(kGmailURL);
base::ListValue pages_value;
AppendURLToListValue(kGmailURL, &pages_value);
// Test the method when there are not enough URLs to force removal.
MostVisitedTilesExperiment::RemovePageValuesMatchingOpenTabs(
open_urls, &pages_value);
base::DictionaryValue gmail_value;
gmail_value.SetString("url", kGmailURL);
// Ensure the open url has not been removed from |pages_value|.
EXPECT_NE(pages_value.end(), pages_value.Find(gmail_value));
// Ensure counts have been incremented correctly.
EXPECT_NO_FATAL_FAILURE(
ValidateMetrics(NTP_TILE_EXPERIMENT_ACTION_DID_NOT_REMOVE_URL));
}
// For pre-instant extended clients.
TEST_F(MostVisitedTilesExperimentTest, RemovePageValuesMatchingOpenTabs) {
base::FieldTrialList::CreateFieldTrial(kMostVisitedFieldTrialName,
kDontShowOpenURLsGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_TRUE(MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled());
std::set<std::string> open_urls;
open_urls.insert(kGmailURL);
base::ListValue pages_value;
AppendURLToListValue(kGmailURL, &pages_value);
// |pages_value| must have > 8 page values for any URLs to be removed by
// experiment.
for (size_t i = 0; i < kMinUrlSuggestions; ++i) {
std::string url;
base::SStringPrintf(&url, "http://www.test%d.com", static_cast<int>(i));
AppendURLToListValue(url, &pages_value);
}
// Call method with enough URLs to force removal.
MostVisitedTilesExperiment::RemovePageValuesMatchingOpenTabs(
open_urls, &pages_value);
// Ensure the open url has been removed from |pages_value|.
base::DictionaryValue gmail_value;
gmail_value.SetString("url", kGmailURL);
EXPECT_EQ(pages_value.end(), pages_value.Find(gmail_value));
// Ensure counts have been incremented correctly.
EXPECT_NO_FATAL_FAILURE(
ValidateMetrics(NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL));
}
// For instant extended clients.
TEST_F(MostVisitedTilesExperimentTest, RemoveItemsMatchingOpenTabsTooFewURLs) {
base::FieldTrialList::CreateFieldTrial(kMostVisitedFieldTrialName,
kDontShowOpenURLsGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_TRUE(MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled());
std::set<std::string> open_urls;
open_urls.insert(kGmailURL);
std::vector<InstantMostVisitedItem> items;
AppendInstantURLToVector(kGmailURL, &items);
// Call the method when there are not enough URLs to force removal.
MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs(open_urls, &items);
// Ensure the open url has not been removed from |items|.
for (size_t i = 0; i < items.size(); i++) {
const std::string& item_url = items[i].url.spec();
EXPECT_NE(0u, open_urls.count(item_url));
}
// Ensure counts have been incremented correctly.
EXPECT_NO_FATAL_FAILURE(
ValidateMetrics(NTP_TILE_EXPERIMENT_ACTION_DID_NOT_REMOVE_URL));
}
// For instant extended clients.
TEST_F(MostVisitedTilesExperimentTest, RemoveItemsMatchingOpenTabs) {
base::FieldTrialList::CreateFieldTrial(
kMostVisitedFieldTrialName,
kDontShowOpenURLsGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_TRUE(MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled());
std::set<std::string> open_urls;
open_urls.insert(kGmailURL);
std::vector<InstantMostVisitedItem> items;
AppendInstantURLToVector(kGmailURL, &items);
// |items| must have > 8 InstantMostVisitedItems for any URLs to be removed by
// experiment.
for (size_t i = 0; i < kMinUrlSuggestions; ++i) {
std::string url;
base::SStringPrintf(&url, "http://www.test%d.com", static_cast<int>(i));
AppendInstantURLToVector(url, &items);
}
// Call method with enough URLs to force removal.
MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs(open_urls, &items);
// Ensure the open URL has been removed from |items|.
for (size_t i = 0; i < items.size(); i++) {
const std::string& item_url = items[i].url.spec();
EXPECT_EQ(0u, open_urls.count(item_url));
}
// Ensure counts have been incremented correctly.
EXPECT_NO_FATAL_FAILURE(
ValidateMetrics(NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL));
}
TEST_F(MostVisitedTilesExperimentTest, MaybeShuffleOneEight) {
base::FieldTrialList::CreateFieldTrial(kMostVisitedFieldTrialName,
kOneEightAGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_EQ(kOneEightAGroupName,
base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName));
MostVisitedURLList most_visited_urls;
MostVisitedURLList test_urls;
SetUpMaybeShuffle(kMinUrlSuggestions, &most_visited_urls, &test_urls);
history::MostVisitedTilesExperiment::MaybeShuffle(&most_visited_urls);
// Ensure the 1st and 8th URLs have been switched.
EXPECT_EQ(most_visited_urls[TILE_ONE].url.spec(),
test_urls[TILE_EIGHT].url.spec());
}
TEST_F(MostVisitedTilesExperimentTest, MaybeShuffleOneEightTooFewURLs) {
base::FieldTrialList::CreateFieldTrial(kMostVisitedFieldTrialName,
kOneEightAGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_EQ(kOneEightAGroupName,
base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName));
MostVisitedURLList most_visited_urls;
MostVisitedURLList test_urls;
// If |most_visited_urls| has < 8 URLs, experiment will not flip any tiles.
SetUpMaybeShuffle(kMinUrlSuggestions - 1, &most_visited_urls, &test_urls);
history::MostVisitedTilesExperiment::MaybeShuffle(&most_visited_urls);
// Ensure no URLs have been switched.
EXPECT_EQ(most_visited_urls[TILE_ONE].url.spec(),
test_urls[TILE_ONE].url.spec());
EXPECT_EQ(most_visited_urls[TILE_EIGHT - 1].url.spec(),
test_urls[TILE_EIGHT - 1].url.spec());
// Ensure counts are correct.
EXPECT_NO_FATAL_FAILURE(
ValidateMetrics(NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_8));
}
TEST_F(MostVisitedTilesExperimentTest, MaybeShuffleOneFour) {
base::FieldTrialList::CreateFieldTrial(kMostVisitedFieldTrialName,
kOneFourAGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_EQ(kOneFourAGroupName,
base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName));
MostVisitedURLList most_visited_urls;
MostVisitedURLList test_urls;
SetUpMaybeShuffle(kMinUrlSuggestions, &most_visited_urls, &test_urls);
history::MostVisitedTilesExperiment::MaybeShuffle(&most_visited_urls);
// Ensure the 1st and 4th URLs have been switched.
EXPECT_EQ(most_visited_urls[TILE_ONE].url.spec(),
test_urls[TILE_FOUR].url.spec());
}
TEST_F(MostVisitedTilesExperimentTest, MaybeShuffleOneFourTooFewURLs) {
base::FieldTrialList::CreateFieldTrial(
kMostVisitedFieldTrialName,
kOneFourAGroupName);
// Ensure the field trial is created with the correct group.
EXPECT_EQ(kOneFourAGroupName,
base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName));
MostVisitedURLList most_visited_urls;
MostVisitedURLList test_urls;
// If |most_visited_urls| has < 4 URLs, experiment will not flip any tiles.
SetUpMaybeShuffle(kMinUrlSuggestions - 5, &most_visited_urls, &test_urls);
history::MostVisitedTilesExperiment::MaybeShuffle(&most_visited_urls);
// Ensure no URLs have been switched.
EXPECT_EQ(most_visited_urls[TILE_ONE].url.spec(),
test_urls[TILE_ONE].url.spec());
EXPECT_EQ(most_visited_urls[TILE_FOUR-1].url.spec(),
test_urls[TILE_FOUR-1].url.spec());
// Ensure counts are correct.
EXPECT_NO_FATAL_FAILURE(
ValidateMetrics(NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_4));
}
} // namespace history
......@@ -5,7 +5,6 @@
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/most_visited_tiles_experiment.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/instant_io_context.h"
......@@ -265,8 +264,6 @@ void InstantService::OnRendererProcessTerminated(int process_id) {
void InstantService::OnMostVisitedItemsReceived(
const history::MostVisitedURLList& data) {
history::MostVisitedURLList reordered_data(data);
history::MostVisitedTilesExperiment::MaybeShuffle(&reordered_data);
std::vector<InstantMostVisitedItem> new_most_visited_items;
for (size_t i = 0; i < reordered_data.size(); i++) {
const history::MostVisitedURL& url = reordered_data[i];
......
......@@ -11,7 +11,6 @@
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/most_visited_tiles_experiment.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_factory.h"
......@@ -419,27 +418,13 @@ void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) {
void SearchTabHelper::MostVisitedItemsChanged(
const std::vector<InstantMostVisitedItem>& items) {
std::vector<InstantMostVisitedItem> items_copy(items);
MaybeRemoveMostVisitedItems(&items_copy);
ipc_router_.SendMostVisitedItems(items_copy);
ipc_router_.SendMostVisitedItems(items);
}
void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) {
ipc_router_.SetOmniboxStartMargin(omnibox_start_margin);
}
void SearchTabHelper::MaybeRemoveMostVisitedItems(
std::vector<InstantMostVisitedItem>* items) {
if (!delegate_)
return;
if (!history::MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled())
return;
history::MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs(
delegate_->GetOpenUrls(), items);
}
void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) {
// TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef.
#if !defined(OS_ANDROID)
......
......@@ -183,11 +183,6 @@ class SearchTabHelper : public content::WebContentsObserver,
const std::vector<InstantMostVisitedItem>& items) OVERRIDE;
virtual void OmniboxStartMarginChanged(int omnibox_start_margin) OVERRIDE;
// Removes recommended URLs if a matching URL is already open in the Browser,
// if the Most Visited Tile Placement experiment is enabled, and the client is
// in the experiment group.
void MaybeRemoveMostVisitedItems(std::vector<InstantMostVisitedItem>* items);
// Sets the mode of the model based on the current URL of web_contents().
// Only updates the origin part of the mode if |update_origin| is true,
// otherwise keeps the current origin. If |is_preloaded_ntp| is true, the mode
......
......@@ -21,8 +21,6 @@
#include "base/threading/thread.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/most_visited_tiles_experiment.h"
#include "chrome/browser/history/page_usage_data.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/thumbnails/thumbnail_list_source.h"
......@@ -144,12 +142,9 @@ void MostVisitedHandler::SendPagesValue() {
profile->GetPrefs()->GetDictionary(prefs::kNtpMostVisitedURLsBlacklist);
bool has_blacklisted_urls = !url_blacklist->empty();
history::TopSites* ts = profile->GetTopSites();
if (ts) {
if (ts)
has_blacklisted_urls = ts->HasBlacklistedItems();
MaybeRemovePageValues();
}
base::FundamentalValue has_blacklisted_urls_value(has_blacklisted_urls);
web_ui()->CallJavascriptFunction("ntp.setMostVisitedPages",
*pages_value_,
......@@ -223,8 +218,6 @@ void MostVisitedHandler::SetPagesValueFromTopSites(
pages_value_.reset(new base::ListValue);
history::MostVisitedURLList top_sites(data);
history::MostVisitedTilesExperiment::MaybeShuffle(&top_sites);
for (size_t i = 0; i < top_sites.size(); i++) {
const history::MostVisitedURL& url = top_sites[i];
base::DictionaryValue* page_value = new base::DictionaryValue();
......@@ -269,25 +262,6 @@ std::string MostVisitedHandler::GetDictionaryKeyForUrl(const std::string& url) {
return base::MD5String(url);
}
void MostVisitedHandler::MaybeRemovePageValues() {
if (!history::MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled())
return;
TabStripModel* tab_strip_model = chrome::FindBrowserWithWebContents(
web_ui()->GetWebContents())->tab_strip_model();
history::TopSites* top_sites = Profile::FromWebUI(web_ui())->GetTopSites();
if (!tab_strip_model || !top_sites) {
NOTREACHED();
return;
}
std::set<std::string> open_urls;
chrome::GetOpenUrls(*tab_strip_model, *top_sites, &open_urls);
history::MostVisitedTilesExperiment::RemovePageValuesMatchingOpenTabs(
open_urls,
pages_value_.get());
}
// static
void MostVisitedHandler::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
......
......@@ -89,11 +89,6 @@ class MostVisitedHandler : public content::WebUIMessageHandler,
// Returns the key used in url_blacklist_ for the passed |url|.
std::string GetDictionaryKeyForUrl(const std::string& url);
// Removes recommended URLs if a matching URL is already open in the Browser,
// if the Most Visited Tile Placement experiment is enabled, and the client is
// in the experiment group.
void MaybeRemovePageValues();
// Sends pages_value_ to the javascript side and resets page_value_.
void SendPagesValue();
......
......@@ -559,8 +559,6 @@
'browser/history/in_memory_url_index.h',
'browser/history/in_memory_url_index_types.cc',
'browser/history/in_memory_url_index_types.h',
'browser/history/most_visited_tiles_experiment.cc',
'browser/history/most_visited_tiles_experiment.h',
'browser/history/page_usage_data.cc',
'browser/history/page_usage_data.h',
'browser/history/scored_history_match.cc',
......
......@@ -1010,7 +1010,6 @@
'browser/history/history_unittest_base.h',
'browser/history/in_memory_url_index_types_unittest.cc',
'browser/history/in_memory_url_index_unittest.cc',
'browser/history/most_visited_tiles_experiment_unittest.cc',
'browser/history/scored_history_match_unittest.cc',
'browser/history/select_favicon_frames_unittest.cc',
'browser/history/shortcuts_database_unittest.cc',
......
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