OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Defines the Chrome Extensions Clear API functions, which entail | 5 // Defines the Chrome Extensions Clear API functions, which entail |
6 // clearing browsing data, and clearing the browser's cache (which, let's be | 6 // clearing browsing data, and clearing the browser's cache (which, let's be |
7 // honest, are the same thing), as specified in the extension API JSON. | 7 // honest, are the same thing), as specified in the extension API JSON. |
8 | 8 |
9 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ | 9 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ |
10 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ | 10 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "chrome/browser/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data_remover.h" |
16 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
17 | 17 |
18 class PluginPrefs; | 18 class PluginPrefs; |
19 | 19 |
| 20 namespace extension_clear_api_constants { |
| 21 |
| 22 // Keys. |
| 23 extern const char kAppCacheKey[]; |
| 24 extern const char kCacheKey[]; |
| 25 extern const char kCookiesKey[]; |
| 26 extern const char kDownloadsKey[]; |
| 27 extern const char kFileSystemsKey[]; |
| 28 extern const char kFormDataKey[]; |
| 29 extern const char kHistoryKey[]; |
| 30 extern const char kIndexedDBKey[]; |
| 31 extern const char kPluginDataKey[]; |
| 32 extern const char kLocalStorageKey[]; |
| 33 extern const char kPasswordsKey[]; |
| 34 extern const char kWebSQLKey[]; |
| 35 |
| 36 // Errors! |
| 37 extern const char kOneAtATimeError[]; |
| 38 |
| 39 } // namespace extension_clear_api_constants |
| 40 |
20 // This serves as a base class from which the browsing data API functions will | 41 // This serves as a base class from which the browsing data API functions will |
21 // inherit. Each needs to be an observer of BrowsingDataRemover events, and each | 42 // inherit. Each needs to be an observer of BrowsingDataRemover events, and each |
22 // will handle those events in the same way (by calling the passed-in callback | 43 // will handle those events in the same way (by calling the passed-in callback |
23 // function). | 44 // function). |
24 // | 45 // |
25 // Each child class must implement GetRemovalMask(), which returns the bitmask | 46 // Each child class must implement GetRemovalMask(), which returns the bitmask |
26 // of data types to remove. | 47 // of data types to remove. |
27 class BrowsingDataExtensionFunction : public AsyncExtensionFunction, | 48 class BrowsingDataExtensionFunction : public AsyncExtensionFunction, |
28 public BrowsingDataRemover::Observer { | 49 public BrowsingDataRemover::Observer { |
29 public: | 50 public: |
(...skipping 10 matching lines...) Expand all Loading... |
40 | 61 |
41 private: | 62 private: |
42 // Updates the removal bitmask according to whether removing plugin data is | 63 // Updates the removal bitmask according to whether removing plugin data is |
43 // supported or not. | 64 // supported or not. |
44 void CheckRemovingPluginDataSupported( | 65 void CheckRemovingPluginDataSupported( |
45 scoped_refptr<PluginPrefs> plugin_prefs); | 66 scoped_refptr<PluginPrefs> plugin_prefs); |
46 | 67 |
47 // Called when we're ready to start removing data. | 68 // Called when we're ready to start removing data. |
48 void StartRemoving(); | 69 void StartRemoving(); |
49 | 70 |
50 BrowsingDataRemover::TimePeriod period_; | 71 base::Time remove_since_; |
51 int removal_mask_; | 72 int removal_mask_; |
52 }; | 73 }; |
53 | 74 |
| 75 class ClearAppCacheFunction : public BrowsingDataExtensionFunction { |
| 76 public: |
| 77 ClearAppCacheFunction() {} |
| 78 virtual ~ClearAppCacheFunction() {} |
| 79 |
| 80 protected: |
| 81 // BrowsingDataTypeExtensionFunction interface method. |
| 82 virtual int GetRemovalMask() const OVERRIDE; |
| 83 |
| 84 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.appcache") |
| 85 }; |
| 86 |
54 class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction { | 87 class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction { |
55 public: | 88 public: |
56 ClearBrowsingDataFunction() {} | 89 ClearBrowsingDataFunction() {} |
57 virtual ~ClearBrowsingDataFunction() {} | 90 virtual ~ClearBrowsingDataFunction() {} |
58 | 91 |
59 protected: | 92 protected: |
60 // BrowsingDataExtensionFunction interface method. | 93 // BrowsingDataExtensionFunction interface method. |
61 virtual int GetRemovalMask() const OVERRIDE; | 94 virtual int GetRemovalMask() const OVERRIDE; |
62 | 95 |
63 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.browsingData") | 96 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.browsingData") |
(...skipping 28 matching lines...) Expand all Loading... |
92 ClearDownloadsFunction() {} | 125 ClearDownloadsFunction() {} |
93 virtual ~ClearDownloadsFunction() {} | 126 virtual ~ClearDownloadsFunction() {} |
94 | 127 |
95 protected: | 128 protected: |
96 // BrowsingDataTypeExtensionFunction interface method. | 129 // BrowsingDataTypeExtensionFunction interface method. |
97 virtual int GetRemovalMask() const OVERRIDE; | 130 virtual int GetRemovalMask() const OVERRIDE; |
98 | 131 |
99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads") | 132 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads") |
100 }; | 133 }; |
101 | 134 |
| 135 class ClearFileSystemsFunction : public BrowsingDataExtensionFunction { |
| 136 public: |
| 137 ClearFileSystemsFunction() {} |
| 138 virtual ~ClearFileSystemsFunction() {} |
| 139 |
| 140 protected: |
| 141 // BrowsingDataTypeExtensionFunction interface method. |
| 142 virtual int GetRemovalMask() const OVERRIDE; |
| 143 |
| 144 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.fileSystems") |
| 145 }; |
| 146 |
102 class ClearFormDataFunction : public BrowsingDataExtensionFunction { | 147 class ClearFormDataFunction : public BrowsingDataExtensionFunction { |
103 public: | 148 public: |
104 ClearFormDataFunction() {} | 149 ClearFormDataFunction() {} |
105 virtual ~ClearFormDataFunction() {} | 150 virtual ~ClearFormDataFunction() {} |
106 | 151 |
107 protected: | 152 protected: |
108 // BrowsingDataTypeExtensionFunction interface method. | 153 // BrowsingDataTypeExtensionFunction interface method. |
109 virtual int GetRemovalMask() const OVERRIDE; | 154 virtual int GetRemovalMask() const OVERRIDE; |
110 | 155 |
111 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.formData") | 156 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.formData") |
112 }; | 157 }; |
113 | 158 |
114 class ClearHistoryFunction : public BrowsingDataExtensionFunction { | 159 class ClearHistoryFunction : public BrowsingDataExtensionFunction { |
115 public: | 160 public: |
116 ClearHistoryFunction() {} | 161 ClearHistoryFunction() {} |
117 virtual ~ClearHistoryFunction() {} | 162 virtual ~ClearHistoryFunction() {} |
118 | 163 |
119 protected: | 164 protected: |
120 // BrowsingDataTypeExtensionFunction interface method. | 165 // BrowsingDataTypeExtensionFunction interface method. |
121 virtual int GetRemovalMask() const OVERRIDE; | 166 virtual int GetRemovalMask() const OVERRIDE; |
122 | 167 |
123 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history") | 168 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history") |
124 }; | 169 }; |
125 | 170 |
| 171 class ClearIndexedDBFunction : public BrowsingDataExtensionFunction { |
| 172 public: |
| 173 ClearIndexedDBFunction() {} |
| 174 virtual ~ClearIndexedDBFunction() {} |
| 175 |
| 176 protected: |
| 177 // BrowsingDataTypeExtensionFunction interface method. |
| 178 virtual int GetRemovalMask() const OVERRIDE; |
| 179 |
| 180 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.indexedDB") |
| 181 }; |
| 182 |
| 183 class ClearLocalStorageFunction : public BrowsingDataExtensionFunction { |
| 184 public: |
| 185 ClearLocalStorageFunction() {} |
| 186 virtual ~ClearLocalStorageFunction() {} |
| 187 |
| 188 protected: |
| 189 // BrowsingDataTypeExtensionFunction interface method. |
| 190 virtual int GetRemovalMask() const OVERRIDE; |
| 191 |
| 192 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.localStorage") |
| 193 }; |
| 194 |
| 195 class ClearPluginDataFunction : public BrowsingDataExtensionFunction { |
| 196 public: |
| 197 ClearPluginDataFunction() {} |
| 198 virtual ~ClearPluginDataFunction() {} |
| 199 |
| 200 protected: |
| 201 // BrowsingDataTypeExtensionFunction interface method. |
| 202 virtual int GetRemovalMask() const OVERRIDE; |
| 203 |
| 204 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.pluginData") |
| 205 }; |
| 206 |
126 class ClearPasswordsFunction : public BrowsingDataExtensionFunction { | 207 class ClearPasswordsFunction : public BrowsingDataExtensionFunction { |
127 public: | 208 public: |
128 ClearPasswordsFunction() {} | 209 ClearPasswordsFunction() {} |
129 virtual ~ClearPasswordsFunction() {} | 210 virtual ~ClearPasswordsFunction() {} |
130 | 211 |
131 protected: | 212 protected: |
132 // BrowsingDataTypeExtensionFunction interface method. | 213 // BrowsingDataTypeExtensionFunction interface method. |
133 virtual int GetRemovalMask() const OVERRIDE; | 214 virtual int GetRemovalMask() const OVERRIDE; |
134 | 215 |
135 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords") | 216 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords") |
136 }; | 217 }; |
137 | 218 |
| 219 class ClearWebSQLFunction : public BrowsingDataExtensionFunction { |
| 220 public: |
| 221 ClearWebSQLFunction() {} |
| 222 virtual ~ClearWebSQLFunction() {} |
| 223 |
| 224 protected: |
| 225 // BrowsingDataTypeExtensionFunction interface method. |
| 226 virtual int GetRemovalMask() const OVERRIDE; |
| 227 |
| 228 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.webSQL") |
| 229 }; |
138 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ | 230 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ |
OLD | NEW |