Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(912)

Side by Side Diff: chrome/browser/profile_resetter/automatic_profile_resetter_mementos.h

Issue 24533002: Added the AutomaticProfileResetter service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
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.
14
15 #ifndef CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_MEMENTOS_H_
16 #define CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_MEMENTOS_H_
17
18 #include <string>
19
20 #include "base/basictypes.h"
21 #include "base/callback.h"
22
23 namespace base {
24 class FilePath;
25 }
26
27 class Profile;
28
29 namespace profile_resetter {
30
31 // This class is a wrapper around the user preference that gets stored when we
32 // show the one-time profile reset prompt, and which is kept as a reminder that
33 // we should not show the prompt again.
34 class PreferenceHostedPromptMemento {
35 public:
36 explicit PreferenceHostedPromptMemento(Profile* profile);
37 ~PreferenceHostedPromptMemento();
38
39 std::string ReadValue() const;
40 void StoreValue(const std::string& value);
41
42 private:
43 Profile* profile_;
44
45 DISALLOW_COPY_AND_ASSIGN(PreferenceHostedPromptMemento);
46 };
47
48 // This class is a wrapper around the Local State preference that gets stored
49 // when we show the one-time profile reset prompt, and which is kept as a
50 // reminder that we should not show the prompt again.
51 class LocalStateHostedPromptMemento {
52 public:
53 explicit LocalStateHostedPromptMemento(Profile* profile);
54 ~LocalStateHostedPromptMemento();
55
56 std::string ReadValue() const;
57 void StoreValue(const std::string& value);
58
59 private:
60 // Returns the key that shall be used in the dictionary preference in Local
61 // State to uniquely identify this profile.
62 std::string GetProfileKey() const;
63
64 Profile* profile_;
65
66 DISALLOW_COPY_AND_ASSIGN(LocalStateHostedPromptMemento);
67 };
68
69 // This class manages a marker file that gets stored when we show the one-time
70 // profile reset prompt, and which is kept as a reminder that we should not show
71 // the prompt again.
72 class FileHostedPromptMemento {
73 public:
74 typedef base::Callback<void(const std::string&)> ReadValueCallback;
75
76 explicit FileHostedPromptMemento(Profile* profile);
77 ~FileHostedPromptMemento();
78
79 // Posts to the FILE thread to read the value, then returns the value to the
80 // calling thread.
81 void ReadValue(const ReadValueCallback& callback) const;
82
83 // Asynchronously stores the value on the FILE thread.
84 void StoreValue(const std::string& value);
85
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);
91
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;
95
96 Profile* profile_;
97
98 DISALLOW_COPY_AND_ASSIGN(FileHostedPromptMemento);
99 };
100
101 } // namespace profile_resetter
102
103 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_MEMENTOS_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698