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

Unified Diff: chrome/browser/browsing_data/clear_site_data_throttle.h

Issue 2025683003: First experimental implementation of the Clear-Site-Data header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: chrome/browser/browsing_data/clear_site_data_throttle.h
diff --git a/chrome/browser/browsing_data/clear_site_data_throttle.h b/chrome/browser/browsing_data/clear_site_data_throttle.h
new file mode 100644
index 0000000000000000000000000000000000000000..a94b1e9d9c0f8b684014f59a1a85a810128dfac8
--- /dev/null
+++ b/chrome/browser/browsing_data/clear_site_data_throttle.h
@@ -0,0 +1,66 @@
+// Copyright 2016 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_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
+#define CHROME_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/values.h"
+#include "content/public/browser/resource_request_info.h"
+#include "content/public/browser/resource_throttle.h"
+
+class Profile;
+
+namespace content {
+class ResourceHandle;
+class ResourceRequestInfo;
+}
+
+namespace net {
+class URLRequest;
+}
+
+// This throttle asynchronously executes the clearing of browsing data.
+// It does not block navigation.
+class ClearSiteDataThrottle : public content::ResourceThrottle {
+ public:
+ explicit ClearSiteDataThrottle(const net::URLRequest* request);
+ ~ClearSiteDataThrottle() override;
+
+ public:
+ // ResourceThrottle implementation:
+ void WillProcessResponse(bool* defer) override;
+ const char* GetNameForLogging() const override;
+
+ private:
+ // Process the response. This must be done on UI thread, since both
+ // WebContentsGetter and BrowsingDataRemover require to be called from there.
+ // The |getter|, |domain| and |header| from the request are passed to this
+ // static method so that further processing can be independent from
+ // the lifetime of the throttle.
+ static void ProcessResponseOnUIThread(
+ const content::ResourceRequestInfo::WebContentsGetter& getter,
+ std::string domain,
+ std::string header);
+
+ // Called by ProcessResponseOnUIThread() after successful parsing of |header|.
+ // Clears data for the |profile| and |domain|. The datatypes are determined
+ // by the parsed |header|.
+ static void ClearData(
+ Profile* profile,
+ std::string domain,
+ std::unique_ptr<base::Value> header);
+
+ // Called by ProcessResponseOnUIThread() if header could not be parsed
+ // and reports the |error|.
+ static void OnParseError(const std::string& error);
+
+ const net::URLRequest* request_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClearSiteDataThrottle);
+};
+
+#endif // CHROME_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_

Powered by Google App Engine
This is Rietveld 408576698