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

Unified Diff: chrome/browser/ui/webui/ntp/android/promo_handler.cc

Issue 11689004: Move PromoResourceService from Profile to BrowserProcessImpl/local_state(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 12 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/android/promo_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/android/promo_handler.cc b/chrome/browser/ui/webui/ntp/android/promo_handler.cc
index 64d421632ed69fba0bb1e84671bc9f8a64752bbd..14b6b93c68dfdd78dd42c96096aab6cfe86ec646 100644
--- a/chrome/browser/ui/webui/ntp/android/promo_handler.cc
+++ b/chrome/browser/ui/webui/ntp/android/promo_handler.cc
@@ -50,8 +50,8 @@ void RecordImpressionOnHistogram(PromoImpressionBuckets type) {
}
// Helper to ask whether the promo is active.
-bool CanShowNotificationPromo(Profile* profile) {
- NotificationPromo notification_promo(profile);
+bool CanShowNotificationPromo() {
+ NotificationPromo notification_promo;
notification_promo.InitFromPrefs(NotificationPromo::MOBILE_NTP_SYNC_PROMO);
return notification_promo.CanShow();
}
@@ -175,11 +175,10 @@ void PromoHandler::HandlePromoSendEmail(const base::ListValue* args) {
}
void PromoHandler::HandlePromoActionTriggered(const base::ListValue* /*args*/) {
- Profile* profile = Profile::FromWebUI(web_ui());
- if (!profile || !CanShowNotificationPromo(profile))
+ if (!CanShowNotificationPromo())
return;
- NotificationPromoMobileNtp promo(profile);
+ NotificationPromoMobileNtp promo;
if (!promo.InitFromPrefs())
return;
@@ -188,12 +187,10 @@ void PromoHandler::HandlePromoActionTriggered(const base::ListValue* /*args*/) {
}
void PromoHandler::HandlePromoDisabled(const base::ListValue* /*args*/) {
- Profile* profile = Profile::FromWebUI(web_ui());
- if (!profile || !CanShowNotificationPromo(profile))
+ if (!CanShowNotificationPromo())
return;
- NotificationPromo::HandleClosed(
- profile, NotificationPromo::MOBILE_NTP_SYNC_PROMO);
+ NotificationPromo::HandleClosed(NotificationPromo::MOBILE_NTP_SYNC_PROMO);
RecordImpressionOnHistogram(PROMO_IMPRESSION_CLOSE_PROMO_CLICKED);
content::NotificationService* service =
@@ -225,9 +222,7 @@ void PromoHandler::InjectPromoDecorations() {
void PromoHandler::RecordPromotionImpression(const std::string& id) {
// Update number of views a promotion has received and trigger refresh
// if it exceeded max_views set for the promotion.
- Profile* profile = Profile::FromWebUI(web_ui());
- if (profile &&
- NotificationPromo::HandleViewed(profile,
+ if (NotificationPromo::HandleViewed(
NotificationPromo::MOBILE_NTP_SYNC_PROMO)) {
Notify(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
}
@@ -244,11 +239,10 @@ void PromoHandler::RecordPromotionImpression(const std::string& id) {
bool PromoHandler::FetchPromotion(DictionaryValue* result) {
DCHECK(result != NULL);
- Profile* profile = Profile::FromWebUI(web_ui());
- if (!profile || !CanShowNotificationPromo(profile))
+ if (!CanShowNotificationPromo())
return false;
- NotificationPromoMobileNtp promo(profile);
+ NotificationPromoMobileNtp promo;
if (!promo.InitFromPrefs())
return false;

Powered by Google App Engine
This is Rietveld 408576698