1 // Copyright 2018 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 THIRD_PARTY_BLINK_PUBLIC_COMMON_ORIGIN_POLICY_ORIGIN_POLICY_H_
6 #define THIRD_PARTY_BLINK_PUBLIC_COMMON_ORIGIN_POLICY_ORIGIN_POLICY_H_
7 
8 #include <memory>
9 #include <set>
10 #include <string>
11 #include <vector>
12 
13 #include "base/strings/string_piece.h"
14 #include "third_party/blink/public/common/common_export.h"
15 #include "url/origin.h"
16 
17 namespace blink {
18 
19 class OriginPolicyParser;
20 
21 class BLINK_COMMON_EXPORT OriginPolicy {
22  public:
23   ~OriginPolicy();
24 
25   // Create & parse the manifest.
26   static std::unique_ptr<OriginPolicy> From(base::StringPiece);
27 
28   struct CSP {
29     std::string policy;
30     bool report_only;
31   };
GetContentSecurityPolicies()32   const std::vector<CSP>& GetContentSecurityPolicies() const { return csp_; }
33 
GetFeaturePolicies()34   const std::vector<std::string>& GetFeaturePolicies() const {
35     return features_;
36   }
37 
GetFirstPartySet()38   const std::set<url::Origin>& GetFirstPartySet() const {
39     return first_party_set_;
40   }
41 
42  private:
43   friend class OriginPolicyParser;
44 
45   OriginPolicy();
46 
47   std::vector<CSP> csp_;
48   std::vector<std::string> features_;
49   std::set<url::Origin> first_party_set_;
50 };
51 
52 }  // namespace blink
53 
54 #endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_ORIGIN_POLICY_ORIGIN_POLICY_H_
55