Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / nacl / renderer / json_manifest.h
blob7fdb1ab9e18d1af97f8ce2c9dddb892bd622b7d4
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>
11 #include "base/memory/scoped_ptr.h"
12 #include "ppapi/c/pp_array_output.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/private/ppb_nacl_private.h"
15 #include "third_party/jsoncpp/source/include/json/value.h"
17 namespace nacl {
18 class JsonManifest;
19 class NexeLoadManager;
21 // There is at most one JsonManifest per PP_Instance. This adds a one-to-one
22 // mapping.
23 void AddJsonManifest(PP_Instance instance, scoped_ptr<JsonManifest> manifest);
25 // Returns a non-owning pointer to the JsonManifest for the given instance.
26 // Returns NULL if no such JsonManifest exists.
27 JsonManifest* GetJsonManifest(PP_Instance instance);
28 void DeleteJsonManifest(PP_Instance instance);
30 class JsonManifest {
31 public:
32 struct ErrorInfo {
33 PP_NaClError error;
34 std::string string;
37 JsonManifest(const std::string& manifest_base_url,
38 const std::string& sandbox_isa,
39 bool nonsfi_enabled,
40 bool pnacl_debug);
42 // Initialize the manifest object for use by later lookups. Returns
43 // true if the manifest parses correctly and matches the schema.
44 bool Init(const std::string& json_manifest, ErrorInfo* error_info);
46 // Gets the full program URL for the current sandbox ISA from the
47 // manifest file.
48 bool GetProgramURL(std::string* full_url,
49 PP_PNaClOptions* pnacl_options,
50 bool* uses_nonsfi_mode,
51 ErrorInfo* error_info) const;
53 // Resolves a key from the "files" section to a fully resolved URL,
54 // i.e., relative URL values are fully expanded relative to the
55 // manifest's URL (via ResolveURL).
56 // If there was an error, details are reported via error_info.
57 bool ResolveKey(const std::string& key,
58 std::string* full_url,
59 PP_PNaClOptions* pnacl_options) const;
61 private:
62 bool MatchesSchema(ErrorInfo* error_info);
63 bool GetKeyUrl(const Json::Value& dictionary,
64 const std::string& key,
65 std::string* full_url,
66 PP_PNaClOptions* pnacl_options) const;
67 bool GetURLFromISADictionary(const Json::Value& dictionary,
68 const std::string& parent_key,
69 std::string* url,
70 PP_PNaClOptions* pnacl_options,
71 bool* uses_nonsfi_mode,
72 ErrorInfo* error_info) const;
74 std::string manifest_base_url_;
75 std::string sandbox_isa_;
76 bool nonsfi_enabled_;
77 bool pnacl_debug_;
79 // The dictionary of manifest information parsed in Init().
80 Json::Value dictionary_;
83 } // namespace nacl
85 #endif // COMPONENTS_NACL_RENDERER_JSON_MANIFEST_H