summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_data_deleter.h
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 14:47:31 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 14:47:31 +0000
commit0da7636f1e91b05a407a310800d6fe79796931a4 (patch)
treeaed2e394e82f5ee4127bdf66ab9416bda0576d01 /chrome/browser/extensions/extension_data_deleter.h
parent32c5626f902813453bc20ff0bf8449f88d443141 (diff)
downloadchromium_src-0da7636f1e91b05a407a310800d6fe79796931a4.zip
chromium_src-0da7636f1e91b05a407a310800d6fe79796931a4.tar.gz
chromium_src-0da7636f1e91b05a407a310800d6fe79796931a4.tar.bz2
Clear cookies, local storage and databases when an extension gets uninstalled.
BUG=27938 TEST=Unittest in extension_service_unitttest.cc Review URL: http://codereview.chromium.org/1095003 Patch from Mattias Nissler. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42467 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_data_deleter.h')
-rw-r--r--chrome/browser/extensions/extension_data_deleter.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_data_deleter.h b/chrome/browser/extensions/extension_data_deleter.h
new file mode 100644
index 0000000..a886833
--- /dev/null
+++ b/chrome/browser/extensions/extension_data_deleter.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_
+
+#include <string>
+
+#include "base/ref_counted.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/in_process_webkit/webkit_context.h"
+#include "chrome/browser/net/url_request_context_getter.h"
+#include "googleurl/src/gurl.h"
+#include "webkit/database/database_tracker.h"
+
+class Extension;
+class Profile;
+
+// A helper class that takes care of removing local storage, databases and
+// cookies for a given extension. This is used by
+// ExtensionsService::ClearExtensionData() upon uninstalling an extension.
+class ExtensionDataDeleter
+ : public base::RefCountedThreadSafe<ExtensionDataDeleter,
+ ChromeThread::DeleteOnUIThread> {
+ public:
+ ExtensionDataDeleter(Profile* profile, const GURL& extension_url);
+
+ // Start removing data. The extension should not be running when this is
+ // called. Cookies are deleted on the current thread, local storage and
+ // databases are deleted asynchronously on the webkit and file threads,
+ // respectively. This function must be called from the UI thread.
+ void StartDeleting();
+
+ private:
+ // Deletes the database for the extension. May only be called on the file
+ // thread.
+ void DeleteDatabaseOnFileThread();
+
+ // Deletes local storage for the extension. May only be called on the webkit
+ // thread.
+ void DeleteLocalStorageOnWebkitThread();
+
+ // The database context for deleting the database.
+ scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
+
+ // Provides access to the extension request context.
+ scoped_refptr<URLRequestContextGetter> extension_request_context_;
+
+ // The URL of the extension we're removing data for.
+ GURL extension_url_;
+
+ // The security origin identifier for which we're deleting stuff.
+ string16 origin_id_;
+
+ // Webkit context for accessing the DOM storage helper.
+ scoped_refptr<WebKitContext> webkit_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionDataDeleter);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_