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