| 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 | |
| 41 // This serves as a base class from which the browsing data API functions will | 20 // This serves as a base class from which the browsing data API functions will |
| 42 // inherit. Each needs to be an observer of BrowsingDataRemover events, and each | 21 // inherit. Each needs to be an observer of BrowsingDataRemover events, and each |
| 43 // will handle those events in the same way (by calling the passed-in callback | 22 // will handle those events in the same way (by calling the passed-in callback |
| 44 // function). | 23 // function). |
| 45 // | 24 // |
| 46 // Each child class must implement GetRemovalMask(), which returns the bitmask | 25 // Each child class must implement GetRemovalMask(), which returns the bitmask |
| 47 // of data types to remove. | 26 // of data types to remove. |
| 48 class BrowsingDataExtensionFunction : public AsyncExtensionFunction, | 27 class BrowsingDataExtensionFunction : public AsyncExtensionFunction, |
| 49 public BrowsingDataRemover::Observer { | 28 public BrowsingDataRemover::Observer { |
| 50 public: | 29 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 61 | 40 |
| 62 private: | 41 private: |
| 63 // Updates the removal bitmask according to whether removing plugin data is | 42 // Updates the removal bitmask according to whether removing plugin data is |
| 64 // supported or not. | 43 // supported or not. |
| 65 void CheckRemovingPluginDataSupported( | 44 void CheckRemovingPluginDataSupported( |
| 66 scoped_refptr<PluginPrefs> plugin_prefs); | 45 scoped_refptr<PluginPrefs> plugin_prefs); |
| 67 | 46 |
| 68 // Called when we're ready to start removing data. | 47 // Called when we're ready to start removing data. |
| 69 void StartRemoving(); | 48 void StartRemoving(); |
| 70 | 49 |
| 71 base::Time remove_since_; | 50 BrowsingDataRemover::TimePeriod period_; |
| 72 int removal_mask_; | 51 int removal_mask_; |
| 73 }; | 52 }; |
| 74 | 53 |
| 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 | |
| 87 class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction { | 54 class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction { |
| 88 public: | 55 public: |
| 89 ClearBrowsingDataFunction() {} | 56 ClearBrowsingDataFunction() {} |
| 90 virtual ~ClearBrowsingDataFunction() {} | 57 virtual ~ClearBrowsingDataFunction() {} |
| 91 | 58 |
| 92 protected: | 59 protected: |
| 93 // BrowsingDataExtensionFunction interface method. | 60 // BrowsingDataExtensionFunction interface method. |
| 94 virtual int GetRemovalMask() const OVERRIDE; | 61 virtual int GetRemovalMask() const OVERRIDE; |
| 95 | 62 |
| 96 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.browsingData") | 63 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.browsingData") |
| (...skipping 28 matching lines...) Expand all Loading... |
| 125 ClearDownloadsFunction() {} | 92 ClearDownloadsFunction() {} |
| 126 virtual ~ClearDownloadsFunction() {} | 93 virtual ~ClearDownloadsFunction() {} |
| 127 | 94 |
| 128 protected: | 95 protected: |
| 129 // BrowsingDataTypeExtensionFunction interface method. | 96 // BrowsingDataTypeExtensionFunction interface method. |
| 130 virtual int GetRemovalMask() const OVERRIDE; | 97 virtual int GetRemovalMask() const OVERRIDE; |
| 131 | 98 |
| 132 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads") | 99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads") |
| 133 }; | 100 }; |
| 134 | 101 |
| 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 | |
| 147 class ClearFormDataFunction : public BrowsingDataExtensionFunction { | 102 class ClearFormDataFunction : public BrowsingDataExtensionFunction { |
| 148 public: | 103 public: |
| 149 ClearFormDataFunction() {} | 104 ClearFormDataFunction() {} |
| 150 virtual ~ClearFormDataFunction() {} | 105 virtual ~ClearFormDataFunction() {} |
| 151 | 106 |
| 152 protected: | 107 protected: |
| 153 // BrowsingDataTypeExtensionFunction interface method. | 108 // BrowsingDataTypeExtensionFunction interface method. |
| 154 virtual int GetRemovalMask() const OVERRIDE; | 109 virtual int GetRemovalMask() const OVERRIDE; |
| 155 | 110 |
| 156 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.formData") | 111 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.formData") |
| 157 }; | 112 }; |
| 158 | 113 |
| 159 class ClearHistoryFunction : public BrowsingDataExtensionFunction { | 114 class ClearHistoryFunction : public BrowsingDataExtensionFunction { |
| 160 public: | 115 public: |
| 161 ClearHistoryFunction() {} | 116 ClearHistoryFunction() {} |
| 162 virtual ~ClearHistoryFunction() {} | 117 virtual ~ClearHistoryFunction() {} |
| 163 | 118 |
| 164 protected: | 119 protected: |
| 165 // BrowsingDataTypeExtensionFunction interface method. | 120 // BrowsingDataTypeExtensionFunction interface method. |
| 166 virtual int GetRemovalMask() const OVERRIDE; | 121 virtual int GetRemovalMask() const OVERRIDE; |
| 167 | 122 |
| 168 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history") | 123 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history") |
| 169 }; | 124 }; |
| 170 | 125 |
| 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 | |
| 207 class ClearPasswordsFunction : public BrowsingDataExtensionFunction { | 126 class ClearPasswordsFunction : public BrowsingDataExtensionFunction { |
| 208 public: | 127 public: |
| 209 ClearPasswordsFunction() {} | 128 ClearPasswordsFunction() {} |
| 210 virtual ~ClearPasswordsFunction() {} | 129 virtual ~ClearPasswordsFunction() {} |
| 211 | 130 |
| 212 protected: | 131 protected: |
| 213 // BrowsingDataTypeExtensionFunction interface method. | 132 // BrowsingDataTypeExtensionFunction interface method. |
| 214 virtual int GetRemovalMask() const OVERRIDE; | 133 virtual int GetRemovalMask() const OVERRIDE; |
| 215 | 134 |
| 216 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords") | 135 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords") |
| 217 }; | 136 }; |
| 218 | 137 |
| 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 }; | |
| 230 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ | 138 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ |
| OLD | NEW |