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

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

Issue 1363243004: Allow embedders to share code to override UI strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment to test and class and fix typo Created 5 years, 2 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/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "components/variations/service/ui_string_overrider.h"
18 #include "components/variations/service/variations_service_client.h" 19 #include "components/variations/service/variations_service_client.h"
19 #include "components/variations/variations_request_scheduler.h" 20 #include "components/variations/variations_request_scheduler.h"
20 #include "components/variations/variations_seed_simulator.h" 21 #include "components/variations/variations_seed_simulator.h"
21 #include "components/variations/variations_seed_store.h" 22 #include "components/variations/variations_seed_store.h"
22 #include "components/web_resource/resource_request_allowed_notifier.h" 23 #include "components/web_resource/resource_request_allowed_notifier.h"
23 #include "net/url_request/url_fetcher_delegate.h" 24 #include "net/url_request/url_fetcher_delegate.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 class PrefService; 27 class PrefService;
27 class PrefRegistrySimple; 28 class PrefRegistrySimple;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Register Variations related prefs in the Profile prefs. 122 // Register Variations related prefs in the Profile prefs.
122 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 123 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
123 124
124 // Factory method for creating a VariationsService. Does not take ownership of 125 // Factory method for creating a VariationsService. Does not take ownership of
125 // |state_manager|. Caller should ensure that |state_manager| is valid for the 126 // |state_manager|. Caller should ensure that |state_manager| is valid for the
126 // lifetime of this class. 127 // lifetime of this class.
127 static scoped_ptr<VariationsService> Create( 128 static scoped_ptr<VariationsService> Create(
128 scoped_ptr<VariationsServiceClient> client, 129 scoped_ptr<VariationsServiceClient> client,
129 PrefService* local_state, 130 PrefService* local_state,
130 metrics::MetricsStateManager* state_manager, 131 metrics::MetricsStateManager* state_manager,
131 const char* disable_network_switch); 132 const char* disable_network_switch,
133 const UIStringOverrider& ui_string_overrider);
132 134
133 // Factory method for creating a VariationsService in a testing context. 135 // Factory method for creating a VariationsService in a testing context.
134 static scoped_ptr<VariationsService> CreateForTesting( 136 static scoped_ptr<VariationsService> CreateForTesting(
135 scoped_ptr<VariationsServiceClient> client, 137 scoped_ptr<VariationsServiceClient> client,
136 PrefService* local_state); 138 PrefService* local_state);
137 139
138 // Set the PrefService responsible for getting policy-related preferences, 140 // Set the PrefService responsible for getting policy-related preferences,
139 // such as the restrict parameter. 141 // such as the restrict parameter.
140 void set_policy_pref_service(PrefService* service) { 142 void set_policy_pref_service(PrefService* service) {
141 DCHECK(service); 143 DCHECK(service);
(...skipping 19 matching lines...) Expand all
161 bool is_delta_compressed); 163 bool is_delta_compressed);
162 164
163 // Creates the VariationsService with the given |local_state| prefs service 165 // Creates the VariationsService with the given |local_state| prefs service
164 // and |state_manager|. Does not take ownership of |state_manager|. Caller 166 // and |state_manager|. Does not take ownership of |state_manager|. Caller
165 // should ensure that |state_manager| is valid for the lifetime of this class. 167 // should ensure that |state_manager| is valid for the lifetime of this class.
166 // Use the |Create| factory method to create a VariationsService. 168 // Use the |Create| factory method to create a VariationsService.
167 VariationsService( 169 VariationsService(
168 scoped_ptr<VariationsServiceClient> client, 170 scoped_ptr<VariationsServiceClient> client,
169 scoped_ptr<web_resource::ResourceRequestAllowedNotifier> notifier, 171 scoped_ptr<web_resource::ResourceRequestAllowedNotifier> notifier,
170 PrefService* local_state, 172 PrefService* local_state,
171 metrics::MetricsStateManager* state_manager); 173 metrics::MetricsStateManager* state_manager,
174 const UIStringOverrider& ui_string_overrider);
172 175
173 private: 176 private:
174 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); 177 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer);
175 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); 178 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus);
176 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); 179 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus);
177 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status); 180 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status);
178 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, 181 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest,
179 LoadPermanentConsistencyCountry); 182 LoadPermanentConsistencyCountry);
180 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CountryHeader); 183 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CountryHeader);
181 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, GetVariationsServerURL); 184 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, GetVariationsServerURL);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // Loads the country code to use for filtering permanent consistency studies, 225 // Loads the country code to use for filtering permanent consistency studies,
223 // updating the stored country code if the stored value was for a different 226 // updating the stored country code if the stored value was for a different
224 // Chrome version. The country used for permanent consistency studies is kept 227 // Chrome version. The country used for permanent consistency studies is kept
225 // consistent between Chrome upgrades in order to avoid annoying the user due 228 // consistent between Chrome upgrades in order to avoid annoying the user due
226 // to experiment churn while traveling. 229 // to experiment churn while traveling.
227 std::string LoadPermanentConsistencyCountry( 230 std::string LoadPermanentConsistencyCountry(
228 const base::Version& version, 231 const base::Version& version,
229 const std::string& latest_country); 232 const std::string& latest_country);
230 233
231 scoped_ptr<VariationsServiceClient> client_; 234 scoped_ptr<VariationsServiceClient> client_;
235 UIStringOverrider ui_string_overrider_;
232 236
233 // The pref service used to store persist the variations seed. 237 // The pref service used to store persist the variations seed.
234 PrefService* local_state_; 238 PrefService* local_state_;
235 239
236 // Used for instantiating entropy providers for variations seed simulation. 240 // Used for instantiating entropy providers for variations seed simulation.
237 // Weak pointer. 241 // Weak pointer.
238 metrics::MetricsStateManager* state_manager_; 242 metrics::MetricsStateManager* state_manager_;
239 243
240 // Used to obtain policy-related preferences. Depending on the platform, will 244 // Used to obtain policy-related preferences. Depending on the platform, will
241 // either be Local State or Profile prefs. 245 // either be Local State or Profile prefs.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 base::ThreadChecker thread_checker_; 294 base::ThreadChecker thread_checker_;
291 295
292 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; 296 base::WeakPtrFactory<VariationsService> weak_ptr_factory_;
293 297
294 DISALLOW_COPY_AND_ASSIGN(VariationsService); 298 DISALLOW_COPY_AND_ASSIGN(VariationsService);
295 }; 299 };
296 300
297 } // namespace variations 301 } // namespace variations
298 302
299 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ 303 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/variations/service/ui_string_overrider.cc ('k') | components/variations/service/variations_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698