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

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: Addressed csharp's comments. 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
robertshield 2017/01/10 02:55:22 nit: wrapping looks weird here.
alito 2017/01/10 19:13:33 Done.
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 IDs
39 // identify the domains or entities that we want to prompt the user
40 // for and can be used for metrics reporting.
41 int UrlToResetDomainId(const GURL& url) const;
42
43 // TODO(alito): parameterize the set of things that we want to reset
44 // for so that we can control it from the finch config. For example,
45 // with functions like HomepageResetAllowed() etc.
46 private:
47 typedef std::vector<uint8_t> SHA256Hash;
48 struct SHA256HashHasher {
49 size_t operator()(const SHA256Hash& key) const;
50 };
51 enum ConfigError : int;
52
53 SettingsResetPromptConfig();
54 bool Init();
55 ConfigError ParseDomainHashes(const std::string& domain_hashes_json);
56
57 // Map of 32 byte SHA256 hashes to integer domain IDs.
58 std::unordered_map<SHA256Hash, int, SHA256HashHasher> domain_hashes_;
59
60 DISALLOW_COPY_AND_ASSIGN(SettingsResetPromptConfig);
61 };
62
63 } // namespace safe_browsing.
robertshield 2017/01/10 02:55:22 nit: no .
alito 2017/01/10 19:13:33 Done.
64
65 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_SETTINGS_RESET_PRO MPT_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698