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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
6 #define CHROME_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/values.h"
12 #include "content/public/browser/resource_request_info.h"
13 #include "content/public/browser/resource_throttle.h"
14
15 class Profile;
16
17 namespace content {
18 class ResourceHandle;
19 class ResourceRequestInfo;
20 }
21
22 namespace net {
23 class URLRequest;
24 }
25
26 // This throttle asynchronously executes the clearing of browsing data.
27 // It does not block navigation.
28 class ClearSiteDataThrottle : public content::ResourceThrottle {
29 public:
30 explicit ClearSiteDataThrottle(const net::URLRequest* request);
31 ~ClearSiteDataThrottle() override;
32
33 public:
34 // ResourceThrottle implementation:
35 void WillProcessResponse(bool* defer) override;
36 const char* GetNameForLogging() const override;
37
38 private:
39 // Process the response. This must be done on UI thread, since both
40 // WebContentsGetter and BrowsingDataRemover require to be called from there.
41 // The |getter|, |domain| and |header| from the request are passed to this
42 // static method so that further processing can be independent from
43 // the lifetime of the throttle.
44 static void ProcessResponseOnUIThread(
45 const content::ResourceRequestInfo::WebContentsGetter& getter,
46 std::string domain,
47 std::string header);
48
49 // Called by ProcessResponseOnUIThread() after successful parsing of |header|.
50 // Clears data for the |profile| and |domain|. The datatypes are determined
51 // by the parsed |header|.
52 static void ClearData(
53 Profile* profile,
54 std::string domain,
55 std::unique_ptr<base::Value> header);
56
57 // Called by ProcessResponseOnUIThread() if header could not be parsed
58 // and reports the |error|.
59 static void OnParseError(const std::string& error);
60
61 const net::URLRequest* request_;
62
63 DISALLOW_COPY_AND_ASSIGN(ClearSiteDataThrottle);
64 };
65
66 #endif // CHROME_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698