blob: 0aec12a25d3b8b33275f069e70c97a3fa999bf64 [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]c10da4b02010-03-25 14:38:322// 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]32b76ef2010-07-26 23:08:247#pragma once
[email protected]c10da4b02010-03-25 14:38:328
[email protected]0d6ec3a72011-09-02 02:09:439#include "base/file_path.h"
[email protected]3b63f8f42011-03-28 01:54:1510#include "base/memory/ref_counted.h"
[email protected]24492412010-08-15 19:00:1911#include "base/string16.h"
[email protected]c38831a12011-10-28 12:44:4912#include "content/public/browser/browser_thread.h"
[email protected]c10da4b02010-03-25 14:38:3213#include "googleurl/src/gurl.h"
[email protected]04068382010-08-26 22:51:5414
15namespace webkit_database {
16class DatabaseTracker;
17}
[email protected]c10da4b02010-03-25 14:38:3218
[email protected]b7b82eb2010-12-14 01:12:1219namespace fileapi {
[email protected]397281f2011-02-14 05:15:5320class FileSystemContext;
[email protected]b7b82eb2010-12-14 01:12:1221}
22
[email protected]abe2c032011-03-31 18:49:3423namespace net {
24class URLRequestContextGetter;
25}
26
[email protected]0d6ec3a72011-09-02 02:09:4327class ChromeAppCacheService;
28class Profile;
29class WebKitContext;
30
[email protected]c10da4b02010-03-25 14:38:3231// A helper class that takes care of removing local storage, databases and
32// cookies for a given extension. This is used by
[email protected]eaa7dd182010-12-14 11:09:0033// ExtensionService::ClearExtensionData() upon uninstalling an extension.
[email protected]c10da4b02010-03-25 14:38:3234class ExtensionDataDeleter
[email protected]631bb742011-11-02 11:29:3935 : public base::RefCountedThreadSafe<
36 ExtensionDataDeleter, content::BrowserThread::DeleteOnUIThread> {
[email protected]c10da4b02010-03-25 14:38:3237 public:
[email protected]dc0b5a12011-10-14 00:06:1338 // Starts removing data. The extension should not be running when this is
[email protected]c10da4b02010-03-25 14:38:3239 // called. Cookies are deleted on the current thread, local storage and
[email protected]dc0b5a12011-10-14 00:06:1340 // 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]c10da4b02010-03-25 14:38:3247
48 private:
[email protected]631bb742011-11-02 11:29:3949 friend struct content::BrowserThread::DeleteOnThread<
50 content::BrowserThread::UI>;
[email protected]525074d2011-03-07 22:32:2751 friend class DeleteTask<ExtensionDataDeleter>;
52
[email protected]dc0b5a12011-10-14 00:06:1353 ExtensionDataDeleter(
54 Profile* profile,
55 const std::string& extension_id,
56 const GURL& storage_origin,
57 bool is_storage_isolated);
[email protected]525074d2011-03-07 22:32:2758 ~ExtensionDataDeleter();
59
[email protected]9eaa18e2010-06-29 20:51:0160 // Deletes the cookies for the extension. May only be called on the io
61 // thread.
62 void DeleteCookiesOnIOThread();
63
[email protected]c10da4b02010-03-25 14:38:3264 // 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]e1dcf922010-11-22 19:12:1272 // Deletes indexed db files for the extension. May only be called on the
73 // webkit thread.
74 void DeleteIndexedDBOnWebkitThread();
75
[email protected]09a316022010-12-03 03:21:3776 // Deletes filesystem files for the extension. May only be called on the
77 // file thread.
78 void DeleteFileSystemOnFileThread();
79
[email protected]0d6ec3a72011-09-02 02:09:4380 // Deletes appcache files for the extension. May only be called on the IO
81 // thread.
82 void DeleteAppcachesOnIOThread();
83
[email protected]dc0b5a12011-10-14 00:06:1384 // The ID of the extension being deleted.
85 const std::string extension_id_;
86
[email protected]c10da4b02010-03-25 14:38:3287 // The database context for deleting the database.
88 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
89
[email protected]0d6ec3a72011-09-02 02:09:4390 // Provides access to the request context.
[email protected]abe2c032011-03-31 18:49:3491 scoped_refptr<net::URLRequestContextGetter> extension_request_context_;
[email protected]c10da4b02010-03-25 14:38:3292
[email protected]0d6ec3a72011-09-02 02:09:4393 // The origin of the extension/app for which we're going to clear data.
94 GURL storage_origin_;
[email protected]c10da4b02010-03-25 14:38:3295
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]397281f2011-02-14 05:15:53102 scoped_refptr<fileapi::FileSystemContext> file_system_context_;
[email protected]09a316022010-12-03 03:21:37103
[email protected]0d6ec3a72011-09-02 02:09:43104 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]c10da4b02010-03-25 14:38:32110 DISALLOW_COPY_AND_ASSIGN(ExtensionDataDeleter);
111};
112
113#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_