Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: components/variations/service/variations_service.h

Issue 1903593002: Allows to manually change the stored permanent country in Variations from the translate-internals d… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "components/variations/service/ui_string_overrider.h" 19 #include "components/variations/service/ui_string_overrider.h"
20 #include "components/variations/service/variations_service_client.h" 20 #include "components/variations/service/variations_service_client.h"
21 #include "components/variations/variations_request_scheduler.h" 21 #include "components/variations/variations_request_scheduler.h"
22 #include "components/variations/variations_seed_simulator.h" 22 #include "components/variations/variations_seed_simulator.h"
23 #include "components/variations/variations_seed_store.h" 23 #include "components/variations/variations_seed_store.h"
24 #include "components/version_info/version_info.h"
24 #include "components/web_resource/resource_request_allowed_notifier.h" 25 #include "components/web_resource/resource_request_allowed_notifier.h"
25 #include "net/url_request/url_fetcher_delegate.h" 26 #include "net/url_request/url_fetcher_delegate.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 class PrefService; 29 class PrefService;
29 class PrefRegistrySimple; 30 class PrefRegistrySimple;
30 31
31 namespace base { 32 namespace base {
32 class FeatureList; 33 class FeatureList;
33 class Version; 34 class Version;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // Returns the variations server URL, which can vary if a command-line flag is 115 // 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 116 // set and/or the variations restrict pref is set in |local_prefs|. Declared
116 // static for test purposes. 117 // static for test purposes.
117 GURL GetVariationsServerURL(PrefService* local_prefs, 118 GURL GetVariationsServerURL(PrefService* local_prefs,
118 const std::string& restrict_mode_override); 119 const std::string& restrict_mode_override);
119 120
120 // Returns the permanent country code stored for this client. Country code is 121 // 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 122 // in the format of lowercase ISO 3166-1 alpha-2. Example: us, br, in
122 std::string GetStoredPermanentCountry(); 123 std::string GetStoredPermanentCountry();
123 124
125 // Forces an override of kVariationsPermanentConsistencyCountry. Returns true
hajimehoshi 2016/04/22 07:22:57 nit: Remove a space char after 'of'
hamelphi 2016/04/22 17:20:05 Done.
126 // if the variable has been updated. Return false if the override country is
127 // the same as the stored variable, or if the update failed for any other
128 // reason.
129 bool OverrideStoredPermanentCountry(const std::string& override_country);
130
124 // Exposed for testing. 131 // Exposed for testing.
125 static std::string GetDefaultVariationsServerURLForTesting(); 132 static std::string GetDefaultVariationsServerURLForTesting();
126 133
127 // Register Variations related prefs in Local State. 134 // Register Variations related prefs in Local State.
128 static void RegisterPrefs(PrefRegistrySimple* registry); 135 static void RegisterPrefs(PrefRegistrySimple* registry);
129 136
130 // Register Variations related prefs in the Profile prefs. 137 // Register Variations related prefs in the Profile prefs.
131 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 138 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
132 139
133 // Factory method for creating a VariationsService. Does not take ownership of 140 // Factory method for creating a VariationsService. Does not take ownership of
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_EQ, 219 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_EQ,
213 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_NEQ, 220 LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_NEQ,
214 LOAD_COUNTRY_MAX, 221 LOAD_COUNTRY_MAX,
215 }; 222 };
216 223
217 // Loads the seed from the variations store into |seed|. If successfull, 224 // 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 225 // |seed| will contain the loaded data and true is returned. Set as virtual
219 // so that it can be overridden by tests. 226 // so that it can be overridden by tests.
220 virtual bool LoadSeed(VariationsSeed* seed); 227 virtual bool LoadSeed(VariationsSeed* seed);
221 228
229 // Sets the stored permanent country pref for this client.
230 void StorePermanentCountry(const base::Version& version,
231 const std::string& country);
232
222 // Checks if prerequisites for fetching the Variations seed are met, and if 233 // Checks if prerequisites for fetching the Variations seed are met, and if
223 // so, performs the actual fetch using |DoActualFetch|. 234 // so, performs the actual fetch using |DoActualFetch|.
224 void FetchVariationsSeed(); 235 void FetchVariationsSeed();
225 236
226 // Notify any observers of this service based on the simulation |result|. 237 // Notify any observers of this service based on the simulation |result|.
227 void NotifyObservers( 238 void NotifyObservers(
228 const variations::VariationsSeedSimulator::Result& result); 239 const variations::VariationsSeedSimulator::Result& result);
229 240
230 // net::URLFetcherDelegate implementation: 241 // net::URLFetcherDelegate implementation:
231 void OnURLFetchComplete(const net::URLFetcher* source) override; 242 void OnURLFetchComplete(const net::URLFetcher* source) override;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 base::ThreadChecker thread_checker_; 324 base::ThreadChecker thread_checker_;
314 325
315 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; 326 base::WeakPtrFactory<VariationsService> weak_ptr_factory_;
316 327
317 DISALLOW_COPY_AND_ASSIGN(VariationsService); 328 DISALLOW_COPY_AND_ASSIGN(VariationsService);
318 }; 329 };
319 330
320 } // namespace variations 331 } // namespace variations
321 332
322 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ 333 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698