| Index: chrome/browser/ui/webui/ntp/most_visited_handler.cc
|
| diff --git a/chrome/browser/ui/webui/ntp/most_visited_handler.cc b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
|
| index 5574ceba17d07202ea73b551fec9047196c1358d..822461036647794aa9217d74dff931e01ea870f1 100644
|
| --- a/chrome/browser/ui/webui/ntp/most_visited_handler.cc
|
| +++ b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
|
| @@ -12,7 +12,6 @@
|
| #include "base/md5.h"
|
| #include "base/memory/scoped_vector.h"
|
| #include "base/memory/singleton.h"
|
| -#include "base/metrics/field_trial.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/prefs/pref_service.h"
|
| #include "base/strings/string16.h"
|
| @@ -52,14 +51,6 @@ using content::UserMetricsAction;
|
|
|
| namespace {
|
|
|
| -// Constants for the most visited tile placement field trial.
|
| -const char kMostVisitedFieldTrialName[] = "MostVisitedTilePlacement";
|
| -const char kTabsGroupName[] = "DontShowOpenTabs";
|
| -
|
| -// Minimum number of suggestions that |pages_value_| must hold for the Most
|
| -// Visited Field Trial to remove a URL if already open in the browser.
|
| -const size_t kMinUrlSuggestions = 8;
|
| -
|
| // Creates a set containing the canonical URLs of the currently open tabs.
|
| void GetOpenUrls(const TabStripModel& tabs,
|
| const history::TopSites& ts,
|
| @@ -170,15 +161,7 @@ void MostVisitedHandler::SendPagesValue() {
|
| if (ts) {
|
| has_blacklisted_urls = ts->HasBlacklistedItems();
|
|
|
| - // The following experiment removes recommended URLs if a matching URL is
|
| - // already open in the Browser. Note: this 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.
|
| - if (base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName) ==
|
| - kTabsGroupName) {
|
| - RemovePageValuesMatchingOpenTabs();
|
| - }
|
| + MaybeRemovePageValues();
|
| }
|
|
|
| base::FundamentalValue has_blacklisted_urls_value(has_blacklisted_urls);
|
| @@ -299,8 +282,11 @@ std::string MostVisitedHandler::GetDictionaryKeyForUrl(const std::string& url) {
|
| return base::MD5String(url);
|
| }
|
|
|
| -void MostVisitedHandler::RemovePageValuesMatchingOpenTabs() {
|
| +void MostVisitedHandler::MaybeRemovePageValues() {
|
| #if !defined(OS_ANDROID)
|
| + if (!history::TopSites::IsClientInTabsGroup())
|
| + return;
|
| +
|
| TabStripModel* tab_strip_model = chrome::FindBrowserWithWebContents(
|
| web_ui()->GetWebContents())->tab_strip_model();
|
| history::TopSites* ts = Profile::FromWebUI(web_ui())->GetTopSites();
|
| @@ -309,23 +295,11 @@ void MostVisitedHandler::RemovePageValuesMatchingOpenTabs() {
|
| return;
|
| }
|
|
|
| - // Iterate through most visited suggestions and remove pages already open in
|
| - // current browser, making sure to not drop below 8 suggestions.
|
| std::set<std::string> open_urls;
|
| GetOpenUrls(*tab_strip_model, *ts, &open_urls);
|
| - size_t i = 0;
|
| - while (i < pages_value_->GetSize() &&
|
| - pages_value_->GetSize() > kMinUrlSuggestions) {
|
| - base::DictionaryValue* page_value;
|
| - std::string url;
|
| - if (pages_value_->GetDictionary(i, &page_value) &&
|
| - page_value->GetString("url", &url) &&
|
| - open_urls.count(url) != 0) {
|
| - pages_value_->Remove(*page_value, &i);
|
| - } else {
|
| - ++i;
|
| - }
|
| - }
|
| + history::TopSites::RemovePageValuesMatchingOpenTabs(
|
| + open_urls,
|
| + pages_value_.get());
|
| #endif
|
| }
|
|
|
|
|