chromium/chrome/browser/profile_resetter/triggered_profile_resetter.h

// Copyright 2015 The Chromium Authors
// 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 <stddef.h>

#include <string>

#include "base/memory/raw_ptr.h"
#include "build/build_config.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 shown to the user. The
// intended use case for this is to provide a sanctioned profile reset API for
// third party tools (anti-virus 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
//      HKCU\Software\$PRODUCT_NAME\TriggeredReset where $PRODUCT_NAME is one
//      of the values "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. The "ToolName" should be just the name of the tool,
//      e.g. "AwesomeAV".
//   3) Set a REG_QWORD value called "Timestamp" with a timestamp for the reset
//      event. This value should be obtained from a call to
//      ::GetSystemTimeAsFileTime() at the time the reset is requested. This
//      value will be persisted in the profile when it is reset 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 any timestamp is present will not get the reset
//   flow.
class TriggeredProfileResetter : public KeyedService {};

// Exposed for testing.
extern const wchar_t kTriggeredResetRegistryPath[];
extern const wchar_t kTriggeredResetToolName[];
extern const wchar_t kTriggeredResetTimestamp[];

#endif  // CHROME_BROWSER_PROFILE_RESETTER_TRIGGERED_PROFILE_RESETTER_H_