| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool is_selected); | 73 bool is_selected); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // This serves as a base class from which the browsing data API removal | 76 // This serves as a base class from which the browsing data API removal |
| 77 // functions will inherit. Each needs to be an observer of BrowsingDataRemover | 77 // functions will inherit. Each needs to be an observer of BrowsingDataRemover |
| 78 // events, and each will handle those events in the same way (by calling the | 78 // events, and each will handle those events in the same way (by calling the |
| 79 // passed-in callback function). | 79 // passed-in callback function). |
| 80 // | 80 // |
| 81 // Each child class must implement GetRemovalMask(), which returns the bitmask | 81 // Each child class must implement GetRemovalMask(), which returns the bitmask |
| 82 // of data types to remove. | 82 // of data types to remove. |
| 83 class BrowsingDataRemoveFunction : public AsyncExtensionFunction, | 83 class BrowsingDataRemoverFunction : public AsyncExtensionFunction, |
| 84 public BrowsingDataRemover::Observer { | 84 public BrowsingDataRemover::Observer { |
| 85 public: | 85 public: |
| 86 // BrowsingDataRemover::Observer interface method. | 86 // BrowsingDataRemover::Observer interface method. |
| 87 virtual void OnBrowsingDataRemoverDone() OVERRIDE; | 87 virtual void OnBrowsingDataRemoverDone() OVERRIDE; |
| 88 | 88 |
| 89 // ExtensionFunction: | 89 // ExtensionFunction: |
| 90 virtual bool RunImpl() OVERRIDE; | 90 virtual bool RunImpl() OVERRIDE; |
| 91 | 91 |
| 92 protected: | 92 protected: |
| 93 virtual ~BrowsingDataRemoveFunction() {} | 93 virtual ~BrowsingDataRemoverFunction() {} |
| 94 | 94 |
| 95 // Children should override this method to provide the proper removal mask | 95 // Children should override this method to provide the proper removal mask |
| 96 // based on the API call they represent. | 96 // based on the API call they represent. |
| 97 virtual int GetRemovalMask() = 0; | 97 virtual int GetRemovalMask() = 0; |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 // Updates the removal bitmask according to whether removing plugin data is | 100 // Updates the removal bitmask according to whether removing plugin data is |
| 101 // supported or not. | 101 // supported or not. |
| 102 void CheckRemovingPluginDataSupported( | 102 void CheckRemovingPluginDataSupported( |
| 103 scoped_refptr<PluginPrefs> plugin_prefs); | 103 scoped_refptr<PluginPrefs> plugin_prefs); |
| 104 | 104 |
| 105 // Parse the developer-provided |origin_types| object into an origin_set_mask | 105 // Parse the developer-provided |origin_types| object into an origin_set_mask |
| 106 // that can be used with the BrowsingDataRemover. | 106 // that can be used with the BrowsingDataRemover. |
| 107 int ParseOriginSetMask(const base::DictionaryValue& options); | 107 int ParseOriginSetMask(const base::DictionaryValue& options); |
| 108 | 108 |
| 109 // Called when we're ready to start removing data. | 109 // Called when we're ready to start removing data. |
| 110 void StartRemoving(); | 110 void StartRemoving(); |
| 111 | 111 |
| 112 base::Time remove_since_; | 112 base::Time remove_since_; |
| 113 int removal_mask_; | 113 int removal_mask_; |
| 114 int origin_set_mask_; | 114 int origin_set_mask_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 class RemoveAppCacheFunction : public BrowsingDataRemoveFunction { | 117 class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction { |
| 118 public: | 118 public: |
| 119 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", | 119 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", |
| 120 BROWSINGDATA_REMOVEAPPCACHE) | 120 BROWSINGDATA_REMOVEAPPCACHE) |
| 121 | 121 |
| 122 protected: | 122 protected: |
| 123 virtual ~RemoveAppCacheFunction() {} | 123 virtual ~BrowsingDataRemoveAppcacheFunction() {} |
| 124 | 124 |
| 125 // BrowsingDataTypeExtensionFunction: | 125 // BrowsingDataRemoverFunction: |
| 126 virtual int GetRemovalMask() OVERRIDE; | 126 virtual int GetRemovalMask() OVERRIDE; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 class RemoveBrowsingDataFunction : public BrowsingDataRemoveFunction { | 129 class BrowsingDataRemoveFunction : public BrowsingDataRemoverFunction { |
| 130 public: | 130 public: |
| 131 DECLARE_EXTENSION_FUNCTION("browsingData.remove", BROWSINGDATA_REMOVE) | 131 DECLARE_EXTENSION_FUNCTION("browsingData.remove", BROWSINGDATA_REMOVE) |
| 132 | 132 |
| 133 protected: | 133 protected: |
| 134 virtual ~RemoveBrowsingDataFunction() {} | 134 virtual ~BrowsingDataRemoveFunction() {} |
| 135 | 135 |
| 136 // BrowsingDataRemoveFunction: | 136 // BrowsingDataRemoverFunction: |
| 137 virtual int GetRemovalMask() OVERRIDE; | 137 virtual int GetRemovalMask() OVERRIDE; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 class RemoveCacheFunction : public BrowsingDataRemoveFunction { | 140 class BrowsingDataRemoveCacheFunction : public BrowsingDataRemoverFunction { |
| 141 public: | 141 public: |
| 142 DECLARE_EXTENSION_FUNCTION("browsingData.removeCache", | 142 DECLARE_EXTENSION_FUNCTION("browsingData.removeCache", |
| 143 BROWSINGDATA_REMOVECACHE) | 143 BROWSINGDATA_REMOVECACHE) |
| 144 | 144 |
| 145 protected: | 145 protected: |
| 146 virtual ~RemoveCacheFunction() {} | 146 virtual ~BrowsingDataRemoveCacheFunction() {} |
| 147 | 147 |
| 148 // BrowsingDataRemoveFunction: | 148 // BrowsingDataRemoverFunction: |
| 149 virtual int GetRemovalMask() OVERRIDE; | 149 virtual int GetRemovalMask() OVERRIDE; |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 class RemoveCookiesFunction : public BrowsingDataRemoveFunction { | 152 class BrowsingDataRemoveCookiesFunction : public BrowsingDataRemoverFunction { |
| 153 public: | 153 public: |
| 154 DECLARE_EXTENSION_FUNCTION("browsingData.removeCookies", | 154 DECLARE_EXTENSION_FUNCTION("browsingData.removeCookies", |
| 155 BROWSINGDATA_REMOVECOOKIES) | 155 BROWSINGDATA_REMOVECOOKIES) |
| 156 | 156 |
| 157 protected: | 157 protected: |
| 158 virtual ~RemoveCookiesFunction() {} | 158 virtual ~BrowsingDataRemoveCookiesFunction() {} |
| 159 | 159 |
| 160 // BrowsingDataRemoveFunction: | 160 // BrowsingDataRemoverFunction: |
| 161 virtual int GetRemovalMask() OVERRIDE; | 161 virtual int GetRemovalMask() OVERRIDE; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 class RemoveDownloadsFunction : public BrowsingDataRemoveFunction { | 164 class BrowsingDataRemoveDownloadsFunction : public BrowsingDataRemoverFunction { |
| 165 public: | 165 public: |
| 166 DECLARE_EXTENSION_FUNCTION("browsingData.removeDownloads", | 166 DECLARE_EXTENSION_FUNCTION("browsingData.removeDownloads", |
| 167 BROWSINGDATA_REMOVEDOWNLOADS) | 167 BROWSINGDATA_REMOVEDOWNLOADS) |
| 168 | 168 |
| 169 protected: | 169 protected: |
| 170 virtual ~RemoveDownloadsFunction() {} | 170 virtual ~BrowsingDataRemoveDownloadsFunction() {} |
| 171 | 171 |
| 172 // BrowsingDataRemoveFunction: | 172 // BrowsingDataRemoverFunction: |
| 173 virtual int GetRemovalMask() OVERRIDE; | 173 virtual int GetRemovalMask() OVERRIDE; |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 class RemoveFileSystemsFunction : public BrowsingDataRemoveFunction { | 176 class BrowsingDataRemoveFileSystemsFunction |
| 177 : public BrowsingDataRemoverFunction { |
| 177 public: | 178 public: |
| 178 DECLARE_EXTENSION_FUNCTION("browsingData.removeFileSystems", | 179 DECLARE_EXTENSION_FUNCTION("browsingData.removeFileSystems", |
| 179 BROWSINGDATA_REMOVEFILESYSTEMS) | 180 BROWSINGDATA_REMOVEFILESYSTEMS) |
| 180 | 181 |
| 181 protected: | 182 protected: |
| 182 virtual ~RemoveFileSystemsFunction() {} | 183 virtual ~BrowsingDataRemoveFileSystemsFunction() {} |
| 183 | 184 |
| 184 // BrowsingDataRemoveFunction: | 185 // BrowsingDataRemoverFunction: |
| 185 virtual int GetRemovalMask() OVERRIDE; | 186 virtual int GetRemovalMask() OVERRIDE; |
| 186 }; | 187 }; |
| 187 | 188 |
| 188 class RemoveFormDataFunction : public BrowsingDataRemoveFunction { | 189 class BrowsingDataRemoveFormDataFunction : public BrowsingDataRemoverFunction { |
| 189 public: | 190 public: |
| 190 DECLARE_EXTENSION_FUNCTION("browsingData.removeFormData", | 191 DECLARE_EXTENSION_FUNCTION("browsingData.removeFormData", |
| 191 BROWSINGDATA_REMOVEFORMDATA) | 192 BROWSINGDATA_REMOVEFORMDATA) |
| 192 | 193 |
| 193 protected: | 194 protected: |
| 194 virtual ~RemoveFormDataFunction() {} | 195 virtual ~BrowsingDataRemoveFormDataFunction() {} |
| 195 | 196 |
| 196 // BrowsingDataRemoveFunction: | 197 // BrowsingDataRemoverFunction: |
| 197 virtual int GetRemovalMask() OVERRIDE; | 198 virtual int GetRemovalMask() OVERRIDE; |
| 198 }; | 199 }; |
| 199 | 200 |
| 200 class RemoveHistoryFunction : public BrowsingDataRemoveFunction { | 201 class BrowsingDataRemoveHistoryFunction : public BrowsingDataRemoverFunction { |
| 201 public: | 202 public: |
| 202 DECLARE_EXTENSION_FUNCTION("browsingData.removeHistory", | 203 DECLARE_EXTENSION_FUNCTION("browsingData.removeHistory", |
| 203 BROWSINGDATA_REMOVEHISTORY) | 204 BROWSINGDATA_REMOVEHISTORY) |
| 204 | 205 |
| 205 protected: | 206 protected: |
| 206 virtual ~RemoveHistoryFunction() {} | 207 virtual ~BrowsingDataRemoveHistoryFunction() {} |
| 207 | 208 |
| 208 // BrowsingDataRemoveFunction: | 209 // BrowsingDataRemoverFunction: |
| 209 virtual int GetRemovalMask() OVERRIDE; | 210 virtual int GetRemovalMask() OVERRIDE; |
| 210 }; | 211 }; |
| 211 | 212 |
| 212 class RemoveIndexedDBFunction : public BrowsingDataRemoveFunction { | 213 class BrowsingDataRemoveIndexedDBFunction : public BrowsingDataRemoverFunction { |
| 213 public: | 214 public: |
| 214 DECLARE_EXTENSION_FUNCTION("browsingData.removeIndexedDB", | 215 DECLARE_EXTENSION_FUNCTION("browsingData.removeIndexedDB", |
| 215 BROWSINGDATA_REMOVEINDEXEDDB) | 216 BROWSINGDATA_REMOVEINDEXEDDB) |
| 216 | 217 |
| 217 protected: | 218 protected: |
| 218 virtual ~RemoveIndexedDBFunction() {} | 219 virtual ~BrowsingDataRemoveIndexedDBFunction() {} |
| 219 | 220 |
| 220 // BrowsingDataRemoveFunction: | 221 // BrowsingDataRemoverFunction: |
| 221 virtual int GetRemovalMask() OVERRIDE; | 222 virtual int GetRemovalMask() OVERRIDE; |
| 222 }; | 223 }; |
| 223 | 224 |
| 224 class RemoveLocalStorageFunction : public BrowsingDataRemoveFunction { | 225 class BrowsingDataRemoveLocalStorageFunction |
| 226 : public BrowsingDataRemoverFunction { |
| 225 public: | 227 public: |
| 226 DECLARE_EXTENSION_FUNCTION("browsingData.removeLocalStorage", | 228 DECLARE_EXTENSION_FUNCTION("browsingData.removeLocalStorage", |
| 227 BROWSINGDATA_REMOVELOCALSTORAGE) | 229 BROWSINGDATA_REMOVELOCALSTORAGE) |
| 228 | 230 |
| 229 protected: | 231 protected: |
| 230 virtual ~RemoveLocalStorageFunction() {} | 232 virtual ~BrowsingDataRemoveLocalStorageFunction() {} |
| 231 | 233 |
| 232 // BrowsingDataRemoveFunction: | 234 // BrowsingDataRemoverFunction: |
| 233 virtual int GetRemovalMask() OVERRIDE; | 235 virtual int GetRemovalMask() OVERRIDE; |
| 234 }; | 236 }; |
| 235 | 237 |
| 236 class RemovePluginDataFunction : public BrowsingDataRemoveFunction { | 238 class BrowsingDataRemovePluginDataFunction |
| 239 : public BrowsingDataRemoverFunction { |
| 237 public: | 240 public: |
| 238 DECLARE_EXTENSION_FUNCTION("browsingData.removePluginData", | 241 DECLARE_EXTENSION_FUNCTION("browsingData.removePluginData", |
| 239 BROWSINGDATA_REMOVEPLUGINDATA) | 242 BROWSINGDATA_REMOVEPLUGINDATA) |
| 240 | 243 |
| 241 protected: | 244 protected: |
| 242 virtual ~RemovePluginDataFunction() {} | 245 virtual ~BrowsingDataRemovePluginDataFunction() {} |
| 243 | 246 |
| 244 // BrowsingDataRemoveFunction: | 247 // BrowsingDataRemoverFunction: |
| 245 virtual int GetRemovalMask() OVERRIDE; | 248 virtual int GetRemovalMask() OVERRIDE; |
| 246 }; | 249 }; |
| 247 | 250 |
| 248 class RemovePasswordsFunction : public BrowsingDataRemoveFunction { | 251 class BrowsingDataRemovePasswordsFunction : public BrowsingDataRemoverFunction { |
| 249 public: | 252 public: |
| 250 DECLARE_EXTENSION_FUNCTION("browsingData.removePasswords", | 253 DECLARE_EXTENSION_FUNCTION("browsingData.removePasswords", |
| 251 BROWSINGDATA_REMOVEPASSWORDS) | 254 BROWSINGDATA_REMOVEPASSWORDS) |
| 252 | 255 |
| 253 protected: | 256 protected: |
| 254 virtual ~RemovePasswordsFunction() {} | 257 virtual ~BrowsingDataRemovePasswordsFunction() {} |
| 255 | 258 |
| 256 // BrowsingDataRemoveFunction: | 259 // BrowsingDataRemoverFunction: |
| 257 virtual int GetRemovalMask() OVERRIDE; | 260 virtual int GetRemovalMask() OVERRIDE; |
| 258 }; | 261 }; |
| 259 | 262 |
| 260 class RemoveWebSQLFunction : public BrowsingDataRemoveFunction { | 263 class BrowsingDataRemoveWebSQLFunction : public BrowsingDataRemoverFunction { |
| 261 public: | 264 public: |
| 262 DECLARE_EXTENSION_FUNCTION("browsingData.removeWebSQL", | 265 DECLARE_EXTENSION_FUNCTION("browsingData.removeWebSQL", |
| 263 BROWSINGDATA_REMOVEWEBSQL) | 266 BROWSINGDATA_REMOVEWEBSQL) |
| 264 | 267 |
| 265 protected: | 268 protected: |
| 266 virtual ~RemoveWebSQLFunction() {} | 269 virtual ~BrowsingDataRemoveWebSQLFunction() {} |
| 267 | 270 |
| 268 // BrowsingDataRemoveFunction: | 271 // BrowsingDataRemoverFunction: |
| 269 virtual int GetRemovalMask() OVERRIDE; | 272 virtual int GetRemovalMask() OVERRIDE; |
| 270 }; | 273 }; |
| 271 | 274 |
| 272 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 275 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| OLD | NEW |