Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Unified Diff: content/browser/devtools/protocol/network_handler.cc

Issue 2785943005: DevTools: Fix Network.clearBrowserCookies (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/devtools/protocol/network_handler.cc
diff --git a/content/browser/devtools/protocol/network_handler.cc b/content/browser/devtools/protocol/network_handler.cc
index 4e3f2746c56f08364e7a7b8f03a2a7bfb6654140..5f4df9f132243ec3303edc0af481c46ef09304b3 100644
--- a/content/browser/devtools/protocol/network_handler.cc
+++ b/content/browser/devtools/protocol/network_handler.cc
@@ -192,6 +192,19 @@ void DeletedCookieOnIO(std::unique_ptr<DeleteCookieCallback> callback) {
base::Passed(std::move(callback))));
}
+void ClearedCookiesOnIO(int num_deleted) {
phulce 2017/03/31 16:40:42 It'd be nice to communicate this over the protocol
dgozman 2017/03/31 22:57:55 You can mark it "async" in protocol_config.json, i
phulce 2017/03/31 23:54:32 done
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
+void ClearCookiesOnIO(ResourceContext* resource_context,
+ net::URLRequestContextGetter* context_getter) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ net::URLRequestContext* request_context =
+ context_getter->GetURLRequestContext();
+ request_context->cookie_store()->DeleteAllAsync(
+ base::Bind(&ClearedCookiesOnIO));
+}
+
void DeleteCookieOnIO(
ResourceContext* resource_context,
net::URLRequestContextGetter* context_getter,
@@ -439,8 +452,19 @@ Response NetworkHandler::ClearBrowserCache() {
}
Response NetworkHandler::ClearBrowserCookies() {
- if (host_)
- GetContentClient()->browser()->ClearCookies(host_);
+ if (!host_) {
+ return Response::InternalError();
+ }
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ClearCookiesOnIO,
+ base::Unretained(host_->GetSiteInstance()
+ ->GetBrowserContext()
+ ->GetResourceContext()),
+ base::Unretained(host_->GetProcess()
+ ->GetStoragePartition()
+ ->GetURLRequestContext())));
return Response::OK();
}

Powered by Google App Engine
This is Rietveld 408576698