Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / profile_resetter / automatic_profile_resetter_mementos.h
blob025ffb224501b86101d7e1d94410ba1793c0855f
1 // Copyright 2013 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.
5 // The classes in this file are alternative implementations of the concept of a
6 // "prompt memento", a token of some kind that gets stored when we show the
7 // one-time profile reset prompt, and which then serves as a reminder that we
8 // should not show the prompt again.
9 //
10 // In an ideal world, a single implementation would suffice, however, we expect
11 // that third party software might accidentally interfere with some of these
12 // methods. We need this redundancy because we want to make absolutely sure that
13 // we do not annoy the user with the prompt multiple times.
15 #ifndef CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_MEMENTOS_H_
16 #define CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_MEMENTOS_H_
18 #include <string>
20 #include "base/basictypes.h"
21 #include "base/callback.h"
23 namespace base {
24 class FilePath;
27 class Profile;
29 // This class is a wrapper around the user preference that gets stored when we
30 // show the one-time profile reset prompt, and which is kept as a reminder that
31 // we should not show the prompt again.
32 class PreferenceHostedPromptMemento {
33 public:
34 explicit PreferenceHostedPromptMemento(Profile* profile);
35 ~PreferenceHostedPromptMemento();
37 std::string ReadValue() const;
38 void StoreValue(const std::string& value);
40 private:
41 Profile* profile_;
43 DISALLOW_COPY_AND_ASSIGN(PreferenceHostedPromptMemento);
46 // This class is a wrapper around the Local State preference that gets stored
47 // when we show the one-time profile reset prompt, and which is kept as a
48 // reminder that we should not show the prompt again.
49 class LocalStateHostedPromptMemento {
50 public:
51 explicit LocalStateHostedPromptMemento(Profile* profile);
52 ~LocalStateHostedPromptMemento();
54 std::string ReadValue() const;
55 void StoreValue(const std::string& value);
57 private:
58 // Returns the key that shall be used in the dictionary preference in Local
59 // State to uniquely identify this profile.
60 std::string GetProfileKey() const;
62 Profile* profile_;
64 DISALLOW_COPY_AND_ASSIGN(LocalStateHostedPromptMemento);
67 // This class manages a marker file that gets stored when we show the one-time
68 // profile reset prompt, and which is kept as a reminder that we should not show
69 // the prompt again.
70 class FileHostedPromptMemento {
71 public:
72 typedef base::Callback<void(const std::string&)> ReadValueCallback;
74 explicit FileHostedPromptMemento(Profile* profile);
75 ~FileHostedPromptMemento();
77 // Posts to the FILE thread to read the value, then returns the value to the
78 // calling thread. It is safe to destroy this object as soon as this method
79 // (synchronously) returns.
80 void ReadValue(const ReadValueCallback& callback) const;
82 // Asynchronously stores the value on the FILE thread. However, it is safe to
83 // destroy this object as soon as this method (synchronously) returns.
84 void StoreValue(const std::string& value);
86 private:
87 static std::string ReadValueOnFileThread(
88 const base::FilePath& memento_file_path);
89 static void StoreValueOnFileThread(const base::FilePath& memento_file_path,
90 const std::string& value);
92 // Returns the path to the file that shall be used to store this kind of
93 // memento for this profile.
94 base::FilePath GetMementoFilePath() const;
96 Profile* profile_;
98 DISALLOW_COPY_AND_ASSIGN(FileHostedPromptMemento);
101 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_MEMENTOS_H_