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

Side by Side Diff: chrome/browser/extensions/extension_clear_api.h

Issue 7551008: Strawman proposal for chrome.experimental.clear.* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing ExtensionPermissionSetTest Created 9 years, 4 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 (c) 2011 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 // Defines the Chrome Extensions Clear API functions, which entail
6 // clearing browsing data, and clearing the browser's cache (which, let's be
7 // honest, are the same thing), as specified in
8 // chrome/common/extensions/api/extension_api.json.
9
10 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_
11 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_
12 #pragma once
13
14 #include <string>
15
16 #include "chrome/browser/browsing_data_remover.h"
17 #include "chrome/browser/extensions/extension_function.h"
18
19 namespace base {
20 class DictionaryValue;
21 }
22
23 // This serves as a base class from which the browsing data API functions will
24 // inherit. Each needs to be an observer of BrowsingDataRemover events, and each
25 // will handle those events in the same way (by calling the passed-in callback
26 // function).
27 //
28 // Each child class must implement GetRemovalMask(), which returns the bitmask
29 // of data types to remove.
30 class BrowsingDataExtensionFunction : public AsyncExtensionFunction,
31 public BrowsingDataRemover::Observer {
32 public:
33 // BrowsingDataRemover::Observer interface method.
34 virtual void OnBrowsingDataRemoverDone() OVERRIDE;
35
36 // AsyncExtensionFunction interface method.
37 virtual bool RunImpl() OVERRIDE;
38
39 protected:
40 // Children should override this method to provide the proper removal mask
41 // based on the API call they represent.
42 virtual int GetRemovalMask() const = 0;
43
44 private:
45 // Converts the JavaScript API's string input ("last_week") into the
46 // appropriate BrowsingDataRemover::TimePeriod (in this case,
47 // BrowsingDataRemover::LAST_WEEK).
48 virtual bool ParseTimePeriod(const std::string& parse,
49 BrowsingDataRemover::TimePeriod* period) const;
50 };
51
52 class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction {
53 public:
54 ClearBrowsingDataFunction() {}
55 virtual ~ClearBrowsingDataFunction() {}
56
57 protected:
58 // BrowsingDataExtensionFunction interface method.
59 virtual int GetRemovalMask() const OVERRIDE;
60
61 private:
62 // Convert the JavaScript API's object input ({ cookies: true }) into the
63 // appropriate removal mask for the BrowsingDataRemover object.
64 virtual int ParseRemovalMask(base::DictionaryValue* value) const;
65
66 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.browsingData")
67 };
68
69 class ClearCacheFunction : public BrowsingDataExtensionFunction {
70 public:
71 ClearCacheFunction() {}
72 virtual ~ClearCacheFunction() {}
73
74 protected:
75 // BrowsingDataTypeExtensionFunction interface method.
76 virtual int GetRemovalMask() const OVERRIDE;
77
78 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.cache")
79 };
80
81 class ClearCookiesFunction : public BrowsingDataExtensionFunction {
82 public:
83 ClearCookiesFunction() {}
84 virtual ~ClearCookiesFunction() {}
85
86 protected:
87 // BrowsingDataTypeExtensionFunction interface method.
88 virtual int GetRemovalMask() const OVERRIDE;
89
90 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.cookies")
91 };
92
93 class ClearDownloadsFunction : public BrowsingDataExtensionFunction {
94 public:
95 ClearDownloadsFunction() {}
96 virtual ~ClearDownloadsFunction() {}
97
98 protected:
99 // BrowsingDataTypeExtensionFunction interface method.
100 virtual int GetRemovalMask() const OVERRIDE;
101
102 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads")
103 };
104
105 class ClearFormDataFunction : public BrowsingDataExtensionFunction {
106 public:
107 ClearFormDataFunction() {}
108 virtual ~ClearFormDataFunction() {}
109
110 protected:
111 // BrowsingDataTypeExtensionFunction interface method.
112 virtual int GetRemovalMask() const OVERRIDE;
113
114 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.formData")
115 };
116
117 class ClearHistoryFunction : public BrowsingDataExtensionFunction {
118 public:
119 ClearHistoryFunction() {}
120 virtual ~ClearHistoryFunction() {}
121
122 protected:
123 // BrowsingDataTypeExtensionFunction interface method.
124 virtual int GetRemovalMask() const OVERRIDE;
125
126 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history")
127 };
128
129 class ClearPasswordsFunction : public BrowsingDataExtensionFunction {
130 public:
131 ClearPasswordsFunction() {}
132 virtual ~ClearPasswordsFunction() {}
133
134 protected:
135 // BrowsingDataTypeExtensionFunction interface method.
136 virtual int GetRemovalMask() const OVERRIDE;
137
138 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords")
139 };
140
141 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698