[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 8 | |
[email protected] | 0d6ec3a7 | 2011-09-02 02:09:43 | [diff] [blame] | 9 | #include "base/file_path.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
[email protected] | 2449241 | 2010-08-15 19:00:19 | [diff] [blame] | 11 | #include "base/string16.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 12 | #include "content/public/browser/browser_thread.h" |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 13 | #include "googleurl/src/gurl.h" |
[email protected] | 0406838 | 2010-08-26 22:51:54 | [diff] [blame] | 14 | |
| 15 | namespace webkit_database { |
| 16 | class DatabaseTracker; |
| 17 | } |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 18 | |
[email protected] | b7b82eb | 2010-12-14 01:12:12 | [diff] [blame] | 19 | namespace fileapi { |
[email protected] | 397281f | 2011-02-14 05:15:53 | [diff] [blame] | 20 | class FileSystemContext; |
[email protected] | b7b82eb | 2010-12-14 01:12:12 | [diff] [blame] | 21 | } |
| 22 | |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 23 | namespace net { |
| 24 | class URLRequestContextGetter; |
| 25 | } |
| 26 | |
[email protected] | 0d6ec3a7 | 2011-09-02 02:09:43 | [diff] [blame] | 27 | class ChromeAppCacheService; |
| 28 | class Profile; |
| 29 | class WebKitContext; |
| 30 | |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 31 | // A helper class that takes care of removing local storage, databases and |
| 32 | // cookies for a given extension. This is used by |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 33 | // ExtensionService::ClearExtensionData() upon uninstalling an extension. |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 34 | class ExtensionDataDeleter |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 35 | : public base::RefCountedThreadSafe< |
| 36 | ExtensionDataDeleter, content::BrowserThread::DeleteOnUIThread> { |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 37 | public: |
[email protected] | dc0b5a1 | 2011-10-14 00:06:13 | [diff] [blame] | 38 | // Starts removing data. The extension should not be running when this is |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 39 | // called. Cookies are deleted on the current thread, local storage and |
[email protected] | dc0b5a1 | 2011-10-14 00:06:13 | [diff] [blame] | 40 | // databases/settings are deleted asynchronously on the webkit and file |
| 41 | // threads, respectively. This function must be called from the UI thread. |
| 42 | static void StartDeleting( |
| 43 | Profile* profile, |
| 44 | const std::string& extension_id, |
| 45 | const GURL& storage_origin, |
| 46 | bool is_storage_isolated); |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 47 | |
| 48 | private: |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 49 | friend struct content::BrowserThread::DeleteOnThread< |
| 50 | content::BrowserThread::UI>; |
[email protected] | 525074d | 2011-03-07 22:32:27 | [diff] [blame] | 51 | friend class DeleteTask<ExtensionDataDeleter>; |
| 52 | |
[email protected] | dc0b5a1 | 2011-10-14 00:06:13 | [diff] [blame] | 53 | ExtensionDataDeleter( |
| 54 | Profile* profile, |
| 55 | const std::string& extension_id, |
| 56 | const GURL& storage_origin, |
| 57 | bool is_storage_isolated); |
[email protected] | 525074d | 2011-03-07 22:32:27 | [diff] [blame] | 58 | ~ExtensionDataDeleter(); |
| 59 | |
[email protected] | 9eaa18e | 2010-06-29 20:51:01 | [diff] [blame] | 60 | // Deletes the cookies for the extension. May only be called on the io |
| 61 | // thread. |
| 62 | void DeleteCookiesOnIOThread(); |
| 63 | |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 64 | // Deletes the database for the extension. May only be called on the file |
| 65 | // thread. |
| 66 | void DeleteDatabaseOnFileThread(); |
| 67 | |
| 68 | // Deletes local storage for the extension. May only be called on the webkit |
| 69 | // thread. |
| 70 | void DeleteLocalStorageOnWebkitThread(); |
| 71 | |
[email protected] | e1dcf92 | 2010-11-22 19:12:12 | [diff] [blame] | 72 | // Deletes indexed db files for the extension. May only be called on the |
| 73 | // webkit thread. |
| 74 | void DeleteIndexedDBOnWebkitThread(); |
| 75 | |
[email protected] | 09a31602 | 2010-12-03 03:21:37 | [diff] [blame] | 76 | // Deletes filesystem files for the extension. May only be called on the |
| 77 | // file thread. |
| 78 | void DeleteFileSystemOnFileThread(); |
| 79 | |
[email protected] | 0d6ec3a7 | 2011-09-02 02:09:43 | [diff] [blame] | 80 | // Deletes appcache files for the extension. May only be called on the IO |
| 81 | // thread. |
| 82 | void DeleteAppcachesOnIOThread(); |
| 83 | |
[email protected] | dc0b5a1 | 2011-10-14 00:06:13 | [diff] [blame] | 84 | // The ID of the extension being deleted. |
| 85 | const std::string extension_id_; |
| 86 | |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 87 | // The database context for deleting the database. |
| 88 | scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 89 | |
[email protected] | 0d6ec3a7 | 2011-09-02 02:09:43 | [diff] [blame] | 90 | // Provides access to the request context. |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 91 | scoped_refptr<net::URLRequestContextGetter> extension_request_context_; |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 92 | |
[email protected] | 0d6ec3a7 | 2011-09-02 02:09:43 | [diff] [blame] | 93 | // The origin of the extension/app for which we're going to clear data. |
| 94 | GURL storage_origin_; |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 95 | |
| 96 | // The security origin identifier for which we're deleting stuff. |
| 97 | string16 origin_id_; |
| 98 | |
| 99 | // Webkit context for accessing the DOM storage helper. |
| 100 | scoped_refptr<WebKitContext> webkit_context_; |
| 101 | |
[email protected] | 397281f | 2011-02-14 05:15:53 | [diff] [blame] | 102 | scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
[email protected] | 09a31602 | 2010-12-03 03:21:37 | [diff] [blame] | 103 | |
[email protected] | 0d6ec3a7 | 2011-09-02 02:09:43 | [diff] [blame] | 104 | scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 105 | |
| 106 | // If non-empty, the extension we're deleting is an isolated app, and this |
| 107 | // is its directory which we should delete. |
| 108 | FilePath isolated_app_path_; |
| 109 | |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 110 | DISALLOW_COPY_AND_ASSIGN(ExtensionDataDeleter); |
| 111 | }; |
| 112 | |
| 113 | #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ |