Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / nacl / renderer / json_manifest.h
blob4117966ba6606db917b8070e5f0c4c2e8b68be93
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 "components/nacl/renderer/ppb_nacl_private.h"
13 #include "ppapi/c/pp_array_output.h"
14 #include "third_party/jsoncpp/source/include/json/value.h"
16 namespace nacl {
17 class JsonManifest;
18 class NexeLoadManager;
20 class JsonManifest {
21 public:
22 struct ErrorInfo {
23 PP_NaClError error;
24 std::string string;
27 JsonManifest(const std::string& manifest_base_url,
28 const std::string& sandbox_isa,
29 bool nonsfi_enabled,
30 bool pnacl_debug);
32 // Initialize the manifest object for use by later lookups. Returns
33 // true if the manifest parses correctly and matches the schema.
34 bool Init(const std::string& json_manifest, ErrorInfo* error_info);
36 // Gets the full program URL for the current sandbox ISA from the
37 // manifest file.
38 bool GetProgramURL(std::string* full_url,
39 PP_PNaClOptions* pnacl_options,
40 bool* uses_nonsfi_mode,
41 ErrorInfo* error_info) const;
43 // Gets all the keys and their URLs in the "files" section that are
44 // prefetchable.
45 void GetPrefetchableFiles(
46 std::vector<std::pair<std::string, std::string> >* out_files) const;
48 // Resolves a key from the "files" section to a fully resolved URL,
49 // i.e., relative URL values are fully expanded relative to the
50 // manifest's URL (via ResolveURL).
51 // If there was an error, details are reported via error_info.
52 bool ResolveKey(const std::string& key,
53 std::string* full_url,
54 PP_PNaClOptions* pnacl_options) const;
56 private:
57 bool MatchesSchema(ErrorInfo* error_info);
58 bool GetKeyUrl(const Json::Value& dictionary,
59 const std::string& key,
60 std::string* full_url,
61 PP_PNaClOptions* pnacl_options) const;
62 bool GetURLFromISADictionary(const Json::Value& dictionary,
63 const std::string& parent_key,
64 std::string* url,
65 PP_PNaClOptions* pnacl_options,
66 bool* uses_nonsfi_mode,
67 ErrorInfo* error_info) const;
69 std::string manifest_base_url_;
70 std::string sandbox_isa_;
71 bool nonsfi_enabled_;
72 bool pnacl_debug_;
74 // The dictionary of manifest information parsed in Init().
75 Json::Value dictionary_;
78 } // namespace nacl
80 #endif // COMPONENTS_NACL_RENDERER_JSON_MANIFEST_H