OLD | NEW |
---|---|
(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_FRAME_HOST_ANCESTOR_THROTTLE_H_ | |
nasko
2016/05/02 17:22:09
This code lives in content/ now ;).
Mike West
2016/05/05 08:14:28
Yes, sorry. Typo. :(
| |
6 #define CHROME_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 content { | |
16 class NavigationHandle; | |
17 } | |
18 | |
19 namespace net { | |
20 class HttpResponseHeaders; | |
21 } | |
22 | |
23 namespace content { | |
24 | |
25 // An AncestorThrottle is responsible for enforcing a resource's embedding | |
26 // rules, and blocking requests which violate them. | |
27 class CONTENT_EXPORT AncestorThrottle : public NavigationThrottle { | |
28 public: | |
29 enum HeaderDisposition { | |
30 NONE, | |
31 DENY, | |
32 SAMEORIGIN, | |
33 ALLOWALL, | |
34 INVALID, | |
35 CONFLICT, | |
36 IGNORE | |
37 }; | |
38 | |
39 static std::unique_ptr<NavigationThrottle> MaybeCreateThrottleFor( | |
40 NavigationHandle* handle); | |
41 | |
42 explicit AncestorThrottle(NavigationHandle* handle); | |
43 ~AncestorThrottle() override; | |
44 | |
45 NavigationThrottle::ThrottleCheckResult WillProcessResponse() override; | |
46 | |
47 private: | |
48 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest, ParsingXFrameOptions); | |
49 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest, ErrorsParsingXFrameOptions); | |
50 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest, | |
51 IgnoreWhenFrameAncestorsPresent); | |
52 | |
53 void ParseError(const std::string& value, HeaderDisposition disposition); | |
54 void ConsoleError(HeaderDisposition disposition); | |
55 | |
56 // Parses an 'X-Frame-Options' header. If the result is either CONFLICT | |
57 // or INVALID, |header_value| will be populated with the value which caused | |
58 // the parse error. | |
59 HeaderDisposition ParseHeader(const net::HttpResponseHeaders* headers, | |
60 std::string* header_value); | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(AncestorThrottle); | |
63 }; | |
64 | |
65 } // namespace content | |
66 | |
67 #endif // CHROME_BROWSER_FRAME_HOST_ANCESTOR_THROTTLE_H_ | |
OLD | NEW |