summaryrefslogtreecommitdiffstats
path: root/webkit/database/database_tracker.cc
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 /webkit/database/database_tracker.cc
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 'webkit/database/database_tracker.cc')
-rw-r--r--webkit/database/database_tracker.cc60
1 files changed, 50 insertions, 10 deletions
diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc
index bc7dd47..ea1994e 100644
--- a/webkit/database/database_tracker.cc
+++ b/webkit/database/database_tracker.cc
@@ -420,6 +420,22 @@ void DatabaseTracker::ScheduleDatabaseForDeletion(
origin_identifier, database_name));
}
+void DatabaseTracker::ScheduleDatabasesForDeletion(
+ const DatabaseSet& databases,
+ net::CompletionCallback* callback) {
+ DCHECK(!callback ||
+ deletion_callbacks_.find(callback) == deletion_callbacks_.end());
+ DCHECK(!databases.empty());
+ if (callback)
+ deletion_callbacks_[callback] = databases;
+ for (DatabaseSet::const_iterator ori = databases.begin();
+ ori != databases.end(); ++ori) {
+ for (std::set<string16>::const_iterator db = ori->second.begin();
+ db != ori->second.end(); ++db)
+ ScheduleDatabaseForDeletion(ori->first, *db);
+ }
+}
+
int DatabaseTracker::DeleteDatabase(const string16& origin_identifier,
const string16& database_name,
net::CompletionCallback* callback) {
@@ -477,18 +493,42 @@ int DatabaseTracker::DeleteDataModifiedSince(
}
}
+ if (rv != net::OK)
+ return rv;
+
if (!to_be_deleted.empty()) {
- if (callback)
- deletion_callbacks_[callback] = to_be_deleted;
- for (DatabaseSet::iterator ori = to_be_deleted.begin();
- ori != to_be_deleted.end(); ++ori) {
- for (std::set<string16>::iterator db = ori->second.begin();
- db != ori->second.end(); ++db)
- ScheduleDatabaseForDeletion(ori->first, *db);
- }
- rv = net::ERR_IO_PENDING;
+ ScheduleDatabasesForDeletion(to_be_deleted, callback);
+ return net::ERR_IO_PENDING;
+ }
+ return net::OK;
+}
+
+int DatabaseTracker::DeleteDataForOrigin(const string16& origin,
+ net::CompletionCallback* callback) {
+ if (!LazyInit())
+ return net::ERR_FAILED;
+
+ DCHECK(!callback ||
+ deletion_callbacks_.find(callback) == deletion_callbacks_.end());
+ DatabaseSet to_be_deleted;
+
+ std::vector<DatabaseDetails> details;
+ if (!databases_table_->GetAllDatabaseDetailsForOrigin(origin, &details))
+ return net::ERR_FAILED;
+ for (std::vector<DatabaseDetails>::const_iterator db = details.begin();
+ db != details.end(); ++db) {
+ // Check if the database is opened by any renderer.
+ if (database_connections_.IsDatabaseOpened(origin, db->database_name))
+ to_be_deleted[origin].insert(db->database_name);
+ else
+ DeleteClosedDatabase(origin, db->database_name);
}
- return rv;
+
+ if (!to_be_deleted.empty()) {
+ ScheduleDatabasesForDeletion(to_be_deleted, callback);
+ return net::ERR_IO_PENDING;
+ }
+ return net::OK;
}
// static