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

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: android x 4 Created 8 years 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..086510430e4dfefaa3c356bddec3d1ff49884881 100644
--- a/chrome/browser/ui/webui/ntp/android/promo_handler.cc
+++ b/chrome/browser/ui/webui/ntp/android/promo_handler.cc
@@ -11,6 +11,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/android/intent_helper.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -50,8 +51,8 @@ void RecordImpressionOnHistogram(PromoImpressionBuckets type) {
}
// Helper to ask whether the promo is active.
-bool CanShowNotificationPromo(Profile* profile) {
- NotificationPromo notification_promo(profile);
+bool CanShowNotificationPromo(PrefServiceSimple* prefs) {
+ NotificationPromo notification_promo(prefs);
notification_promo.InitFromPrefs(NotificationPromo::MOBILE_NTP_SYNC_PROMO);
return notification_promo.CanShow();
}
@@ -175,11 +176,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(g_browser_process->local_state()))
return;
- NotificationPromoMobileNtp promo(profile);
+ NotificationPromoMobileNtp promo(g_browser_process->local_state());
if (!promo.InitFromPrefs())
return;
@@ -188,12 +188,11 @@ 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(g_browser_process->local_state()))
return;
- NotificationPromo::HandleClosed(
- profile, NotificationPromo::MOBILE_NTP_SYNC_PROMO);
+ NotificationPromo::HandleClosed(g_browser_process->local_state(),
+ NotificationPromo::MOBILE_NTP_SYNC_PROMO);
RecordImpressionOnHistogram(PROMO_IMPRESSION_CLOSE_PROMO_CLICKED);
content::NotificationService* service =
@@ -225,9 +224,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(g_browser_process->local_state(),
NotificationPromo::MOBILE_NTP_SYNC_PROMO)) {
Notify(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
}
@@ -244,11 +241,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(g_browser_process->local_state()))
return false;
- NotificationPromoMobileNtp promo(profile);
+ NotificationPromoMobileNtp promo(g_browser_process->local_state());
if (!promo.InitFromPrefs())
return false;

Powered by Google App Engine
This is Rietveld 408576698