OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_ | |
6 #define CHROME_BROWSER_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
grt (UTC plus 2)
2015/09/05 12:44:14
nit: i think you really want macros.h rather than
| |
11 #include "base/logging.h" | |
12 #include "base/memory/ref_counted.h" | |
grt (UTC plus 2)
2015/09/05 12:44:14
unused
| |
13 #include "base/memory/weak_ptr.h" | |
grt (UTC plus 2)
2015/09/05 12:44:14
unused
| |
14 #include "base/strings/string16.h" | |
15 #include "components/keyed_service/core/keyed_service.h" | |
16 | |
17 class Profile; | |
18 | |
19 // This service is responsible for evaluating whether a profile reset trigger | |
20 // has been set and not yet consumed by |profile_|. If it has, the profile is | |
21 // eligible for reset and a profile reset UI will be show to the user. The | |
22 // intended use case for this is to provide a sanctioned profile reset API for | |
23 // third party tools (AVs or cleaner tools) that wish to reset users' profiles | |
24 // as part of their cleanup flow. | |
25 // | |
26 // To use this mechanism from a third party tool, perform the following steps: | |
27 // 1) Create (or open) the registry key | |
28 // HCKU\Software\$PRODUCT_STRING_PATH\TriggeredReset where | |
29 // $PRODUCT_NAME is one of the values in chrome\common\chrome_constants.h, | |
30 // currently either "Google\\Chrome" or "Chromium" | |
31 // 2) Set a REG_SZ value called "ToolName" to the localized name of the tool. | |
32 // This string (truncated to kMaxToolNameLength) will be displayed in a | |
33 // notification UI. | |
34 // 3) Set a REG_QWORD value with the timestamp of the reset. This value should | |
35 // be obtained from a call to ::GetSystemTimeAsFileTime(). This value | |
36 // will be persisted in a reset profile and will be used to avoid | |
37 // multiple resets. | |
38 // | |
39 // Some considerations: | |
40 // | |
41 // * Chrome supports multiple profiles. When the above steps are followed, | |
42 // each profile will enter the reset flow as it is opened. | |
43 // * New profiles created while a timestamp is present will not get the reset | |
44 // flow. | |
45 class TriggeredProfileResetter : public KeyedService { | |
46 public: | |
47 enum : int { kMaxToolNameLength = 100 }; | |
48 | |
49 explicit TriggeredProfileResetter(Profile* profile); | |
50 ~TriggeredProfileResetter() override; | |
51 | |
52 // Causes the TriggeredProfileResetter to look for the presence of a trigger | |
53 // and perform a reset, subsequent calls to HasResetTrigger will return | |
54 // whether |profile_| is subject to a reset. | |
55 virtual void Activate(); | |
56 | |
57 // Returns true iff the given profile should have a reset reset according to | |
58 // the description in the class comment. Must call Activate() first. | |
59 virtual bool HasResetTrigger(); | |
grt (UTC plus 2)
2015/09/05 12:44:14
very optional nit: you could get rid of virtual di
| |
60 | |
61 // Returns the name of the tool that performed the reset. This string will be | |
62 // truncated to a length of |kMaxToolNameLength|. | |
63 virtual base::string16 GetResetToolName(); | |
64 | |
65 private: | |
66 Profile* profile_; | |
67 | |
68 bool has_reset_trigger_ = false; | |
69 | |
70 #if DCHECK_IS_ON() | |
71 bool activate_called_ = false; | |
72 #endif | |
73 | |
74 base::string16 tool_name_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(TriggeredProfileResetter); | |
77 }; | |
78 | |
79 #endif // CHROME_BROWSER_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_ | |
OLD | NEW |