| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/web_resource/notification_promo.h" | |
| 12 #include "chrome/browser/web_resource/web_resource_service.h" | 11 #include "chrome/browser/web_resource/web_resource_service.h" |
| 13 | 12 |
| 14 namespace base { | 13 namespace base { |
| 15 class DictionaryValue; | 14 class DictionaryValue; |
| 16 } | 15 } |
| 17 | 16 |
| 17 class NotificationPromo; |
| 18 class PrefService; | 18 class PrefService; |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 // A PromoResourceService fetches data from a web resource server to be used to | 21 // A PromoResourceService fetches data from a web resource server to be used to |
| 22 // dynamically change the appearance of the New Tab Page. For example, it has | 22 // dynamically change the appearance of the New Tab Page. For example, it has |
| 23 // been used to fetch "tips" to be displayed on the NTP, or to display | 23 // been used to fetch "tips" to be displayed on the NTP, or to display |
| 24 // promotional messages to certain groups of Chrome users. | 24 // promotional messages to certain groups of Chrome users. |
| 25 class PromoResourceService : public WebResourceService { | 25 class PromoResourceService : public WebResourceService { |
| 26 public: | 26 public: |
| 27 static void RegisterPrefs(PrefService* local_state); | 27 static void RegisterPrefs(PrefService* local_state); |
| 28 | 28 |
| 29 static void RegisterUserPrefs(PrefService* prefs); | 29 static void RegisterUserPrefs(PrefService* prefs); |
| 30 | 30 |
| 31 explicit PromoResourceService(Profile* profile); | 31 explicit PromoResourceService(Profile* profile); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 virtual ~PromoResourceService(); | 34 virtual ~PromoResourceService(); |
| 35 | 35 |
| 36 int GetPromoServiceVersion(); | 36 int GetPromoServiceVersion(); |
| 37 | 37 |
| 38 // Gets the locale of the last promos fetched from the server. This is saved | 38 // Gets the locale of the last promos fetched from the server. This is saved |
| 39 // so we can fetch new data if the locale changes. | 39 // so we can fetch new data if the locale changes. |
| 40 std::string GetPromoLocale(); | 40 std::string GetPromoLocale(); |
| 41 | 41 |
| 42 // Schedule a notification that a web resource is either going to become | 42 // Schedule a notification that a web resource is either going to become |
| 43 // available or be no longer valid. | 43 // available or be no longer valid. |
| 44 void ScheduleNotification(double start, double end); | 44 void ScheduleNotification(const NotificationPromo& notification_promo); |
| 45 | 45 |
| 46 // Schedules the initial notification for when the web resource is going | 46 // Schedules the initial notification for when the web resource is going |
| 47 // to become available or no longer valid. This performs a few additional | 47 // to become available or no longer valid. This performs a few additional |
| 48 // checks than ScheduleNotification, namely it schedules updates immediately | 48 // checks than ScheduleNotification, namely it schedules updates immediately |
| 49 // if the promo service or Chrome locale has changed. | 49 // if the promo service or Chrome locale has changed. |
| 50 void ScheduleNotificationOnInit(); | 50 void ScheduleNotificationOnInit(); |
| 51 | 51 |
| 52 // If delay_ms is positive, schedule notification with the delay. | 52 // If delay_ms is positive, schedule notification with the delay. |
| 53 // If delay_ms is 0, notify immediately by calling WebResourceStateChange(). | 53 // If delay_ms is 0, notify immediately by calling WebResourceStateChange(). |
| 54 // If delay_ms is negative, do nothing. | 54 // If delay_ms is negative, do nothing. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 68 // when a new web resource should be shown or removed. | 68 // when a new web resource should be shown or removed. |
| 69 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; | 69 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; |
| 70 | 70 |
| 71 // Notification type when an update is done. | 71 // Notification type when an update is done. |
| 72 int notification_type_; | 72 int notification_type_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); | 74 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 77 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| OLD | NEW |