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 b3867cebcf4c62df7194fdba60726e6da301faff..600b823f05bd2e5c38fd61412d62a6801e9f42e9 100644 |
--- a/chrome/browser/ui/webui/ntp/most_visited_handler.cc |
+++ b/chrome/browser/ui/webui/ntp/most_visited_handler.cc |
@@ -39,15 +39,6 @@ |
#include "grit/locale_settings.h" |
#include "ui/base/l10n/l10n_util.h" |
-// This struct is used when getting the pre-populated pages in case the user |
-// hasn't filled up his most visited pages. |
-struct MostVisitedHandler::MostVisitedPage { |
- string16 title; |
- GURL url; |
- GURL thumbnail_url; |
- GURL favicon_url; |
-}; |
- |
MostVisitedHandler::MostVisitedHandler() |
: got_first_most_visited_request_(false) { |
} |
@@ -100,14 +91,6 @@ void MostVisitedHandler::RegisterMessages() { |
web_ui_->RegisterMessageCallback("clearMostVisitedURLsBlacklist", |
base::Bind(&MostVisitedHandler::HandleClearBlacklist, |
base::Unretained(this))); |
- |
- // Register ourself for pinned URL messages. |
- web_ui_->RegisterMessageCallback("addPinnedURL", |
- base::Bind(&MostVisitedHandler::HandleAddPinnedURL, |
- base::Unretained(this))); |
- web_ui_->RegisterMessageCallback("removePinnedURL", |
- base::Bind(&MostVisitedHandler::HandleRemovePinnedURL, |
- base::Unretained(this))); |
} |
void MostVisitedHandler::HandleGetMostVisited(const ListValue* args) { |
@@ -178,103 +161,6 @@ void MostVisitedHandler::HandleClearBlacklist(const ListValue* args) { |
ts->ClearBlacklistedURLs(); |
} |
-void MostVisitedHandler::HandleAddPinnedURL(const ListValue* args) { |
- DCHECK_EQ(5U, args->GetSize()) << "Wrong number of params to addPinnedURL"; |
- MostVisitedPage mvp; |
- std::string tmp_string; |
- string16 tmp_string16; |
- int index; |
- |
- bool r = args->GetString(0, &tmp_string); |
- DCHECK(r) << "Missing URL in addPinnedURL from the NTP Most Visited."; |
- mvp.url = GURL(tmp_string); |
- |
- r = args->GetString(1, &tmp_string16); |
- DCHECK(r) << "Missing title in addPinnedURL from the NTP Most Visited."; |
- mvp.title = tmp_string16; |
- |
- r = args->GetString(2, &tmp_string); |
- DCHECK(r) << "Failed to read the favicon URL in addPinnedURL from the NTP " |
- << "Most Visited."; |
- if (!tmp_string.empty()) |
- mvp.favicon_url = GURL(tmp_string); |
- |
- r = args->GetString(3, &tmp_string); |
- DCHECK(r) << "Failed to read the thumbnail URL in addPinnedURL from the NTP " |
- << "Most Visited."; |
- if (!tmp_string.empty()) |
- mvp.thumbnail_url = GURL(tmp_string); |
- |
- r = args->GetString(4, &tmp_string); |
- DCHECK(r) << "Missing index in addPinnedURL from the NTP Most Visited."; |
- base::StringToInt(tmp_string, &index); |
- |
- AddPinnedURL(mvp, index); |
-} |
- |
-void MostVisitedHandler::AddPinnedURL(const MostVisitedPage& page, int index) { |
- history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites(); |
- if (ts) |
- ts->AddPinnedURL(page.url, index); |
- UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlPinned")); |
-} |
- |
-void MostVisitedHandler::HandleRemovePinnedURL(const ListValue* args) { |
- std::string url = UTF16ToUTF8(ExtractStringValue(args)); |
- RemovePinnedURL(GURL(url)); |
-} |
- |
-void MostVisitedHandler::RemovePinnedURL(const GURL& url) { |
- history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites(); |
- if (ts) |
- ts->RemovePinnedURL(url); |
- UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlUnpinned")); |
-} |
- |
-bool MostVisitedHandler::GetPinnedURLAtIndex(int index, |
- MostVisitedPage* page) { |
- // This iterates over all the pinned URLs. It might seem like it is worth |
- // having a map from the index to the item but the number of items is limited |
- // to the number of items the most visited section is showing on the NTP so |
- // this will be fast enough for now. |
- PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); |
- const DictionaryValue* pinned_urls = |
- prefs->GetDictionary(prefs::kNTPMostVisitedPinnedURLs); |
- for (DictionaryValue::key_iterator it = pinned_urls->begin_keys(); |
- it != pinned_urls->end_keys(); ++it) { |
- Value* value; |
- if (pinned_urls->GetWithoutPathExpansion(*it, &value)) { |
- if (!value->IsType(DictionaryValue::TYPE_DICTIONARY)) { |
- // Moved on to TopSites and now going back. |
- DictionaryPrefUpdate update(prefs, prefs::kNTPMostVisitedPinnedURLs); |
- update.Get()->Clear(); |
- return false; |
- } |
- |
- int dict_index; |
- const DictionaryValue* dict = static_cast<DictionaryValue*>(value); |
- if (dict->GetInteger("index", &dict_index) && dict_index == index) { |
- // The favicon and thumbnail URLs may be empty. |
- std::string tmp_string; |
- if (dict->GetString("faviconUrl", &tmp_string)) |
- page->favicon_url = GURL(tmp_string); |
- if (dict->GetString("thumbnailUrl", &tmp_string)) |
- page->thumbnail_url = GURL(tmp_string); |
- |
- if (dict->GetString("url", &tmp_string)) |
- page->url = GURL(tmp_string); |
- else |
- return false; |
- |
- return dict->GetString("title", &page->title); |
- } |
- } else { |
- NOTREACHED() << "DictionaryValue iterators are filthy liars."; |
- } |
- } |
- |
- return false; |
-} |
void MostVisitedHandler::SetPagesValueFromTopSites( |
const history::MostVisitedURLList& data) { |
@@ -306,9 +192,6 @@ void MostVisitedHandler::SetPagesValueFromTopSites( |
page_value->SetString("faviconDominantColor", "rgb(63, 132, 197)"); |
} |
- history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites(); |
- if (ts && ts->IsURLPinned(url.url)) |
- page_value->SetBoolean("pinned", true); |
pages_value_->Append(page_value); |
} |
} |
@@ -345,6 +228,7 @@ std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) { |
void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) { |
prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedURLsBlacklist, |
PrefService::UNSYNCABLE_PREF); |
+ // TODO(estade): remove this. |
prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs, |
PrefService::UNSYNCABLE_PREF); |
} |