OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" | 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" |
6 | 6 |
7 #include "native_client/src/include/portability_io.h" | 7 #include "native_client/src/include/portability_io.h" |
8 #include "native_client/src/shared/platform/nacl_check.h" | 8 #include "native_client/src/shared/platform/nacl_check.h" |
9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
11 #include "ppapi/native_client/src/trusted/plugin/file_utils.h" | 11 #include "ppapi/native_client/src/trusted/plugin/file_utils.h" |
12 #include "ppapi/native_client/src/trusted/plugin/manifest.h" | 12 #include "ppapi/native_client/src/trusted/plugin/manifest.h" |
13 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 13 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
14 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" | 14 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" |
15 #include "ppapi/native_client/src/trusted/plugin/utility.h" | 15 #include "ppapi/native_client/src/trusted/plugin/utility.h" |
16 #include "third_party/jsoncpp/source/include/json/reader.h" | 16 #include "third_party/jsoncpp/source/include/json/reader.h" |
17 #include "third_party/jsoncpp/source/include/json/value.h" | 17 #include "third_party/jsoncpp/source/include/json/value.h" |
18 | 18 |
19 namespace plugin { | 19 namespace plugin { |
| 20 namespace { |
| 21 const PPB_NaCl_Private* GetNaClInterface() { |
| 22 pp::Module *module = pp::Module::Get(); |
| 23 CHECK(module); |
| 24 return static_cast<const PPB_NaCl_Private*>( |
| 25 module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE)); |
| 26 } |
| 27 } // namespace |
20 | 28 |
21 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/"; | 29 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/"; |
22 const char PnaclUrls::kResourceInfoUrl[] = "pnacl.json"; | 30 const char PnaclUrls::kResourceInfoUrl[] = "pnacl.json"; |
23 | 31 |
24 nacl::string PnaclUrls::GetBaseUrl() { | 32 nacl::string PnaclUrls::GetBaseUrl() { |
25 return nacl::string(kPnaclBaseUrl); | 33 return nacl::string(kPnaclBaseUrl); |
26 } | 34 } |
27 | 35 |
28 nacl::string PnaclUrls::PrependPlatformPrefix(const nacl::string& url) { | 36 nacl::string PnaclUrls::PrependPlatformPrefix(const nacl::string& url) { |
29 return nacl::string(GetSandboxISA()) + "/" + url; | 37 return nacl::string(GetNaClInterface()->GetSandboxISA()) + "/" + url; |
30 } | 38 } |
31 | 39 |
32 // Determine if a URL is for a pnacl-component file, or if it is some other | 40 // Determine if a URL is for a pnacl-component file, or if it is some other |
33 // type of URL (e.g., http://, https://, chrome-extension://). | 41 // type of URL (e.g., http://, https://, chrome-extension://). |
34 // The URL could be one of the other variants for shared libraries | 42 // The URL could be one of the other variants for shared libraries |
35 // served from the web. | 43 // served from the web. |
36 bool PnaclUrls::IsPnaclComponent(const nacl::string& full_url) { | 44 bool PnaclUrls::IsPnaclComponent(const nacl::string& full_url) { |
37 return full_url.find(kPnaclBaseUrl, 0) == 0; | 45 return full_url.find(kPnaclBaseUrl, 0) == 0; |
38 } | 46 } |
39 | 47 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 resource_wrappers_[resource_urls[i]] = | 247 resource_wrappers_[resource_urls[i]] = |
240 plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY); | 248 plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY); |
241 } | 249 } |
242 } | 250 } |
243 // We're done! Queue the callback. | 251 // We're done! Queue the callback. |
244 pp::Core* core = pp::Module::Get()->core(); | 252 pp::Core* core = pp::Module::Get()->core(); |
245 core->CallOnMainThread(0, all_loaded_callback, result); | 253 core->CallOnMainThread(0, all_loaded_callback, result); |
246 } | 254 } |
247 | 255 |
248 } // namespace plugin | 256 } // namespace plugin |
OLD | NEW |