Suppress tabs permission warning if there is already a browsingHistory warning.
[chromium-blink-merge.git] / components / variations / study_filtering.h
blob1c14fc960f3afddf97898129960f06b059181f11
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 chrome_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 |locale| per |filter|.
32 bool CheckStudyLocale(const Study_Filter& filter, const std::string& locale);
34 // Checks whether a study is applicable for the given |platform| per |filter|.
35 bool CheckStudyPlatform(const Study_Filter& filter, Study_Platform platform);
37 // Checks whether a study is applicable for the given date/time per |filter|.
38 bool CheckStudyStartDate(const Study_Filter& filter,
39 const base::Time& date_time);
41 // Checks whether a study is applicable for the given version per |filter|.
42 bool CheckStudyVersion(const Study_Filter& filter,
43 const base::Version& version);
45 // Checks whether |study| is expired using the given date/time.
46 bool IsStudyExpired(const Study& study, const base::Time& date_time);
48 // Returns whether |study| should be disabled according to its restriction
49 // parameters. Uses |version_info| for min / max version checks,
50 // |reference_date| for the start date check and |channel| for channel
51 // checks.
52 bool ShouldAddStudy(const Study& study,
53 const std::string& locale,
54 const base::Time& reference_date,
55 const base::Version& version,
56 Study_Channel channel,
57 Study_FormFactor form_factor);
59 } // namespace internal
61 // Filters the list of studies in |seed| and validates and pre-processes them,
62 // adding any kept studies to |filtered_studies| list. Ensures that the
63 // resulting list will not have more than one study with the same name.
64 void FilterAndValidateStudies(const VariationsSeed& seed,
65 const std::string& locale,
66 const base::Time& reference_date,
67 const base::Version& version,
68 Study_Channel channel,
69 Study_FormFactor form_factor,
70 std::vector<ProcessedStudy>* filtered_studies);
72 } // namespace chrome_variations
74 #endif // COMPONENTS_VARIATIONS_STUDY_FILTERING_H_