| 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;
|
|
|
|
|