Desktop User Manager: Use new Material icons for "locked" and "supervised".
[chromium-blink-merge.git] / components / variations / study_filtering.h
blobd36515c95155e825682ecca05d48f9db749679e9
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VARIATIONS_STUDY_FILTERING_H_
6 #define COMPONENTS_VARIATIONS_STUDY_FILTERING_H_
8 #include <string>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "base/time/time.h"
13 #include "base/version.h"
14 #include "components/variations/processed_study.h"
15 #include "components/variations/proto/study.pb.h"
16 #include "components/variations/proto/variations_seed.pb.h"
18 namespace variations {
20 // Internal functions exposed for testing purposes only.
21 namespace internal {
23 // Checks whether a study is applicable for the given |channel| per |filter|.
24 bool CheckStudyChannel(const Study_Filter& filter, Study_Channel channel);
26 // Checks whether a study is applicable for the given |form_factor| per
27 // |filter|.
28 bool CheckStudyFormFactor(const Study_Filter& filter,
29 Study_FormFactor form_factor);
31 // Checks whether a study is applicable for the given |hardware_class| per
32 // |filter|.
33 bool CheckStudyHardwareClass(const Study_Filter& filter,
34 const std::string& hardware_class);
36 // Checks whether a study is applicable for the given |locale| per |filter|.
37 bool CheckStudyLocale(const Study_Filter& filter, const std::string& locale);
39 // Checks whether a study is applicable for the given |platform| per |filter|.
40 bool CheckStudyPlatform(const Study_Filter& filter, Study_Platform platform);
42 // Checks whether a study is applicable for the given date/time per |filter|.
43 bool CheckStudyStartDate(const Study_Filter& filter,
44 const base::Time& date_time);
46 // Checks whether a study is applicable for the given version per |filter|.
47 bool CheckStudyVersion(const Study_Filter& filter,
48 const base::Version& version);
50 // Checks whether |study| is expired using the given date/time.
51 bool IsStudyExpired(const Study& study, const base::Time& date_time);
53 // Returns whether |study| should be disabled according to its restriction
54 // parameters.
55 bool ShouldAddStudy(const Study& study,
56 const std::string& locale,
57 const base::Time& reference_date,
58 const base::Version& version,
59 Study_Channel channel,
60 Study_FormFactor form_factor,
61 const std::string& hardware_class);
63 } // namespace internal
65 // Filters the list of studies in |seed| and validates and pre-processes them,
66 // adding any kept studies to |filtered_studies| list. Ensures that the
67 // resulting list will not have more than one study with the same name.
68 void FilterAndValidateStudies(const VariationsSeed& seed,
69 const std::string& locale,
70 const base::Time& reference_date,
71 const base::Version& version,
72 Study_Channel channel,
73 Study_FormFactor form_factor,
74 const std::string& hardware_class,
75 std::vector<ProcessedStudy>* filtered_studies);
77 } // namespace variations
79 #endif // COMPONENTS_VARIATIONS_STUDY_FILTERING_H_