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

Side by Side Diff: components/variations/variations_seed_processor.h

Issue 370463003: Add support for variations controlled overriding UI strings to the variations service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_VARIATIONS_SEED_PROCESSOR_H_ 5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_ 6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
13 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/strings/string16.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "base/version.h" 17 #include "base/version.h"
16 #include "components/variations/proto/study.pb.h" 18 #include "components/variations/proto/study.pb.h"
17 #include "components/variations/proto/variations_seed.pb.h" 19 #include "components/variations/proto/variations_seed.pb.h"
18 20
19 namespace chrome_variations { 21 namespace chrome_variations {
20 22
21 class ProcessedStudy; 23 class ProcessedStudy;
22 24
23 // Helper class to instantiate field trials from a variations seed. 25 // Helper class to instantiate field trials from a variations seed.
24 class VariationsSeedProcessor { 26 class VariationsSeedProcessor {
25 public: 27 public:
28 typedef base::Callback<void(uint32_t, const base::string16&)>
29 UIStringOverrideCallback;
30
26 VariationsSeedProcessor(); 31 VariationsSeedProcessor();
27 virtual ~VariationsSeedProcessor(); 32 virtual ~VariationsSeedProcessor();
28 33
29 // Creates field trials from the specified variations |seed|, based on the 34 // Creates field trials from the specified variations |seed|, based on the
30 // specified configuration (locale, current date, version, channel, form 35 // specified configuration (locale, current date, version, channel, form
31 // factor and hardware_class). 36 // factor and hardware_class).
32 void CreateTrialsFromSeed(const VariationsSeed& seed, 37 void CreateTrialsFromSeed(const VariationsSeed& seed,
33 const std::string& locale, 38 const std::string& locale,
34 const base::Time& reference_date, 39 const base::Time& reference_date,
35 const base::Version& version, 40 const base::Version& version,
36 Study_Channel channel, 41 Study_Channel channel,
37 Study_FormFactor form_factor, 42 Study_FormFactor form_factor,
38 const std::string& hardware_class); 43 const std::string& hardware_class,
44 const UIStringOverrideCallback& override_callback);
39 45
40 private: 46 private:
41 friend class VariationsSeedProcessorTest; 47 friend class VariationsSeedProcessorTest;
42 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 48 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
43 AllowForceGroupAndVariationId); 49 AllowForceGroupAndVariationId);
44 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 50 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
45 AllowVariationIdWithForcingFlag); 51 AllowVariationIdWithForcingFlag);
46 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 52 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
47 ForbidForceGroupWithVariationId); 53 ForbidForceGroupWithVariationId);
48 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1); 54 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1);
49 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2); 55 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2);
50 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 56 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
51 ForceGroup_ChooseFirstGroupWithFlag); 57 ForceGroup_ChooseFirstGroupWithFlag);
52 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 58 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
53 ForceGroup_DontChooseGroupWithFlag); 59 ForceGroup_DontChooseGroupWithFlag);
54 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired); 60 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired);
55 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams); 61 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams);
56 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 62 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
57 VariationParamsWithForcingFlag); 63 VariationParamsWithForcingFlag);
58 64
59 // Check if the |study| is only associated with platform Android/iOS and 65 // Check if the |study| is only associated with platform Android/iOS and
60 // channel dev/canary. If so, forcing flag and variation id can both be set. 66 // channel dev/canary. If so, forcing flag and variation id can both be set.
61 // (Otherwise, forcing_flag and variation_id are mutually exclusive.) 67 // (Otherwise, forcing_flag and variation_id are mutually exclusive.)
62 bool AllowVariationIdWithForcingFlag(const Study& study); 68 bool AllowVariationIdWithForcingFlag(const Study& study);
63 69
64 // Creates and registers a field trial from the |processed_study| data. 70 // Creates and registers a field trial from the |processed_study| data.
65 // Disables the trial if |processed_study.is_expired| is true. 71 // Disables the trial if |processed_study.is_expired| is true.
66 void CreateTrialFromStudy(const ProcessedStudy& processed_study); 72 void CreateTrialFromStudy(const ProcessedStudy& processed_study,
73 const UIStringOverrideCallback& override_callback);
67 74
68 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor); 75 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor);
69 }; 76 };
70 77
71 } // namespace chrome_variations 78 } // namespace chrome_variations
72 79
73 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_ 80 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
OLDNEW
« no previous file with comments | « components/variations/proto/study.proto ('k') | components/variations/variations_seed_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698