Index: chrome/browser/profile_resetter/triggered_profile_resetter.h |
diff --git a/chrome/browser/profile_resetter/triggered_profile_resetter.h b/chrome/browser/profile_resetter/triggered_profile_resetter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1434b41219746a4d5c6eee1db9827c119819ded3 |
--- /dev/null |
+++ b/chrome/browser/profile_resetter/triggered_profile_resetter.h |
@@ -0,0 +1,75 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_ |
+#define CHROME_BROWSER_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/strings/string16.h" |
+#include "components/keyed_service/core/keyed_service.h" |
+ |
+class Profile; |
+ |
+// This service is responsible for evaluating whether a profile reset trigger |
+// has been set and not yet consumed by |profile_|. If it has, the profile is |
+// eligible for reset and a profile reset UI will be show to the user. The |
+// intended use case for this is to provide a sanctioned profile reset API for |
+// 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!
|
+// as part of their cleanup flow. |
+// |
+// To use this mechanism from a third party tool, perform the following steps: |
+// 1) Create (or open) the registry key |
+// HCKU\Software\$PRODUCT_STRING_PATH\TriggeredReset where |
+// $PRODUCT_NAME is one of the values in chrome\common\chrome_constants.h, |
+// currently either "Google\\Chrome" or "Chromium" |
+// 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.
|
+// string (truncated to kMaxToolNameLength) will be displayed in a |
+// notification UI. |
+// 3) Set a REG_QWORD value with the timestamp of the reset. This value should |
+// be obtained from a call to ::GetSystemTimeAsFileTime(). This value |
+// will be persisted in a reset profile and will be used to avoid |
+// multiple resets. |
+// |
+// Some considerations: |
+// |
+// * Chrome supports multiple profiles. When the above steps are followed, |
+// each profile will enter the reset flow as it is opened. |
+// * New profiles created while a timestamp is present will not get the reset |
+// flow. |
+class TriggeredProfileResetter : public KeyedService { |
+ public: |
+ 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!
|
+ |
+ explicit TriggeredProfileResetter(Profile* profile); |
+ ~TriggeredProfileResetter() override; |
+ |
+ // Causes the TriggeredProfileResetter to look for the presence of a trigger |
+ // and perform a reset, subsequent calls to HasResetTrigger will return |
+ // whether |profile_| is subject to a reset. |
+ virtual void Activate(); |
+ |
+ // Returns true iff the given profile should have a reset reset according to |
+ // the description in the class comment. Must call Activate() first. |
+ virtual bool HasResetTrigger(); |
+ |
+ // Returns the name of the tool that performed the reset. This string will be |
+ // truncated to a length of |kMaxToolNameLength|. |
+ virtual base::string16 GetResetToolName(); |
+ |
+ private: |
+ Profile* profile_; |
+ |
+ bool has_reset_trigger_ = false; |
+ 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.
|
+ |
+ base::string16 tool_name_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TriggeredProfileResetter); |
+}; |
+ |
+#endif // CHROME_BROWSER_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_ |