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

Side by Side Diff: content/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: Fixed tests, extracted c/b/browsing_data Created 4 years, 5 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 CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
6 #define CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h"
13 #include "base/values.h"
14 #include "content/public/browser/navigation_throttle.h"
15 #include "content/public/browser/resource_request_info.h"
16 #include "content/public/common/console_message_level.h"
17 #include "url/gurl.h"
18
19 class Profile;
20
21 namespace content {
22
23 class NavigationHandle;
24
25 // This throttle asynchronously executes the clearing of browsing data.
26 // It does not block navigation.
27 class CONTENT_EXPORT ClearSiteDataThrottle : public NavigationThrottle {
28 public:
29 struct ConsoleMessage {
30 std::string text;
31 ConsoleMessageLevel level;
32 };
33
34 static std::unique_ptr<NavigationThrottle>
35 CreateThrottleFor(NavigationHandle* handle);
36
37 ~ClearSiteDataThrottle() override;
38
39 // NavigationThrottle implementation:
40 ThrottleCheckResult WillStartRequest() override;
41 ThrottleCheckResult WillProcessResponse() override;
42 ThrottleCheckResult WillRedirectRequest() override;
43
44 private:
45 explicit ClearSiteDataThrottle(NavigationHandle* handle);
46
47 // Scans for 'Clear-Site-Data' headers, calls ParseHeader() to parse them,
48 // and requests the actual data clearing. This is the common logic
49 // of WillProcessResponse() and WillRedirectRequest().
50 void HandleHeader();
51
52 // Parses the value of the 'Clear-Site-Data' header and outputs whether
53 // the header requests to |clear_cookies|, |clear_storage|, and |clear_cache|.
54 // The |messages| vector will be filled with messages to be output in the
55 // console. Returns true if parsing was successful.
56 bool ParseHeader(const std::string& header,
57 bool* clear_cookies, bool* clear_storage, bool* clear_cache,
58 std::vector<ConsoleMessage>* messages);
59
60 // Cached console messages to be output when the RenderFrameHost is ready.
61 std::vector<ConsoleMessage> messages_;
62 GURL current_url_;
63
64 FRIEND_TEST_ALL_PREFIXES(ClearSiteDataThrottleTest, ParseHeader);
65 FRIEND_TEST_ALL_PREFIXES(ClearSiteDataThrottleTest, InvalidHeader);
66
67 DISALLOW_COPY_AND_ASSIGN(ClearSiteDataThrottle);
68 };
69
70 } // namespace content
71
72 #endif // CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698