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

Side by Side Diff: content/browser/frame_host/ancestor_throttle.h

Issue 2488743003: (Re-)introduce AncestorThrottle to handle 'X-Frame-Options'. (Closed)
Patch Set: Add histogram. Created 4 years 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_FRAME_HOST_ANCESTOR_THROTTLE_H_
6 #define CONTENT_BROWSER_FRAME_HOST_ANCESTOR_THROTTLE_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h"
13 #include "content/public/browser/navigation_throttle.h"
14
15 namespace net {
16 class HttpResponseHeaders;
17 }
18
19 namespace content {
20 class NavigationHandle;
21
22 // An AncestorThrottle is responsible for enforcing a resource's embedding
23 // rules, and blocking requests which violate them.
24 class CONTENT_EXPORT AncestorThrottle : public NavigationThrottle {
25 public:
26 enum class HeaderDisposition {
27 NONE = 0,
28 DENY,
29 SAMEORIGIN,
30 ALLOWALL,
31 INVALID,
32 CONFLICT,
33 BYPASS
34 };
35
36 // This enum is used for UMA metrics. Keep these enums up to date with
37 // tools/metrics/histograms/histograms.xml.
38 enum XFrameOptionsSameOrigin {
clamy 2016/12/16 15:21:43 I don't think this is needed outside of the class
arthursonzogni 2016/12/19 12:01:18 Done.
39 TOTAL = 0,
40 SAME_ORIGIN = 1,
41 SAME_ORIGIN_BLOCKED = 2,
42 SAME_ORIGIN_WITH_BAD_ANCESTOR_CHAIN = 3,
43 XFRAMEOPTIONS_SAMEORIGIN_COUNT
clamy 2016/12/16 15:21:43 I think this should be XFRAMEOPTIONS_SAMEORIGIN_MA
arthursonzogni 2016/12/19 12:01:18 Done.
44 };
45
46 static std::unique_ptr<NavigationThrottle> MaybeCreateThrottleFor(
47 NavigationHandle* handle);
48
49 ~AncestorThrottle() override;
50
51 NavigationThrottle::ThrottleCheckResult WillProcessResponse() override;
52
53 private:
54 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest, ParsingXFrameOptions);
55 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest, ErrorsParsingXFrameOptions);
56 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest,
57 IgnoreWhenFrameAncestorsPresent);
58
59 explicit AncestorThrottle(NavigationHandle* handle);
60 void ParseError(const std::string& value, HeaderDisposition disposition);
61 void ConsoleError(HeaderDisposition disposition);
62
63 // Parses an 'X-Frame-Options' header. If the result is either CONFLICT
64 // or INVALID, |header_value| will be populated with the value which caused
65 // the parse error.
66 HeaderDisposition ParseHeader(const net::HttpResponseHeaders* headers,
67 std::string* header_value);
68
69 DISALLOW_COPY_AND_ASSIGN(AncestorThrottle);
70 };
71
72 } // namespace content
73
74 #endif // CONTENT_BROWSER_FRAME_HOST_ANCESTOR_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698