| Index: chrome/browser/web_resource/promo_resource_service.h
|
| ===================================================================
|
| --- chrome/browser/web_resource/promo_resource_service.h (revision 97719)
|
| +++ chrome/browser/web_resource/promo_resource_service.h (working copy)
|
| @@ -11,16 +11,11 @@
|
| #include "chrome/browser/web_resource/web_resource_service.h"
|
| #include "chrome/common/chrome_version_info.h"
|
|
|
| +namespace base {
|
| + class DictionaryValue;
|
| +}
|
| +
|
| class Profile;
|
| -
|
| -namespace PromoResourceServiceUtil {
|
| -
|
| -// Certain promotions should only be shown to certain classes of users. This
|
| -// function will change to reflect each kind of promotion.
|
| -bool CanShowPromo(Profile* profile);
|
| -
|
| -} // namespace PromoResourceServiceUtil
|
| -
|
| class PrefService;
|
|
|
| // A PromoResourceService fetches data from a web resource server to be used to
|
| @@ -34,8 +29,8 @@
|
| class PromoResourceService
|
| : public WebResourceService {
|
| public:
|
| - static bool IsBuildTargeted(chrome::VersionInfo::Channel channel,
|
| - int builds_targeted);
|
| + // Checks for conditions to show promo: start/end times, channel, etc.
|
| + static bool CanShowPromo(Profile* profile);
|
|
|
| static void RegisterPrefs(PrefService* local_state);
|
|
|
| @@ -47,6 +42,7 @@
|
| static const char* kDefaultPromoResourceServer;
|
|
|
| private:
|
| + FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, IsBuildTargeted);
|
| FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackLogoSignal);
|
| FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackPromoSignal);
|
| FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackWebStoreSignal);
|
| @@ -72,6 +68,9 @@
|
|
|
| void Init();
|
|
|
| + static bool IsBuildTargeted(chrome::VersionInfo::Channel channel,
|
| + int builds_targeted);
|
| +
|
| // Returns true if |builds_targeted| includes the release channel Chrome
|
| // belongs to. For testing purposes, you can override the current channel
|
| // with set_channel.
|
| @@ -192,10 +191,39 @@
|
| // answer_id: the promo's id
|
| void UnpackWebStoreSignal(const base::DictionaryValue& parsed_json);
|
|
|
| - // Gets mutable dictionary attached to user's preferences, so that we
|
| - // can write resource data back to user's pref file.
|
| - base::DictionaryValue* web_resource_cache_;
|
| + // Parse the answers array element.
|
| + void ParsePromo(base::DictionaryValue* a_dic,
|
| + std::string* promo_start_string,
|
| + std::string* promo_end_string);
|
|
|
| + // Set promo params from a question string, which is of the form
|
| + // <build_type>:<time_slice>:<max_group>.
|
| + void SetPromoParams(base::DictionaryValue* a_dic);
|
| +
|
| + // Extract the promo text from the tooltip string.
|
| + void SetPromoLine(base::DictionaryValue* a_dic);
|
| +
|
| + // Check if this promo is new based on start/end times,
|
| + // and trigger events accordingly.
|
| + void CheckForNewPromo(const std::string& promo_start_string,
|
| + const std::string& promo_end_string);
|
| +
|
| + // Calculate the promo times, taking into account our group, and the
|
| + // group time slice.
|
| + void CalculateNewPromoTimes(const std::string& promo_start_string,
|
| + const std::string& promo_end_string,
|
| + double* promo_start,
|
| + double* promo_end);
|
| +
|
| + // Get saved promo times.
|
| + void GetCurrentPromoTimes(double* old_promo_start, double* old_promo_end);
|
| +
|
| + // Create a new promo group.
|
| + int ResetPromoGroup();
|
| +
|
| + // Actions on receiving a new promo.
|
| + void OnNewPromo(double promo_start, double promo_end);
|
| +
|
| // Overrides the current Chrome release channel for testing purposes.
|
| chrome::VersionInfo::Channel channel_;
|
|
|
|
|