summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 01:48:10 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 01:48:10 +0000
commitc1769284e74137c6b476aeffd8ab705ec8d8fdcb (patch)
tree025c81284f2007fe7b0736491c838eade2c2c23f /chrome
parent39a5b53280853e94a95f8cc8b05582cf10e0d88a (diff)
downloadchromium_src-c1769284e74137c6b476aeffd8ab705ec8d8fdcb.zip
chromium_src-c1769284e74137c6b476aeffd8ab705ec8d8fdcb.tar.gz
chromium_src-c1769284e74137c6b476aeffd8ab705ec8d8fdcb.tar.bz2
ntp: remove dead code for pinning
BUG=none TEST=none Review URL: http://codereview.chromium.org/8369017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ui/webui/ntp/most_visited_handler.cc118
-rw-r--r--chrome/browser/ui/webui/ntp/most_visited_handler.h22
2 files changed, 3 insertions, 137 deletions
diff --git a/chrome/browser/ui/webui/ntp/most_visited_handler.cc b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
index b3867ce..600b823 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);
}
diff --git a/chrome/browser/ui/webui/ntp/most_visited_handler.h b/chrome/browser/ui/webui/ntp/most_visited_handler.h
index 22543d8..d34522a 100644
--- a/chrome/browser/ui/webui/ntp/most_visited_handler.h
+++ b/chrome/browser/ui/webui/ntp/most_visited_handler.h
@@ -26,14 +26,10 @@ class Value;
// The handler for Javascript messages related to the "most visited" view.
//
-// This class manages two preferences:
+// This class manages one preference:
// - The URL blacklist: URLs we do not want to show in the thumbnails list. It
// is a dictionary for quick access (it associates a dummy boolean to the URL
// string).
-// - Pinned URLs: This is a dictionary for the pinned URLs for the the most
-// visited part of the new tab page. The key of the dictionary is a hash of
-// the URL and the value is a dictionary with title, url and index. This is
-// owned by the PrefService.
class MostVisitedHandler : public WebUIMessageHandler,
public content::NotificationObserver {
public:
@@ -57,12 +53,6 @@ class MostVisitedHandler : public WebUIMessageHandler,
// Callback for the "clearMostVisitedURLsBlacklist" message.
void HandleClearBlacklist(const base::ListValue* args);
- // Callback for the "addPinnedURL" message.
- void HandleAddPinnedURL(const base::ListValue* args);
-
- // Callback for the "removePinnedURL" message.
- void HandleRemovePinnedURL(const base::ListValue* args);
-
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
@@ -89,17 +79,9 @@ class MostVisitedHandler : public WebUIMessageHandler,
// Puts the passed URL in the blacklist (so it does not show as a thumbnail).
void BlacklistURL(const GURL& url);
- // Returns the key used in url_blacklist_ and pinned_urls_ for the passed
- // |url|.
+ // Returns the key used in url_blacklist_ for the passed |url|.
std::string GetDictionaryKeyForURL(const std::string& url);
- // Gets the page data for a pinned URL at a given index. This returns
- // true if found.
- bool GetPinnedURLAtIndex(int index, MostVisitedPage* page);
-
- void AddPinnedURL(const MostVisitedPage& page, int index);
- void RemovePinnedURL(const GURL& url);
-
// Sends pages_value_ to the javascript side to and resets page_value_.
void SendPagesValue();