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

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

Issue 2488743003: (Re-)introduce AncestorThrottle to handle 'X-Frame-Options'. (Closed)
Patch Set: Addressed comments (@alexmos #2) Created 3 years, 12 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_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 static std::unique_ptr<NavigationThrottle> MaybeCreateThrottleFor(
37 NavigationHandle* handle);
38
39 ~AncestorThrottle() override;
40
41 NavigationThrottle::ThrottleCheckResult WillProcessResponse() override;
42
43 private:
44 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest, ParsingXFrameOptions);
45 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest, ErrorsParsingXFrameOptions);
46 FRIEND_TEST_ALL_PREFIXES(AncestorThrottleTest,
47 IgnoreWhenFrameAncestorsPresent);
48
49 explicit AncestorThrottle(NavigationHandle* handle);
50 void ParseError(const std::string& value, HeaderDisposition disposition);
51 void ConsoleError(HeaderDisposition disposition);
52
53 // Parses an 'X-Frame-Options' header. If the result is either CONFLICT
54 // or INVALID, |header_value| will be populated with the value which caused
55 // the parse error.
56 HeaderDisposition ParseHeader(const net::HttpResponseHeaders* headers,
57 std::string* header_value);
58
59 DISALLOW_COPY_AND_ASSIGN(AncestorThrottle);
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_BROWSER_FRAME_HOST_ANCESTOR_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698