| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/browser/platform_util.h" | |
| 12 #include "chrome/browser/web_resource/web_resource_service.h" | 11 #include "chrome/browser/web_resource/web_resource_service.h" |
| 12 #include "chrome/common/chrome_version_info.h" |
| 13 | 13 |
| 14 namespace PromoResourceServiceUtil { | 14 namespace PromoResourceServiceUtil { |
| 15 | 15 |
| 16 // Certain promotions should only be shown to certain classes of users. This | 16 // Certain promotions should only be shown to certain classes of users. This |
| 17 // function will change to reflect each kind of promotion. | 17 // function will change to reflect each kind of promotion. |
| 18 bool CanShowPromo(Profile* profile); | 18 bool CanShowPromo(Profile* profile); |
| 19 | 19 |
| 20 } // namespace PromoResourceServiceUtil | 20 } // namespace PromoResourceServiceUtil |
| 21 | 21 |
| 22 class PrefService; | 22 class PrefService; |
| 23 | 23 |
| 24 // A PromoResourceService fetches data from a web resource server to be used to | 24 // A PromoResourceService fetches data from a web resource server to be used to |
| 25 // dynamically change the appearance of the New Tab Page. For example, it has | 25 // dynamically change the appearance of the New Tab Page. For example, it has |
| 26 // been used to fetch "tips" to be displayed on the NTP, or to display | 26 // been used to fetch "tips" to be displayed on the NTP, or to display |
| 27 // promotional messages to certain groups of Chrome users. | 27 // promotional messages to certain groups of Chrome users. |
| 28 // | 28 // |
| 29 // TODO(mirandac): Arrange for a server to be set up specifically for promo | 29 // TODO(mirandac): Arrange for a server to be set up specifically for promo |
| 30 // messages, which have until now been piggybacked onto the old tips server | 30 // messages, which have until now been piggybacked onto the old tips server |
| 31 // structure. (see http://crbug.com/70634 for details.) | 31 // structure. (see http://crbug.com/70634 for details.) |
| 32 class PromoResourceService | 32 class PromoResourceService |
| 33 : public WebResourceService { | 33 : public WebResourceService { |
| 34 public: | 34 public: |
| 35 static bool IsBuildTargeted(platform_util::Channel channel, | 35 static bool IsBuildTargeted(chrome::VersionInfo::Channel channel, |
| 36 int builds_targeted); | 36 int builds_targeted); |
| 37 | 37 |
| 38 static void RegisterPrefs(PrefService* local_state); | 38 static void RegisterPrefs(PrefService* local_state); |
| 39 | 39 |
| 40 static void RegisterUserPrefs(PrefService* prefs); | 40 static void RegisterUserPrefs(PrefService* prefs); |
| 41 | 41 |
| 42 explicit PromoResourceService(Profile* profile); | 42 explicit PromoResourceService(Profile* profile); |
| 43 | 43 |
| 44 // Default server of dynamically loaded NTP HTML elements. | 44 // Default server of dynamically loaded NTP HTML elements. |
| 45 static const char* kDefaultPromoResourceServer; | 45 static const char* kDefaultPromoResourceServer; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // available or be no longer valid. | 79 // available or be no longer valid. |
| 80 void ScheduleNotification(double ms_start_time, double ms_end_time); | 80 void ScheduleNotification(double ms_start_time, double ms_end_time); |
| 81 | 81 |
| 82 // Schedules the initial notification for when the web resource is going | 82 // Schedules the initial notification for when the web resource is going |
| 83 // to become available or no longer valid. This performs a few additional | 83 // to become available or no longer valid. This performs a few additional |
| 84 // checks than ScheduleNotification, namely it schedules updates immediately | 84 // checks than ScheduleNotification, namely it schedules updates immediately |
| 85 // if the promo service or Chrome locale has changed. | 85 // if the promo service or Chrome locale has changed. |
| 86 void ScheduleNotificationOnInit(); | 86 void ScheduleNotificationOnInit(); |
| 87 | 87 |
| 88 // Overrides the current Chrome release channel for testing purposes. | 88 // Overrides the current Chrome release channel for testing purposes. |
| 89 void set_channel(platform_util::Channel channel) { channel_ = channel; } | 89 void set_channel(chrome::VersionInfo::Channel channel) { channel_ = channel; } |
| 90 | 90 |
| 91 virtual void Unpack(const DictionaryValue& parsed_json); | 91 virtual void Unpack(const DictionaryValue& parsed_json); |
| 92 | 92 |
| 93 // Unpack the web resource as a custom promo signal. Expects a start and end | 93 // Unpack the web resource as a custom promo signal. Expects a start and end |
| 94 // signal, with the promo to be shown in the tooltip of the start signal | 94 // signal, with the promo to be shown in the tooltip of the start signal |
| 95 // field. Delivery will be in json in the form of: | 95 // field. Delivery will be in json in the form of: |
| 96 // { | 96 // { |
| 97 // "topic": { | 97 // "topic": { |
| 98 // "answers": [ | 98 // "answers": [ |
| 99 // { | 99 // { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // the logo image. In the example above, the URL is empty so the | 188 // the logo image. In the example above, the URL is empty so the |
| 189 // default webstore logo will be used. | 189 // default webstore logo will be used. |
| 190 // answer_id: the promo's id | 190 // answer_id: the promo's id |
| 191 void UnpackWebStoreSignal(const DictionaryValue& parsed_json); | 191 void UnpackWebStoreSignal(const DictionaryValue& parsed_json); |
| 192 | 192 |
| 193 // Gets mutable dictionary attached to user's preferences, so that we | 193 // Gets mutable dictionary attached to user's preferences, so that we |
| 194 // can write resource data back to user's pref file. | 194 // can write resource data back to user's pref file. |
| 195 DictionaryValue* web_resource_cache_; | 195 DictionaryValue* web_resource_cache_; |
| 196 | 196 |
| 197 // Overrides the current Chrome release channel for testing purposes. | 197 // Overrides the current Chrome release channel for testing purposes. |
| 198 platform_util::Channel channel_; | 198 chrome::VersionInfo::Channel channel_; |
| 199 | 199 |
| 200 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); | 200 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 203 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| OLD | NEW |