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

Side by Side Diff: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config.h

Issue 2614773008: Add a config class for the settings reset prompt. (Closed)
Patch Set: Created 3 years, 11 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
(Empty)
1 // Copyright 2017 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.
4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _CONFIG_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PROMPT _CONFIG_H_
7
8 #include <cstddef>
9 #include <memory>
10 #include <string>
11 #include <unordered_map>
12 #include <vector>
13
14 #include "base/feature_list.h"
15 #include "base/macros.h"
16
17 class GURL;
18
19 namespace safe_browsing {
20
21 // Exposed for testing.
22 extern const base::Feature kSettingsResetPrompt;
23
24 // Encapsulates the state of the reset prompt experiment as well as
25 // associated data.
26 class SettingsResetPromptConfig {
27 public:
28 // Returns true if the settings reset prompt study is enabled.
29 static bool IsPromptEnabled();
30 // Factory method for creating instances of
31 // SettingsResetPromptConfig. Returns nullptr if |IsPromptEnabled()| is
32 // false or if something is wrong with the config parameters.
33 static std::unique_ptr<SettingsResetPromptConfig> Create();
34
35 ~SettingsResetPromptConfig();
36
37 // Returns a non-negative integer ID if |url| should trigger a
38 // settings reset prompt and a negative integer otherwise. The ID is
39 // useful when reporting metrics.
csharp 2017/01/09 21:54:59 Pointer to where the ID mapping for positive value
alito 2017/01/10 00:37:48 Added a bit more explanation. However, the mapping
40 int UrlToResetDomainId(const GURL& url) const;
41
42 // TODO(alito): parameterize the set of things that we want to reset
43 // for so that we can control it from the finch config. For example,
44 // with functions like HomepageResetAllowed() etc.
45 private:
46 typedef std::vector<uint8_t> SHA256Hash;
47 struct SHA256HashHasher {
48 size_t operator()(const SHA256Hash& key) const;
49 };
50 enum ConfigError : int;
51
52 SettingsResetPromptConfig();
53 bool Init();
54 ConfigError ParseDomainHashes(const std::string& domain_hashes_json);
55
56 // Map of 32 byte SHA256 hashes to integer domain IDs.
57 std::unordered_map<SHA256Hash, int, SHA256HashHasher> domain_hashes_;
58
59 DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptConfig);
60 };
61
62 } // namespace safe_browsing.
63
64 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PRO MPT_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698