Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / nacl / renderer / json_manifest.h
blob80a2ac7cd5288d0916fa8f5e7d623e7acb573f6a
1 // Copyright 2014 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.
5 #ifndef COMPONENTS_NACL_RENDERER_JSON_MANIFEST_H
6 #define COMPONENTS_NACL_RENDERER_JSON_MANIFEST_H
8 #include <set>
9 #include <string>
10 #include <utility>
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h"
14 #include "components/nacl/renderer/ppb_nacl_private.h"
16 namespace nacl {
17 class JsonManifest;
18 class NexeLoadManager;
19 struct NaClResourcePrefetchRequest;
21 class JsonManifest {
22 public:
23 struct ErrorInfo {
24 PP_NaClError error;
25 std::string string;
28 JsonManifest(const std::string& manifest_base_url,
29 const std::string& sandbox_isa,
30 bool nonsfi_enabled,
31 bool pnacl_debug);
32 ~JsonManifest();
34 // Initialize the manifest object for use by later lookups. Returns
35 // true if the manifest parses correctly and matches the schema.
36 bool Init(const std::string& json_manifest, ErrorInfo* error_info);
38 // Gets the full program URL for the current sandbox ISA from the
39 // manifest file.
40 bool GetProgramURL(std::string* full_url,
41 PP_PNaClOptions* pnacl_options,
42 bool* uses_nonsfi_mode,
43 ErrorInfo* error_info) const;
45 // Gets all the keys and their URLs in the "files" section that are
46 // prefetchable.
47 void GetPrefetchableFiles(
48 std::vector<NaClResourcePrefetchRequest>* out_files) const;
50 // Resolves a key from the "files" section to a fully resolved URL,
51 // i.e., relative URL values are fully expanded relative to the
52 // manifest's URL (via ResolveURL).
53 // If there was an error, details are reported via error_info.
54 bool ResolveKey(const std::string& key,
55 std::string* full_url,
56 PP_PNaClOptions* pnacl_options) const;
58 private:
59 bool MatchesSchema(ErrorInfo* error_info);
60 bool GetKeyUrl(const base::DictionaryValue& dictionary,
61 const std::string& key,
62 std::string* full_url,
63 PP_PNaClOptions* pnacl_options) const;
64 bool GetURLFromISADictionary(const base::DictionaryValue& parent_dictionary,
65 const std::string& parent_key,
66 std::string* url,
67 PP_PNaClOptions* pnacl_options,
68 bool* uses_nonsfi_mode,
69 ErrorInfo* error_info) const;
71 std::string manifest_base_url_;
72 std::string sandbox_isa_;
73 bool nonsfi_enabled_;
74 bool pnacl_debug_;
76 // The dictionary of manifest information parsed in Init().
77 scoped_ptr<base::DictionaryValue> dictionary_;
80 } // namespace nacl
82 #endif // COMPONENTS_NACL_RENDERER_JSON_MANIFEST_H