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
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"
19 class NexeLoadManager
;
21 // There is at most one JsonManifest per PP_Instance. This adds a one-to-one
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
);
37 JsonManifest(const std::string
& manifest_base_url
,
38 const std::string
& sandbox_isa
,
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
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;
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
,
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_
;
79 // The dictionary of manifest information parsed in Init().
80 Json::Value dictionary_
;
85 #endif // COMPONENTS_NACL_RENDERER_JSON_MANIFEST_H