blob: 98cf4330643218cfb59103f96eb5142d758ed874 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// 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.
#include "chrome/browser/extensions/extension_data_deleter.h"
#include "chrome/browser/profile.h"
#include "chrome/common/extensions/extension.h"
#include "net/base/cookie_monster.h"
#include "net/base/net_errors.h"
#include "webkit/database/database_util.h"
ExtensionDataDeleter::ExtensionDataDeleter(Profile* profile,
const GURL& extension_url) {
DCHECK(profile);
webkit_context_ = profile->GetWebKitContext();
database_tracker_ = profile->GetDatabaseTracker();
extension_request_context_ = profile->GetRequestContextForExtensions();
extension_url_ = extension_url;
origin_id_ =
webkit_database::DatabaseUtil::GetOriginIdentifier(extension_url_);
}
void ExtensionDataDeleter::StartDeleting() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
net::CookieMonster* cookie_monster =
extension_request_context_->GetCookieStore()->GetCookieMonster();
if (cookie_monster)
cookie_monster->DeleteAllForURL(extension_url_, true);
ChromeThread::PostTask(ChromeThread::WEBKIT, FROM_HERE,
NewRunnableMethod(this,
&ExtensionDataDeleter::DeleteLocalStorageOnWebkitThread));
ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(this,
&ExtensionDataDeleter::DeleteDatabaseOnFileThread));
}
void ExtensionDataDeleter::DeleteDatabaseOnFileThread() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
int rv = database_tracker_->DeleteDataForOrigin(origin_id_, NULL);
DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING);
}
void ExtensionDataDeleter::DeleteLocalStorageOnWebkitThread() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
webkit_context_->dom_storage_context()->DeleteLocalStorageForOrigin(
origin_id_);
}
|