| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 BrowsingData API functions, which entail | 5 // Defines the Chrome Extensions BrowsingData 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_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 9 #ifndef CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| 10 #define CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 10 #define CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| 11 | 11 |
| 12 #include <set> |
| 12 #include <string> | 13 #include <string> |
| 13 | 14 |
| 14 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 16 #include "chrome/browser/extensions/chrome_extension_function.h" | 17 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 17 | 18 |
| 18 class PluginPrefs; | 19 class PluginPrefs; |
| 19 class PrefService; | 20 class PrefService; |
| 20 | 21 |
| 22 namespace content { |
| 23 struct BrowsingDataType; |
| 24 } |
| 25 |
| 26 using content::BrowsingDataType; |
| 27 |
| 21 namespace extension_browsing_data_api_constants { | 28 namespace extension_browsing_data_api_constants { |
| 22 | 29 |
| 23 // Parameter name keys. | 30 // Parameter name keys. |
| 24 extern const char kDataRemovalPermittedKey[]; | 31 extern const char kDataRemovalPermittedKey[]; |
| 25 extern const char kDataToRemoveKey[]; | 32 extern const char kDataToRemoveKey[]; |
| 26 extern const char kOptionsKey[]; | 33 extern const char kOptionsKey[]; |
| 27 | 34 |
| 28 // Type keys. | 35 // Type keys. |
| 29 extern const char kAppCacheKey[]; | 36 extern const char kAppCacheKey[]; |
| 30 extern const char kCacheKey[]; | 37 extern const char kCacheKey[]; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // ExtensionFunction: | 102 // ExtensionFunction: |
| 96 bool RunAsync() override; | 103 bool RunAsync() override; |
| 97 | 104 |
| 98 protected: | 105 protected: |
| 99 ~BrowsingDataRemoverFunction() override; | 106 ~BrowsingDataRemoverFunction() override; |
| 100 | 107 |
| 101 // Children should override this method to provide the proper removal mask | 108 // Children should override this method to provide the proper removal mask |
| 102 // based on the API call they represent. | 109 // based on the API call they represent. |
| 103 // Returns whether or not removal mask retrieval was successful. | 110 // Returns whether or not removal mask retrieval was successful. |
| 104 // |removal_mask| is populated with the result, if successful. | 111 // |removal_mask| is populated with the result, if successful. |
| 105 virtual bool GetRemovalMask(int* removal_mask) = 0; | 112 virtual bool GetRemovalMask( |
| 113 std::set<const BrowsingDataType*>* removal_mask) = 0; |
| 106 | 114 |
| 107 private: | 115 private: |
| 108 // Updates the removal bitmask according to whether removing plugin data is | 116 // Updates the removal bitmask according to whether removing plugin data is |
| 109 // supported or not. | 117 // supported or not. |
| 110 void CheckRemovingPluginDataSupported( | 118 void CheckRemovingPluginDataSupported( |
| 111 scoped_refptr<PluginPrefs> plugin_prefs); | 119 scoped_refptr<PluginPrefs> plugin_prefs); |
| 112 | 120 |
| 113 // Parse the developer-provided |origin_types| object into |origin_type_mask| | 121 // Parse the developer-provided |origin_types| object into |origin_type_mask| |
| 114 // that can be used with the BrowsingDataRemover. | 122 // that can be used with the BrowsingDataRemover. |
| 115 // Returns true if parsing was successful. | 123 // Returns true if parsing was successful. |
| 116 bool ParseOriginTypeMask(const base::DictionaryValue& options, | 124 bool ParseOriginTypeMask(const base::DictionaryValue& options, |
| 117 int* origin_type_mask); | 125 int* origin_type_mask); |
| 118 | 126 |
| 119 // Called when we're ready to start removing data. | 127 // Called when we're ready to start removing data. |
| 120 void StartRemoving(); | 128 void StartRemoving(); |
| 121 | 129 |
| 122 base::Time remove_since_; | 130 base::Time remove_since_; |
| 123 int removal_mask_; | 131 std::set<const BrowsingDataType*> removal_mask_; |
| 124 int origin_type_mask_; | 132 int origin_type_mask_; |
| 125 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; | 133 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; |
| 126 }; | 134 }; |
| 127 | 135 |
| 128 class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction { | 136 class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction { |
| 129 public: | 137 public: |
| 130 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", | 138 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", |
| 131 BROWSINGDATA_REMOVEAPPCACHE) | 139 BROWSINGDATA_REMOVEAPPCACHE) |
| 132 | 140 |
| 133 protected: | 141 protected: |
| 134 ~BrowsingDataRemoveAppcacheFunction() override {} | 142 ~BrowsingDataRemoveAppcacheFunction() override {} |
| 135 | 143 |
| 136 // BrowsingDataRemoverFunction: | 144 // BrowsingDataRemoverFunction: |
| 137 bool GetRemovalMask(int* removal_mask) override; | 145 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 138 }; | 146 }; |
| 139 | 147 |
| 140 class BrowsingDataRemoveFunction : public BrowsingDataRemoverFunction { | 148 class BrowsingDataRemoveFunction : public BrowsingDataRemoverFunction { |
| 141 public: | 149 public: |
| 142 DECLARE_EXTENSION_FUNCTION("browsingData.remove", BROWSINGDATA_REMOVE) | 150 DECLARE_EXTENSION_FUNCTION("browsingData.remove", BROWSINGDATA_REMOVE) |
| 143 | 151 |
| 144 protected: | 152 protected: |
| 145 ~BrowsingDataRemoveFunction() override {} | 153 ~BrowsingDataRemoveFunction() override {} |
| 146 | 154 |
| 147 // BrowsingDataRemoverFunction: | 155 // BrowsingDataRemoverFunction: |
| 148 bool GetRemovalMask(int* removal_mask) override; | 156 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 149 }; | 157 }; |
| 150 | 158 |
| 151 class BrowsingDataRemoveCacheFunction : public BrowsingDataRemoverFunction { | 159 class BrowsingDataRemoveCacheFunction : public BrowsingDataRemoverFunction { |
| 152 public: | 160 public: |
| 153 DECLARE_EXTENSION_FUNCTION("browsingData.removeCache", | 161 DECLARE_EXTENSION_FUNCTION("browsingData.removeCache", |
| 154 BROWSINGDATA_REMOVECACHE) | 162 BROWSINGDATA_REMOVECACHE) |
| 155 | 163 |
| 156 protected: | 164 protected: |
| 157 ~BrowsingDataRemoveCacheFunction() override {} | 165 ~BrowsingDataRemoveCacheFunction() override {} |
| 158 | 166 |
| 159 // BrowsingDataRemoverFunction: | 167 // BrowsingDataRemoverFunction: |
| 160 bool GetRemovalMask(int* removal_mask) override; | 168 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 161 }; | 169 }; |
| 162 | 170 |
| 163 class BrowsingDataRemoveCookiesFunction : public BrowsingDataRemoverFunction { | 171 class BrowsingDataRemoveCookiesFunction : public BrowsingDataRemoverFunction { |
| 164 public: | 172 public: |
| 165 DECLARE_EXTENSION_FUNCTION("browsingData.removeCookies", | 173 DECLARE_EXTENSION_FUNCTION("browsingData.removeCookies", |
| 166 BROWSINGDATA_REMOVECOOKIES) | 174 BROWSINGDATA_REMOVECOOKIES) |
| 167 | 175 |
| 168 protected: | 176 protected: |
| 169 ~BrowsingDataRemoveCookiesFunction() override {} | 177 ~BrowsingDataRemoveCookiesFunction() override {} |
| 170 | 178 |
| 171 // BrowsingDataRemoverFunction: | 179 // BrowsingDataRemoverFunction: |
| 172 bool GetRemovalMask(int* removal_mask) override; | 180 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 173 }; | 181 }; |
| 174 | 182 |
| 175 class BrowsingDataRemoveDownloadsFunction : public BrowsingDataRemoverFunction { | 183 class BrowsingDataRemoveDownloadsFunction : public BrowsingDataRemoverFunction { |
| 176 public: | 184 public: |
| 177 DECLARE_EXTENSION_FUNCTION("browsingData.removeDownloads", | 185 DECLARE_EXTENSION_FUNCTION("browsingData.removeDownloads", |
| 178 BROWSINGDATA_REMOVEDOWNLOADS) | 186 BROWSINGDATA_REMOVEDOWNLOADS) |
| 179 | 187 |
| 180 protected: | 188 protected: |
| 181 ~BrowsingDataRemoveDownloadsFunction() override {} | 189 ~BrowsingDataRemoveDownloadsFunction() override {} |
| 182 | 190 |
| 183 // BrowsingDataRemoverFunction: | 191 // BrowsingDataRemoverFunction: |
| 184 bool GetRemovalMask(int* removal_mask) override; | 192 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 185 }; | 193 }; |
| 186 | 194 |
| 187 class BrowsingDataRemoveFileSystemsFunction | 195 class BrowsingDataRemoveFileSystemsFunction |
| 188 : public BrowsingDataRemoverFunction { | 196 : public BrowsingDataRemoverFunction { |
| 189 public: | 197 public: |
| 190 DECLARE_EXTENSION_FUNCTION("browsingData.removeFileSystems", | 198 DECLARE_EXTENSION_FUNCTION("browsingData.removeFileSystems", |
| 191 BROWSINGDATA_REMOVEFILESYSTEMS) | 199 BROWSINGDATA_REMOVEFILESYSTEMS) |
| 192 | 200 |
| 193 protected: | 201 protected: |
| 194 ~BrowsingDataRemoveFileSystemsFunction() override {} | 202 ~BrowsingDataRemoveFileSystemsFunction() override {} |
| 195 | 203 |
| 196 // BrowsingDataRemoverFunction: | 204 // BrowsingDataRemoverFunction: |
| 197 bool GetRemovalMask(int* removal_mask) override; | 205 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 198 }; | 206 }; |
| 199 | 207 |
| 200 class BrowsingDataRemoveFormDataFunction : public BrowsingDataRemoverFunction { | 208 class BrowsingDataRemoveFormDataFunction : public BrowsingDataRemoverFunction { |
| 201 public: | 209 public: |
| 202 DECLARE_EXTENSION_FUNCTION("browsingData.removeFormData", | 210 DECLARE_EXTENSION_FUNCTION("browsingData.removeFormData", |
| 203 BROWSINGDATA_REMOVEFORMDATA) | 211 BROWSINGDATA_REMOVEFORMDATA) |
| 204 | 212 |
| 205 protected: | 213 protected: |
| 206 ~BrowsingDataRemoveFormDataFunction() override {} | 214 ~BrowsingDataRemoveFormDataFunction() override {} |
| 207 | 215 |
| 208 // BrowsingDataRemoverFunction: | 216 // BrowsingDataRemoverFunction: |
| 209 bool GetRemovalMask(int* removal_mask) override; | 217 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 210 }; | 218 }; |
| 211 | 219 |
| 212 class BrowsingDataRemoveHistoryFunction : public BrowsingDataRemoverFunction { | 220 class BrowsingDataRemoveHistoryFunction : public BrowsingDataRemoverFunction { |
| 213 public: | 221 public: |
| 214 DECLARE_EXTENSION_FUNCTION("browsingData.removeHistory", | 222 DECLARE_EXTENSION_FUNCTION("browsingData.removeHistory", |
| 215 BROWSINGDATA_REMOVEHISTORY) | 223 BROWSINGDATA_REMOVEHISTORY) |
| 216 | 224 |
| 217 protected: | 225 protected: |
| 218 ~BrowsingDataRemoveHistoryFunction() override {} | 226 ~BrowsingDataRemoveHistoryFunction() override {} |
| 219 | 227 |
| 220 // BrowsingDataRemoverFunction: | 228 // BrowsingDataRemoverFunction: |
| 221 bool GetRemovalMask(int* removal_mask) override; | 229 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 222 }; | 230 }; |
| 223 | 231 |
| 224 class BrowsingDataRemoveIndexedDBFunction : public BrowsingDataRemoverFunction { | 232 class BrowsingDataRemoveIndexedDBFunction : public BrowsingDataRemoverFunction { |
| 225 public: | 233 public: |
| 226 DECLARE_EXTENSION_FUNCTION("browsingData.removeIndexedDB", | 234 DECLARE_EXTENSION_FUNCTION("browsingData.removeIndexedDB", |
| 227 BROWSINGDATA_REMOVEINDEXEDDB) | 235 BROWSINGDATA_REMOVEINDEXEDDB) |
| 228 | 236 |
| 229 protected: | 237 protected: |
| 230 ~BrowsingDataRemoveIndexedDBFunction() override {} | 238 ~BrowsingDataRemoveIndexedDBFunction() override {} |
| 231 | 239 |
| 232 // BrowsingDataRemoverFunction: | 240 // BrowsingDataRemoverFunction: |
| 233 bool GetRemovalMask(int* removal_mask) override; | 241 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 234 }; | 242 }; |
| 235 | 243 |
| 236 class BrowsingDataRemoveLocalStorageFunction | 244 class BrowsingDataRemoveLocalStorageFunction |
| 237 : public BrowsingDataRemoverFunction { | 245 : public BrowsingDataRemoverFunction { |
| 238 public: | 246 public: |
| 239 DECLARE_EXTENSION_FUNCTION("browsingData.removeLocalStorage", | 247 DECLARE_EXTENSION_FUNCTION("browsingData.removeLocalStorage", |
| 240 BROWSINGDATA_REMOVELOCALSTORAGE) | 248 BROWSINGDATA_REMOVELOCALSTORAGE) |
| 241 | 249 |
| 242 protected: | 250 protected: |
| 243 ~BrowsingDataRemoveLocalStorageFunction() override {} | 251 ~BrowsingDataRemoveLocalStorageFunction() override {} |
| 244 | 252 |
| 245 // BrowsingDataRemoverFunction: | 253 // BrowsingDataRemoverFunction: |
| 246 bool GetRemovalMask(int* removal_mask) override; | 254 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 247 }; | 255 }; |
| 248 | 256 |
| 249 class BrowsingDataRemovePluginDataFunction | 257 class BrowsingDataRemovePluginDataFunction |
| 250 : public BrowsingDataRemoverFunction { | 258 : public BrowsingDataRemoverFunction { |
| 251 public: | 259 public: |
| 252 DECLARE_EXTENSION_FUNCTION("browsingData.removePluginData", | 260 DECLARE_EXTENSION_FUNCTION("browsingData.removePluginData", |
| 253 BROWSINGDATA_REMOVEPLUGINDATA) | 261 BROWSINGDATA_REMOVEPLUGINDATA) |
| 254 | 262 |
| 255 protected: | 263 protected: |
| 256 ~BrowsingDataRemovePluginDataFunction() override {} | 264 ~BrowsingDataRemovePluginDataFunction() override {} |
| 257 | 265 |
| 258 // BrowsingDataRemoverFunction: | 266 // BrowsingDataRemoverFunction: |
| 259 bool GetRemovalMask(int* removal_mask) override; | 267 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 260 }; | 268 }; |
| 261 | 269 |
| 262 class BrowsingDataRemovePasswordsFunction : public BrowsingDataRemoverFunction { | 270 class BrowsingDataRemovePasswordsFunction : public BrowsingDataRemoverFunction { |
| 263 public: | 271 public: |
| 264 DECLARE_EXTENSION_FUNCTION("browsingData.removePasswords", | 272 DECLARE_EXTENSION_FUNCTION("browsingData.removePasswords", |
| 265 BROWSINGDATA_REMOVEPASSWORDS) | 273 BROWSINGDATA_REMOVEPASSWORDS) |
| 266 | 274 |
| 267 protected: | 275 protected: |
| 268 ~BrowsingDataRemovePasswordsFunction() override {} | 276 ~BrowsingDataRemovePasswordsFunction() override {} |
| 269 | 277 |
| 270 // BrowsingDataRemoverFunction: | 278 // BrowsingDataRemoverFunction: |
| 271 bool GetRemovalMask(int* removal_mask) override; | 279 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 272 }; | 280 }; |
| 273 | 281 |
| 274 class BrowsingDataRemoveServiceWorkersFunction | 282 class BrowsingDataRemoveServiceWorkersFunction |
| 275 : public BrowsingDataRemoverFunction { | 283 : public BrowsingDataRemoverFunction { |
| 276 public: | 284 public: |
| 277 DECLARE_EXTENSION_FUNCTION("browsingData.removeServiceWorkers", | 285 DECLARE_EXTENSION_FUNCTION("browsingData.removeServiceWorkers", |
| 278 BROWSINGDATA_REMOVESERVICEWORKERS) | 286 BROWSINGDATA_REMOVESERVICEWORKERS) |
| 279 | 287 |
| 280 protected: | 288 protected: |
| 281 ~BrowsingDataRemoveServiceWorkersFunction() override {} | 289 ~BrowsingDataRemoveServiceWorkersFunction() override {} |
| 282 | 290 |
| 283 // BrowsingDataRemoverFunction: | 291 // BrowsingDataRemoverFunction: |
| 284 bool GetRemovalMask(int* removal_mask) override; | 292 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 285 }; | 293 }; |
| 286 | 294 |
| 287 class BrowsingDataRemoveCacheStorageFunction | 295 class BrowsingDataRemoveCacheStorageFunction |
| 288 : public BrowsingDataRemoverFunction { | 296 : public BrowsingDataRemoverFunction { |
| 289 public: | 297 public: |
| 290 DECLARE_EXTENSION_FUNCTION("browsingData.removeCacheStorage", | 298 DECLARE_EXTENSION_FUNCTION("browsingData.removeCacheStorage", |
| 291 BROWSINGDATA_REMOVECACHESTORAGE) | 299 BROWSINGDATA_REMOVECACHESTORAGE) |
| 292 | 300 |
| 293 protected: | 301 protected: |
| 294 ~BrowsingDataRemoveCacheStorageFunction() override {} | 302 ~BrowsingDataRemoveCacheStorageFunction() override {} |
| 295 | 303 |
| 296 // BrowsingDataRemoverFunction: | 304 // BrowsingDataRemoverFunction: |
| 297 bool GetRemovalMask(int* removal_mask) override; | 305 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 298 }; | 306 }; |
| 299 | 307 |
| 300 class BrowsingDataRemoveWebSQLFunction : public BrowsingDataRemoverFunction { | 308 class BrowsingDataRemoveWebSQLFunction : public BrowsingDataRemoverFunction { |
| 301 public: | 309 public: |
| 302 DECLARE_EXTENSION_FUNCTION("browsingData.removeWebSQL", | 310 DECLARE_EXTENSION_FUNCTION("browsingData.removeWebSQL", |
| 303 BROWSINGDATA_REMOVEWEBSQL) | 311 BROWSINGDATA_REMOVEWEBSQL) |
| 304 | 312 |
| 305 protected: | 313 protected: |
| 306 ~BrowsingDataRemoveWebSQLFunction() override {} | 314 ~BrowsingDataRemoveWebSQLFunction() override {} |
| 307 | 315 |
| 308 // BrowsingDataRemoverFunction: | 316 // BrowsingDataRemoverFunction: |
| 309 bool GetRemovalMask(int* removal_mask) override; | 317 bool GetRemovalMask(std::set<const BrowsingDataType*>* removal_mask) override; |
| 310 }; | 318 }; |
| 311 | 319 |
| 312 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 320 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| OLD | NEW |