Chromium Code Reviews| Index: chrome/browser/web_resource/promo_resource_service.cc |
| =================================================================== |
| --- chrome/browser/web_resource/promo_resource_service.cc (revision 140104) |
| +++ chrome/browser/web_resource/promo_resource_service.cc (working copy) |
| @@ -44,13 +44,11 @@ |
| static const char kWebStoreLinkProperty[] = "inproduct"; |
| static const char kWebStoreExpireProperty[] = "tooltip"; |
| -GURL GetPromoResourceURL(bool legacy) { |
| +GURL GetPromoResourceURL() { |
| const std::string promo_server_url = CommandLine::ForCurrentProcess()-> |
| GetSwitchValueASCII(switches::kPromoServerURL); |
| - if (!promo_server_url.empty()) |
| - return GURL(promo_server_url); |
| - return legacy ? GURL(PromoResourceService::kDefaultPromoResourceServer) : |
| - NotificationPromo::PromoServerURL(); |
| + return promo_server_url.empty() ? |
| + NotificationPromo::PromoServerURL() : GURL(promo_server_url); |
| } |
| bool IsTest() { |
| @@ -63,12 +61,6 @@ |
| } // namespace |
| -// Server for dynamically loaded NTP HTML elements. |
|
Dan Beam
2012/06/04 21:26:32
at the moment this is the URL we can get the webst
achuithb
2012/06/04 23:06:09
You're right. So there is no access to the tips se
|
| -const char* PromoResourceService::kDefaultPromoResourceServer = |
| - "https://www.google.com/support/chrome/bin/topic/1142433/inproduct?hl="; |
| - |
| - |
| - |
| // static |
| void PromoResourceService::RegisterPrefs(PrefService* local_state) { |
| local_state->RegisterIntegerPref(prefs::kNtpPromoVersion, 0); |
| @@ -122,7 +114,7 @@ |
| PromoResourceService::PromoResourceService(Profile* profile) |
| : WebResourceService(profile->GetPrefs(), |
| - GetPromoResourceURL(false), |
| + GetPromoResourceURL(), |
| true, // append locale to URL |
| prefs::kNtpPromoResourceCacheUpdate, |
| kStartResourceFetchDelay, |
| @@ -149,13 +141,6 @@ |
| UnpackWebStoreSignal(parsed_json); |
| } |
| -void PromoResourceService::OnNotificationParsed(double start, double end, |
| - bool new_notification) { |
| - if (new_notification) { |
| - ScheduleNotification(start, end); |
| - } |
| -} |
| - |
| void PromoResourceService::ScheduleNotification(double promo_start, |
| double promo_end) { |
| if (promo_start > 0 && promo_end > 0) { |
| @@ -179,10 +164,13 @@ |
| void PromoResourceService::ScheduleNotificationOnInit() { |
| std::string locale = g_browser_process->GetApplicationLocale(); |
| - if ((GetPromoServiceVersion() != kPromoServiceVersion) || |
| - (GetPromoLocale() != locale)) { |
| + if (GetPromoServiceVersion() != kPromoServiceVersion || |
| + GetPromoLocale() != locale) { |
| // If the promo service has been upgraded or Chrome switched locales, |
| // refresh the promos. |
| + // TODO(achuith): Mixing local_state and prefs does not work for |
| + // multi-profile case. We should probably store version/locale in prefs_ |
| + // as well. |
| PrefService* local_state = g_browser_process->local_state(); |
| local_state->SetInteger(prefs::kNtpPromoVersion, kPromoServiceVersion); |
| local_state->SetString(prefs::kNtpPromoLocale, locale); |
| @@ -234,16 +222,19 @@ |
| void PromoResourceService::UnpackNotificationSignal( |
| const DictionaryValue& parsed_json) { |
| - scoped_refptr<NotificationPromo> notification_promo = |
| - NotificationPromo::Create(profile_, this); |
| - notification_promo->InitFromJson(parsed_json); |
| + NotificationPromo notification_promo(profile_); |
| + notification_promo.InitFromJson(parsed_json); |
| + |
| + if (notification_promo.new_notification()) { |
| + ScheduleNotification(notification_promo.StartTimeForGroup(), |
| + notification_promo.EndTime()); |
| + } |
| } |
| bool PromoResourceService::CanShowNotificationPromo(Profile* profile) { |
| - scoped_refptr<NotificationPromo> notification_promo = |
| - NotificationPromo::Create(profile, NULL); |
| - notification_promo->InitFromPrefs(); |
| - return notification_promo->CanShow(); |
| + NotificationPromo notification_promo(profile); |
| + notification_promo.InitFromPrefs(); |
| + return notification_promo.CanShow(); |
| } |
| void PromoResourceService::UnpackWebStoreSignal( |