Chromium Code Reviews| 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_ |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 void OnBrowsingDataRemoverDone() override; | 93 void OnBrowsingDataRemoverDone() override; |
| 94 | 94 |
| 95 // ExtensionFunction: | 95 // ExtensionFunction: |
| 96 bool RunAsync() override; | 96 bool RunAsync() override; |
| 97 | 97 |
| 98 protected: | 98 protected: |
| 99 ~BrowsingDataRemoverFunction() override; | 99 ~BrowsingDataRemoverFunction() override; |
| 100 | 100 |
| 101 // Children should override this method to provide the proper removal mask | 101 // Children should override this method to provide the proper removal mask |
| 102 // based on the API call they represent. | 102 // based on the API call they represent. |
| 103 virtual int GetRemovalMask() = 0; | 103 // Returns whether or not removal mask retrieval was successful. The mask |
| 104 // should be returned in |removal_mask|. | |
|
Devlin
2017/01/25 20:21:26
nitty nit: second sentence should be something lik
lazyboy
2017/01/25 21:09:30
Done.
| |
| 105 virtual bool GetRemovalMask(int* removal_mask) = 0; | |
| 104 | 106 |
| 105 private: | 107 private: |
| 106 // Updates the removal bitmask according to whether removing plugin data is | 108 // Updates the removal bitmask according to whether removing plugin data is |
| 107 // supported or not. | 109 // supported or not. |
| 108 void CheckRemovingPluginDataSupported( | 110 void CheckRemovingPluginDataSupported( |
| 109 scoped_refptr<PluginPrefs> plugin_prefs); | 111 scoped_refptr<PluginPrefs> plugin_prefs); |
| 110 | 112 |
| 111 // Parse the developer-provided |origin_types| object into an origin_type_mask | 113 // Parse the developer-provided |origin_types| object into an origin_type_mask |
| 112 // that can be used with the BrowsingDataRemover. | 114 // that can be used with the BrowsingDataRemover. |
| 113 int ParseOriginTypeMask(const base::DictionaryValue& options); | 115 int ParseOriginTypeMask(const base::DictionaryValue& options); |
| 114 | 116 |
| 115 // Called when we're ready to start removing data. | 117 // Called when we're ready to start removing data. |
| 116 void StartRemoving(); | 118 void StartRemoving(); |
| 117 | 119 |
| 118 base::Time remove_since_; | 120 base::Time remove_since_; |
| 119 int removal_mask_; | 121 int removal_mask_; |
| 120 int origin_type_mask_; | 122 int origin_type_mask_; |
| 121 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; | 123 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; |
| 122 }; | 124 }; |
| 123 | 125 |
| 124 class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction { | 126 class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction { |
| 125 public: | 127 public: |
| 126 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", | 128 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", |
| 127 BROWSINGDATA_REMOVEAPPCACHE) | 129 BROWSINGDATA_REMOVEAPPCACHE) |
| 128 | 130 |
| 129 protected: | 131 protected: |
| 130 ~BrowsingDataRemoveAppcacheFunction() override {} | 132 ~BrowsingDataRemoveAppcacheFunction() override {} |
| 131 | 133 |
| 132 // BrowsingDataRemoverFunction: | 134 // BrowsingDataRemoverFunction: |
| 133 int GetRemovalMask() override; | 135 bool GetRemovalMask(int* removal_mask) override; |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 class BrowsingDataRemoveFunction : public BrowsingDataRemoverFunction { | 138 class BrowsingDataRemoveFunction : public BrowsingDataRemoverFunction { |
| 137 public: | 139 public: |
| 138 DECLARE_EXTENSION_FUNCTION("browsingData.remove", BROWSINGDATA_REMOVE) | 140 DECLARE_EXTENSION_FUNCTION("browsingData.remove", BROWSINGDATA_REMOVE) |
| 139 | 141 |
| 140 protected: | 142 protected: |
| 141 ~BrowsingDataRemoveFunction() override {} | 143 ~BrowsingDataRemoveFunction() override {} |
| 142 | 144 |
| 143 // BrowsingDataRemoverFunction: | 145 // BrowsingDataRemoverFunction: |
| 144 int GetRemovalMask() override; | 146 bool GetRemovalMask(int* removal_mask) override; |
| 145 }; | 147 }; |
| 146 | 148 |
| 147 class BrowsingDataRemoveCacheFunction : public BrowsingDataRemoverFunction { | 149 class BrowsingDataRemoveCacheFunction : public BrowsingDataRemoverFunction { |
| 148 public: | 150 public: |
| 149 DECLARE_EXTENSION_FUNCTION("browsingData.removeCache", | 151 DECLARE_EXTENSION_FUNCTION("browsingData.removeCache", |
| 150 BROWSINGDATA_REMOVECACHE) | 152 BROWSINGDATA_REMOVECACHE) |
| 151 | 153 |
| 152 protected: | 154 protected: |
| 153 ~BrowsingDataRemoveCacheFunction() override {} | 155 ~BrowsingDataRemoveCacheFunction() override {} |
| 154 | 156 |
| 155 // BrowsingDataRemoverFunction: | 157 // BrowsingDataRemoverFunction: |
| 156 int GetRemovalMask() override; | 158 bool GetRemovalMask(int* removal_mask) override; |
| 157 }; | 159 }; |
| 158 | 160 |
| 159 class BrowsingDataRemoveCookiesFunction : public BrowsingDataRemoverFunction { | 161 class BrowsingDataRemoveCookiesFunction : public BrowsingDataRemoverFunction { |
| 160 public: | 162 public: |
| 161 DECLARE_EXTENSION_FUNCTION("browsingData.removeCookies", | 163 DECLARE_EXTENSION_FUNCTION("browsingData.removeCookies", |
| 162 BROWSINGDATA_REMOVECOOKIES) | 164 BROWSINGDATA_REMOVECOOKIES) |
| 163 | 165 |
| 164 protected: | 166 protected: |
| 165 ~BrowsingDataRemoveCookiesFunction() override {} | 167 ~BrowsingDataRemoveCookiesFunction() override {} |
| 166 | 168 |
| 167 // BrowsingDataRemoverFunction: | 169 // BrowsingDataRemoverFunction: |
| 168 int GetRemovalMask() override; | 170 bool GetRemovalMask(int* removal_mask) override; |
| 169 }; | 171 }; |
| 170 | 172 |
| 171 class BrowsingDataRemoveDownloadsFunction : public BrowsingDataRemoverFunction { | 173 class BrowsingDataRemoveDownloadsFunction : public BrowsingDataRemoverFunction { |
| 172 public: | 174 public: |
| 173 DECLARE_EXTENSION_FUNCTION("browsingData.removeDownloads", | 175 DECLARE_EXTENSION_FUNCTION("browsingData.removeDownloads", |
| 174 BROWSINGDATA_REMOVEDOWNLOADS) | 176 BROWSINGDATA_REMOVEDOWNLOADS) |
| 175 | 177 |
| 176 protected: | 178 protected: |
| 177 ~BrowsingDataRemoveDownloadsFunction() override {} | 179 ~BrowsingDataRemoveDownloadsFunction() override {} |
| 178 | 180 |
| 179 // BrowsingDataRemoverFunction: | 181 // BrowsingDataRemoverFunction: |
| 180 int GetRemovalMask() override; | 182 bool GetRemovalMask(int* removal_mask) override; |
| 181 }; | 183 }; |
| 182 | 184 |
| 183 class BrowsingDataRemoveFileSystemsFunction | 185 class BrowsingDataRemoveFileSystemsFunction |
| 184 : public BrowsingDataRemoverFunction { | 186 : public BrowsingDataRemoverFunction { |
| 185 public: | 187 public: |
| 186 DECLARE_EXTENSION_FUNCTION("browsingData.removeFileSystems", | 188 DECLARE_EXTENSION_FUNCTION("browsingData.removeFileSystems", |
| 187 BROWSINGDATA_REMOVEFILESYSTEMS) | 189 BROWSINGDATA_REMOVEFILESYSTEMS) |
| 188 | 190 |
| 189 protected: | 191 protected: |
| 190 ~BrowsingDataRemoveFileSystemsFunction() override {} | 192 ~BrowsingDataRemoveFileSystemsFunction() override {} |
| 191 | 193 |
| 192 // BrowsingDataRemoverFunction: | 194 // BrowsingDataRemoverFunction: |
| 193 int GetRemovalMask() override; | 195 bool GetRemovalMask(int* removal_mask) override; |
| 194 }; | 196 }; |
| 195 | 197 |
| 196 class BrowsingDataRemoveFormDataFunction : public BrowsingDataRemoverFunction { | 198 class BrowsingDataRemoveFormDataFunction : public BrowsingDataRemoverFunction { |
| 197 public: | 199 public: |
| 198 DECLARE_EXTENSION_FUNCTION("browsingData.removeFormData", | 200 DECLARE_EXTENSION_FUNCTION("browsingData.removeFormData", |
| 199 BROWSINGDATA_REMOVEFORMDATA) | 201 BROWSINGDATA_REMOVEFORMDATA) |
| 200 | 202 |
| 201 protected: | 203 protected: |
| 202 ~BrowsingDataRemoveFormDataFunction() override {} | 204 ~BrowsingDataRemoveFormDataFunction() override {} |
| 203 | 205 |
| 204 // BrowsingDataRemoverFunction: | 206 // BrowsingDataRemoverFunction: |
| 205 int GetRemovalMask() override; | 207 bool GetRemovalMask(int* removal_mask) override; |
| 206 }; | 208 }; |
| 207 | 209 |
| 208 class BrowsingDataRemoveHistoryFunction : public BrowsingDataRemoverFunction { | 210 class BrowsingDataRemoveHistoryFunction : public BrowsingDataRemoverFunction { |
| 209 public: | 211 public: |
| 210 DECLARE_EXTENSION_FUNCTION("browsingData.removeHistory", | 212 DECLARE_EXTENSION_FUNCTION("browsingData.removeHistory", |
| 211 BROWSINGDATA_REMOVEHISTORY) | 213 BROWSINGDATA_REMOVEHISTORY) |
| 212 | 214 |
| 213 protected: | 215 protected: |
| 214 ~BrowsingDataRemoveHistoryFunction() override {} | 216 ~BrowsingDataRemoveHistoryFunction() override {} |
| 215 | 217 |
| 216 // BrowsingDataRemoverFunction: | 218 // BrowsingDataRemoverFunction: |
| 217 int GetRemovalMask() override; | 219 bool GetRemovalMask(int* removal_mask) override; |
| 218 }; | 220 }; |
| 219 | 221 |
| 220 class BrowsingDataRemoveIndexedDBFunction : public BrowsingDataRemoverFunction { | 222 class BrowsingDataRemoveIndexedDBFunction : public BrowsingDataRemoverFunction { |
| 221 public: | 223 public: |
| 222 DECLARE_EXTENSION_FUNCTION("browsingData.removeIndexedDB", | 224 DECLARE_EXTENSION_FUNCTION("browsingData.removeIndexedDB", |
| 223 BROWSINGDATA_REMOVEINDEXEDDB) | 225 BROWSINGDATA_REMOVEINDEXEDDB) |
| 224 | 226 |
| 225 protected: | 227 protected: |
| 226 ~BrowsingDataRemoveIndexedDBFunction() override {} | 228 ~BrowsingDataRemoveIndexedDBFunction() override {} |
| 227 | 229 |
| 228 // BrowsingDataRemoverFunction: | 230 // BrowsingDataRemoverFunction: |
| 229 int GetRemovalMask() override; | 231 bool GetRemovalMask(int* removal_mask) override; |
| 230 }; | 232 }; |
| 231 | 233 |
| 232 class BrowsingDataRemoveLocalStorageFunction | 234 class BrowsingDataRemoveLocalStorageFunction |
| 233 : public BrowsingDataRemoverFunction { | 235 : public BrowsingDataRemoverFunction { |
| 234 public: | 236 public: |
| 235 DECLARE_EXTENSION_FUNCTION("browsingData.removeLocalStorage", | 237 DECLARE_EXTENSION_FUNCTION("browsingData.removeLocalStorage", |
| 236 BROWSINGDATA_REMOVELOCALSTORAGE) | 238 BROWSINGDATA_REMOVELOCALSTORAGE) |
| 237 | 239 |
| 238 protected: | 240 protected: |
| 239 ~BrowsingDataRemoveLocalStorageFunction() override {} | 241 ~BrowsingDataRemoveLocalStorageFunction() override {} |
| 240 | 242 |
| 241 // BrowsingDataRemoverFunction: | 243 // BrowsingDataRemoverFunction: |
| 242 int GetRemovalMask() override; | 244 bool GetRemovalMask(int* removal_mask) override; |
| 243 }; | 245 }; |
| 244 | 246 |
| 245 class BrowsingDataRemovePluginDataFunction | 247 class BrowsingDataRemovePluginDataFunction |
| 246 : public BrowsingDataRemoverFunction { | 248 : public BrowsingDataRemoverFunction { |
| 247 public: | 249 public: |
| 248 DECLARE_EXTENSION_FUNCTION("browsingData.removePluginData", | 250 DECLARE_EXTENSION_FUNCTION("browsingData.removePluginData", |
| 249 BROWSINGDATA_REMOVEPLUGINDATA) | 251 BROWSINGDATA_REMOVEPLUGINDATA) |
| 250 | 252 |
| 251 protected: | 253 protected: |
| 252 ~BrowsingDataRemovePluginDataFunction() override {} | 254 ~BrowsingDataRemovePluginDataFunction() override {} |
| 253 | 255 |
| 254 // BrowsingDataRemoverFunction: | 256 // BrowsingDataRemoverFunction: |
| 255 int GetRemovalMask() override; | 257 bool GetRemovalMask(int* removal_mask) override; |
| 256 }; | 258 }; |
| 257 | 259 |
| 258 class BrowsingDataRemovePasswordsFunction : public BrowsingDataRemoverFunction { | 260 class BrowsingDataRemovePasswordsFunction : public BrowsingDataRemoverFunction { |
| 259 public: | 261 public: |
| 260 DECLARE_EXTENSION_FUNCTION("browsingData.removePasswords", | 262 DECLARE_EXTENSION_FUNCTION("browsingData.removePasswords", |
| 261 BROWSINGDATA_REMOVEPASSWORDS) | 263 BROWSINGDATA_REMOVEPASSWORDS) |
| 262 | 264 |
| 263 protected: | 265 protected: |
| 264 ~BrowsingDataRemovePasswordsFunction() override {} | 266 ~BrowsingDataRemovePasswordsFunction() override {} |
| 265 | 267 |
| 266 // BrowsingDataRemoverFunction: | 268 // BrowsingDataRemoverFunction: |
| 267 int GetRemovalMask() override; | 269 bool GetRemovalMask(int* removal_mask) override; |
| 268 }; | 270 }; |
| 269 | 271 |
| 270 class BrowsingDataRemoveServiceWorkersFunction | 272 class BrowsingDataRemoveServiceWorkersFunction |
| 271 : public BrowsingDataRemoverFunction { | 273 : public BrowsingDataRemoverFunction { |
| 272 public: | 274 public: |
| 273 DECLARE_EXTENSION_FUNCTION("browsingData.removeServiceWorkers", | 275 DECLARE_EXTENSION_FUNCTION("browsingData.removeServiceWorkers", |
| 274 BROWSINGDATA_REMOVESERVICEWORKERS) | 276 BROWSINGDATA_REMOVESERVICEWORKERS) |
| 275 | 277 |
| 276 protected: | 278 protected: |
| 277 ~BrowsingDataRemoveServiceWorkersFunction() override {} | 279 ~BrowsingDataRemoveServiceWorkersFunction() override {} |
| 278 | 280 |
| 279 // BrowsingDataRemoverFunction: | 281 // BrowsingDataRemoverFunction: |
| 280 int GetRemovalMask() override; | 282 bool GetRemovalMask(int* removal_mask) override; |
| 281 }; | 283 }; |
| 282 | 284 |
| 283 class BrowsingDataRemoveCacheStorageFunction | 285 class BrowsingDataRemoveCacheStorageFunction |
| 284 : public BrowsingDataRemoverFunction { | 286 : public BrowsingDataRemoverFunction { |
| 285 public: | 287 public: |
| 286 DECLARE_EXTENSION_FUNCTION("browsingData.removeCacheStorage", | 288 DECLARE_EXTENSION_FUNCTION("browsingData.removeCacheStorage", |
| 287 BROWSINGDATA_REMOVECACHESTORAGE) | 289 BROWSINGDATA_REMOVECACHESTORAGE) |
| 288 | 290 |
| 289 protected: | 291 protected: |
| 290 ~BrowsingDataRemoveCacheStorageFunction() override {} | 292 ~BrowsingDataRemoveCacheStorageFunction() override {} |
| 291 | 293 |
| 292 // BrowsingDataRemoverFunction: | 294 // BrowsingDataRemoverFunction: |
| 293 int GetRemovalMask() override; | 295 bool GetRemovalMask(int* removal_mask) override; |
| 294 }; | 296 }; |
| 295 | 297 |
| 296 class BrowsingDataRemoveWebSQLFunction : public BrowsingDataRemoverFunction { | 298 class BrowsingDataRemoveWebSQLFunction : public BrowsingDataRemoverFunction { |
| 297 public: | 299 public: |
| 298 DECLARE_EXTENSION_FUNCTION("browsingData.removeWebSQL", | 300 DECLARE_EXTENSION_FUNCTION("browsingData.removeWebSQL", |
| 299 BROWSINGDATA_REMOVEWEBSQL) | 301 BROWSINGDATA_REMOVEWEBSQL) |
| 300 | 302 |
| 301 protected: | 303 protected: |
| 302 ~BrowsingDataRemoveWebSQLFunction() override {} | 304 ~BrowsingDataRemoveWebSQLFunction() override {} |
| 303 | 305 |
| 304 // BrowsingDataRemoverFunction: | 306 // BrowsingDataRemoverFunction: |
| 305 int GetRemovalMask() override; | 307 bool GetRemovalMask(int* removal_mask) override; |
| 306 }; | 308 }; |
| 307 | 309 |
| 308 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 310 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| OLD | NEW |