Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Unified Diff: chrome/browser/dom_ui/most_visited_handler.cc

Issue 6283001: Remove TopSites::IsEnabled() as well as related dead code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/dom_ui/most_visited_handler.cc
diff --git a/chrome/browser/dom_ui/most_visited_handler.cc b/chrome/browser/dom_ui/most_visited_handler.cc
index 86f3dddea599b135d46c471a336690cf43716bd9..a35070f7d8a25029a83e80ea53d2b03d981488b0 100644
--- a/chrome/browser/dom_ui/most_visited_handler.cc
+++ b/chrome/browser/dom_ui/most_visited_handler.cc
@@ -132,11 +132,9 @@ void MostVisitedHandler::HandleGetMostVisited(const ListValue* args) {
void MostVisitedHandler::SendPagesValue() {
if (pages_value_.get()) {
bool has_blacklisted_urls = !url_blacklist_->empty();
- if (history::TopSites::IsEnabled()) {
- history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
- if (ts)
- has_blacklisted_urls = ts->HasBlacklistedItems();
- }
+ history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
+ if (ts)
+ has_blacklisted_urls = ts->HasBlacklistedItems();
FundamentalValue first_run(IsFirstRun());
FundamentalValue has_blacklisted_urls_value(has_blacklisted_urls);
dom_ui_->CallJavascriptFunction(L"mostVisitedPages",
@@ -148,32 +146,12 @@ void MostVisitedHandler::SendPagesValue() {
}
void MostVisitedHandler::StartQueryForMostVisited() {
- if (history::TopSites::IsEnabled()) {
- // Use TopSites.
- history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
- if (ts) {
- ts->GetMostVisitedURLs(
- &topsites_consumer_,
- NewCallback(this, &MostVisitedHandler::OnMostVisitedURLsAvailable));
- }
- return;
- }
-
- const int page_count = kMostVisitedPages;
- // Let's query for the number of items we want plus the blacklist size as
- // we'll be filtering-out the returned list with the blacklist URLs.
- // We do not subtract the number of pinned URLs we have because the
- // HistoryService does not know about those.
- const int result_count = page_count + url_blacklist_->size();
- HistoryService* hs =
- dom_ui_->GetProfile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
- // |hs| may be null during unit tests.
- if (hs) {
- hs->QuerySegmentUsageSince(
- &cancelable_consumer_,
- base::Time::Now() - base::TimeDelta::FromDays(kMostVisitedScope),
- result_count,
- NewCallback(this, &MostVisitedHandler::OnSegmentUsageAvailable));
+ // Use TopSites.
+ history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
+ if (ts) {
+ ts->GetMostVisitedURLs(
+ &topsites_consumer_,
+ NewCallback(this, &MostVisitedHandler::OnMostVisitedURLsAvailable));
}
}
@@ -195,15 +173,9 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const ListValue* args) {
}
UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlRemoved"),
dom_ui_->GetProfile());
- if (history::TopSites::IsEnabled()) {
- history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
- if (ts)
- ts->RemoveBlacklistedURL(GURL(url));
- return;
- }
-
- r = url_blacklist_->Remove(GetDictionaryKeyForURL(url), NULL);
- DCHECK(r) << "Unknown URL removed from the NTP Most Visited blacklist.";
+ history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
+ if (ts)
+ ts->RemoveBlacklistedURL(GURL(url));
}
}
@@ -211,14 +183,9 @@ void MostVisitedHandler::HandleClearBlacklist(const ListValue* args) {
UserMetrics::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"),
dom_ui_->GetProfile());
- if (history::TopSites::IsEnabled()) {
- history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
- if (ts)
- ts->ClearBlacklistedURLs();
- return;
- }
-
- url_blacklist_->Clear();
+ history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
+ if (ts)
+ ts->ClearBlacklistedURLs();
}
void MostVisitedHandler::HandleAddPinnedURL(const ListValue* args) {
@@ -256,28 +223,9 @@ void MostVisitedHandler::HandleAddPinnedURL(const ListValue* args) {
}
void MostVisitedHandler::AddPinnedURL(const MostVisitedPage& page, int index) {
- if (history::TopSites::IsEnabled()) {
- history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
- if (ts)
- ts->AddPinnedURL(page.url, index);
- return;
- }
-
- // Remove any pinned URL at the given index.
- MostVisitedPage old_page;
- if (GetPinnedURLAtIndex(index, &old_page)) {
- RemovePinnedURL(old_page.url);
- }
-
- DictionaryValue* new_value = new DictionaryValue();
- SetMostVisistedPage(new_value, page);
-
- new_value->SetInteger("index", index);
- pinned_urls_->Set(GetDictionaryKeyForURL(page.url.spec()), new_value);
-
- // TODO(arv): Notify observers?
-
- // Don't call HandleGetMostVisited. Let the client call this as needed.
+ history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
+ if (ts)
+ ts->AddPinnedURL(page.url, index);
}
void MostVisitedHandler::HandleRemovePinnedURL(const ListValue* args) {
@@ -286,20 +234,9 @@ void MostVisitedHandler::HandleRemovePinnedURL(const ListValue* args) {
}
void MostVisitedHandler::RemovePinnedURL(const GURL& url) {
- if (history::TopSites::IsEnabled()) {
- history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
- if (ts)
- ts->RemovePinnedURL(url);
- return;
- }
-
- const std::string key = GetDictionaryKeyForURL(url.spec());
- if (pinned_urls_->HasKey(key))
- pinned_urls_->Remove(key, NULL);
-
- // TODO(arv): Notify observers?
-
- // Don't call HandleGetMostVisited. Let the client call this as needed.
+ history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
+ if (ts)
+ ts->RemovePinnedURL(url);
}
bool MostVisitedHandler::GetPinnedURLAtIndex(int index,
@@ -420,7 +357,6 @@ void MostVisitedHandler::SetPagesValue(std::vector<PageUsageData*>* data) {
void MostVisitedHandler::SetPagesValueFromTopSites(
const history::MostVisitedURLList& data) {
- DCHECK(history::TopSites::IsEnabled());
pages_value_.reset(new ListValue);
for (size_t i = 0; i < data.size(); i++) {
const history::MostVisitedURL& url = data[i];
@@ -522,19 +458,9 @@ void MostVisitedHandler::Observe(NotificationType type,
}
void MostVisitedHandler::BlacklistURL(const GURL& url) {
- if (history::TopSites::IsEnabled()) {
- history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
- if (ts)
- ts->AddBlacklistedURL(url);
- return;
- }
-
- RemovePinnedURL(url);
-
- std::string key = GetDictionaryKeyForURL(url.spec());
- if (url_blacklist_->HasKey(key))
- return;
- url_blacklist_->SetBoolean(key, true);
+ history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
+ if (ts)
+ ts->AddBlacklistedURL(url);
}
std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) {

Powered by Google App Engine
This is Rietveld 408576698