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