• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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 EXTENSIONS_COMMON_MANIFEST_HANDLERS_SANDBOXED_PAGE_INFO_H_
6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_SANDBOXED_PAGE_INFO_H_
7 
8 #include <string>
9 
10 #include "extensions/common/extension.h"
11 #include "extensions/common/manifest_handler.h"
12 #include "extensions/common/url_pattern_set.h"
13 
14 namespace extensions {
15 
16 struct SandboxedPageInfo : public Extension::ManifestData {
17  public:
18   SandboxedPageInfo();
19   virtual ~SandboxedPageInfo();
20 
21   // Returns the extension's Content Security Policy for the sandboxed pages.
22   static const std::string& GetContentSecurityPolicy(
23       const Extension* extension);
24 
25   // Returns the extension's sandboxed pages.
26   static const URLPatternSet& GetPages(const Extension* extension);
27 
28   // Returns true if the specified page is sandboxed.
29   static bool IsSandboxedPage(const Extension* extension,
30                               const std::string& relative_path);
31 
32   // Optional list of extension pages that are sandboxed (served from a unique
33   // origin with a different Content Security Policy).
34   URLPatternSet pages;
35 
36   // Content Security Policy that should be used to enforce the sandbox used
37   // by sandboxed pages (guaranteed to have the "sandbox" directive without the
38   // "allow-same-origin" token).
39   std::string content_security_policy;
40 };
41 
42 class SandboxedPageHandler : public ManifestHandler {
43  public:
44   SandboxedPageHandler();
45   virtual ~SandboxedPageHandler();
46 
47   virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
48 
49  private:
50   virtual const std::vector<std::string> Keys() const OVERRIDE;
51 };
52 
53 }  // namespace extensions
54 
55 #endif  // EXTENSIONS_COMMON_MANIFEST_HANDLERS_SANDBOXED_PAGE_INFO_H_
56