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

Unified Diff: chrome/browser/ui/webui/ntp/most_visited_handler.cc

Issue 7554008: Removal of Profile from content part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 4 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/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 73a1363ae3a93a056506964a176dab6d21a687d7..b9f6ec16f13f69221c1e338596921eca64637c13 100644
--- a/chrome/browser/ui/webui/ntp/most_visited_handler.cc
+++ b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
@@ -29,6 +29,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/user_metrics.h"
#include "content/common/notification_source.h"
#include "googleurl/src/gurl.h"
@@ -54,7 +55,8 @@ MostVisitedHandler::~MostVisitedHandler() {
}
WebUIMessageHandler* MostVisitedHandler::Attach(WebUI* web_ui) {
- Profile* profile = web_ui->GetProfile();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui->tab_contents()->browser_context());
// Set up our sources for thumbnail and favicon data.
ThumbnailSource* thumbnail_src = new ThumbnailSource(profile);
profile->GetChromeURLDataManager()->AddDataSource(thumbnail_src);
@@ -114,7 +116,8 @@ void MostVisitedHandler::HandleGetMostVisited(const ListValue* args) {
void MostVisitedHandler::SendPagesValue() {
if (pages_value_.get()) {
- Profile* profile = web_ui_->GetProfile();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
const DictionaryValue* url_blacklist =
profile->GetPrefs()->GetDictionary(prefs::kNTPMostVisitedURLsBlacklist);
bool has_blacklisted_urls = !url_blacklist->empty();
@@ -130,7 +133,9 @@ void MostVisitedHandler::SendPagesValue() {
}
void MostVisitedHandler::StartQueryForMostVisited() {
- history::TopSites* ts = web_ui_->GetProfile()->GetTopSites();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ history::TopSites* ts = profile->GetTopSites();
if (ts) {
ts->GetMostVisitedURLs(
&topsites_consumer_,
@@ -155,7 +160,9 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const ListValue* args) {
return;
}
UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlRemoved"));
- history::TopSites* ts = web_ui_->GetProfile()->GetTopSites();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ history::TopSites* ts = profile->GetTopSites();
if (ts)
ts->RemoveBlacklistedURL(GURL(url));
}
@@ -164,7 +171,9 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const ListValue* args) {
void MostVisitedHandler::HandleClearBlacklist(const ListValue* args) {
UserMetrics::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"));
- history::TopSites* ts = web_ui_->GetProfile()->GetTopSites();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ history::TopSites* ts = profile->GetTopSites();
if (ts)
ts->ClearBlacklistedURLs();
}
@@ -204,7 +213,9 @@ void MostVisitedHandler::HandleAddPinnedURL(const ListValue* args) {
}
void MostVisitedHandler::AddPinnedURL(const MostVisitedPage& page, int index) {
- history::TopSites* ts = web_ui_->GetProfile()->GetTopSites();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ history::TopSites* ts = profile->GetTopSites();
if (ts)
ts->AddPinnedURL(page.url, index);
UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlPinned"));
@@ -216,7 +227,9 @@ void MostVisitedHandler::HandleRemovePinnedURL(const ListValue* args) {
}
void MostVisitedHandler::RemovePinnedURL(const GURL& url) {
- history::TopSites* ts = web_ui_->GetProfile()->GetTopSites();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ history::TopSites* ts = profile->GetTopSites();
if (ts)
ts->RemovePinnedURL(url);
UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlUnpinned"));
@@ -228,7 +241,9 @@ bool MostVisitedHandler::GetPinnedURLAtIndex(int index,
// 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 = web_ui_->GetProfile()->GetPrefs();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ PrefService* prefs = profile->GetPrefs();
const DictionaryValue* pinned_urls =
prefs->GetDictionary(prefs::kNTPMostVisitedPinnedURLs);
for (DictionaryValue::key_iterator it = pinned_urls->begin_keys();
@@ -297,7 +312,9 @@ void MostVisitedHandler::SetPagesValueFromTopSites(
page_value->SetString("faviconDominantColor", "rgb(63, 132, 197)");
}
- history::TopSites* ts = web_ui_->GetProfile()->GetTopSites();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ history::TopSites* ts = profile->GetTopSites();
if (ts && ts->IsURLPinned(url.url))
page_value->SetBoolean("pinned", true);
pages_value_->Append(page_value);
@@ -322,7 +339,9 @@ void MostVisitedHandler::Observe(int type,
}
void MostVisitedHandler::BlacklistURL(const GURL& url) {
- history::TopSites* ts = web_ui_->GetProfile()->GetTopSites();
+ Profile* profile =
+ Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
+ history::TopSites* ts = profile->GetTopSites();
if (ts)
ts->AddBlacklistedURL(url);
UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted"));

Powered by Google App Engine
This is Rietveld 408576698