| 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 COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ | 5 #ifndef COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ |
| 6 #define COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ | 6 #define COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Returns the variations server URL, which can vary if a command-line flag is | 114 // Returns the variations server URL, which can vary if a command-line flag is |
| 115 // set and/or the variations restrict pref is set in |local_prefs|. Declared | 115 // set and/or the variations restrict pref is set in |local_prefs|. Declared |
| 116 // static for test purposes. | 116 // static for test purposes. |
| 117 GURL GetVariationsServerURL(PrefService* local_prefs, | 117 GURL GetVariationsServerURL(PrefService* local_prefs, |
| 118 const std::string& restrict_mode_override); | 118 const std::string& restrict_mode_override); |
| 119 | 119 |
| 120 // Returns the permanent country code stored for this client. Country code is | 120 // Returns the permanent country code stored for this client. Country code is |
| 121 // in the format of lowercase ISO 3166-1 alpha-2. Example: us, br, in | 121 // in the format of lowercase ISO 3166-1 alpha-2. Example: us, br, in |
| 122 std::string GetStoredPermanentCountry(); | 122 std::string GetStoredPermanentCountry(); |
| 123 | 123 |
| 124 // Forces an override of kVariationsPermanentConsistencyCountry. Returns true |
| 125 // if the variable has been updated. Return false if the override country is |
| 126 // the same as the stored variable, or if the update failed for any other |
| 127 // reason. |
| 128 bool ForceSetStoredPermanentCountry(const std::string& override_country); |
| 129 |
| 124 // Exposed for testing. | 130 // Exposed for testing. |
| 125 static std::string GetDefaultVariationsServerURLForTesting(); | 131 static std::string GetDefaultVariationsServerURLForTesting(); |
| 126 | 132 |
| 127 // Register Variations related prefs in Local State. | 133 // Register Variations related prefs in Local State. |
| 128 static void RegisterPrefs(PrefRegistrySimple* registry); | 134 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 129 | 135 |
| 130 // Register Variations related prefs in the Profile prefs. | 136 // Register Variations related prefs in the Profile prefs. |
| 131 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 137 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 132 | 138 |
| 133 // Factory method for creating a VariationsService. Does not take ownership of | 139 // Factory method for creating a VariationsService. Does not take ownership of |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_EQ, | 218 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_EQ, |
| 213 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_NEQ, | 219 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_NEQ, |
| 214 LOAD_COUNTRY_MAX, | 220 LOAD_COUNTRY_MAX, |
| 215 }; | 221 }; |
| 216 | 222 |
| 217 // Loads the seed from the variations store into |seed|. If successfull, | 223 // Loads the seed from the variations store into |seed|. If successfull, |
| 218 // |seed| will contain the loaded data and true is returned. Set as virtual | 224 // |seed| will contain the loaded data and true is returned. Set as virtual |
| 219 // so that it can be overridden by tests. | 225 // so that it can be overridden by tests. |
| 220 virtual bool LoadSeed(VariationsSeed* seed); | 226 virtual bool LoadSeed(VariationsSeed* seed); |
| 221 | 227 |
| 228 // Sets the stored permanent country pref for this client. |
| 229 void SetStoredPermanentCountry(const base::Version& version, |
| 230 const std::string& country); |
| 231 |
| 222 // Checks if prerequisites for fetching the Variations seed are met, and if | 232 // Checks if prerequisites for fetching the Variations seed are met, and if |
| 223 // so, performs the actual fetch using |DoActualFetch|. | 233 // so, performs the actual fetch using |DoActualFetch|. |
| 224 void FetchVariationsSeed(); | 234 void FetchVariationsSeed(); |
| 225 | 235 |
| 226 // Notify any observers of this service based on the simulation |result|. | 236 // Notify any observers of this service based on the simulation |result|. |
| 227 void NotifyObservers( | 237 void NotifyObservers( |
| 228 const variations::VariationsSeedSimulator::Result& result); | 238 const variations::VariationsSeedSimulator::Result& result); |
| 229 | 239 |
| 230 // net::URLFetcherDelegate implementation: | 240 // net::URLFetcherDelegate implementation: |
| 231 void OnURLFetchComplete(const net::URLFetcher* source) override; | 241 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 base::ThreadChecker thread_checker_; | 323 base::ThreadChecker thread_checker_; |
| 314 | 324 |
| 315 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; | 325 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; |
| 316 | 326 |
| 317 DISALLOW_COPY_AND_ASSIGN(VariationsService); | 327 DISALLOW_COPY_AND_ASSIGN(VariationsService); |
| 318 }; | 328 }; |
| 319 | 329 |
| 320 } // namespace variations | 330 } // namespace variations |
| 321 | 331 |
| 322 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ | 332 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ |
| OLD | NEW |