Upstream version 7.35.141.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / manifest_handlers / csp_handler.h
1 // Copyright (c) 2013 Intel Corporation. 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 #ifndef XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_CSP_HANDLER_H_
5 #define XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_CSP_HANDLER_H_
6
7 #include <map>
8 #include <string>
9 #include <vector>
10
11 #include "xwalk/application/common/application_data.h"
12 #include "xwalk/application/common/manifest_handler.h"
13
14 namespace xwalk {
15 namespace application {
16
17 class CSPInfo : public ApplicationData::ManifestData {
18  public:
19   CSPInfo();
20   virtual ~CSPInfo();
21
22   void SetDirective(const std::string& directive_name,
23                     const std::vector<std::string>& directive_value) {
24     policies_[directive_name] = directive_value;
25   }
26   const std::map<std::string, std::vector<std::string> >&
27       GetDirectives() const { return policies_; }
28
29  private:
30   std::map<std::string, std::vector<std::string> > policies_;
31 };
32
33 class CSPHandler : public ManifestHandler {
34  public:
35   explicit CSPHandler(Package::Type type);
36   virtual ~CSPHandler();
37
38   virtual bool Parse(scoped_refptr<ApplicationData> application,
39                      base::string16* error) OVERRIDE;
40   virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE;
41   virtual std::vector<std::string> Keys() const OVERRIDE;
42
43  private:
44   Package::Type package_type_;
45
46   DISALLOW_COPY_AND_ASSIGN(CSPHandler);
47 };
48
49 }  // namespace application
50 }  // namespace xwalk
51
52 #endif  // XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_CSP_HANDLER_H_