Chromium Code Reviews| 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..f2b4c7e2c7e7fbadf1b5d7c65d9dcf3afc02a996 |
| --- /dev/null |
| +++ b/chrome/browser/profile_resetter/triggered_profile_resetter.h |
| @@ -0,0 +1,79 @@ |
| +// 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" |
|
grt (UTC plus 2)
2015/09/05 12:44:14
nit: i think you really want macros.h rather than
|
| +#include "base/logging.h" |
| +#include "base/memory/ref_counted.h" |
|
grt (UTC plus 2)
2015/09/05 12:44:14
unused
|
| +#include "base/memory/weak_ptr.h" |
|
grt (UTC plus 2)
2015/09/05 12:44:14
unused
|
| +#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 users' profiles |
| +// 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 localized name of the tool. |
| +// This 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: |
| + enum : int { kMaxToolNameLength = 100 }; |
| + |
| + 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(); |
|
grt (UTC plus 2)
2015/09/05 12:44:14
very optional nit: you could get rid of virtual di
|
| + |
| + // 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; |
| + |
| +#if DCHECK_IS_ON() |
| + bool activate_called_ = false; |
| +#endif |
| + |
| + base::string16 tool_name_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TriggeredProfileResetter); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_ |