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 #ifdef _MSC_VER | 5 #ifdef _MSC_VER |
6 // Do not warn about use of std::copy with raw pointers. | 6 // Do not warn about use of std::copy with raw pointers. |
7 #pragma warning(disable : 4996) | 7 #pragma warning(disable : 4996) |
8 #endif | 8 #endif |
9 | 9 |
10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "ppapi/c/ppp_instance.h" | 35 #include "ppapi/c/ppp_instance.h" |
36 #include "ppapi/c/private/ppb_nacl_private.h" | 36 #include "ppapi/c/private/ppb_nacl_private.h" |
37 #include "ppapi/cpp/dev/url_util_dev.h" | 37 #include "ppapi/cpp/dev/url_util_dev.h" |
38 #include "ppapi/cpp/module.h" | 38 #include "ppapi/cpp/module.h" |
39 #include "ppapi/cpp/text_input_controller.h" | 39 #include "ppapi/cpp/text_input_controller.h" |
40 | 40 |
41 #include "ppapi/native_client/src/trusted/plugin/file_utils.h" | 41 #include "ppapi/native_client/src/trusted/plugin/file_utils.h" |
42 #include "ppapi/native_client/src/trusted/plugin/json_manifest.h" | 42 #include "ppapi/native_client/src/trusted/plugin/json_manifest.h" |
43 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" | 43 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" |
44 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" | 44 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" |
45 #include "ppapi/native_client/src/trusted/plugin/nexe_arch.h" | |
46 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" | 45 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" |
47 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 46 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" |
48 #include "ppapi/native_client/src/trusted/plugin/utility.h" | 47 #include "ppapi/native_client/src/trusted/plugin/utility.h" |
49 | 48 |
50 namespace plugin { | 49 namespace plugin { |
51 | 50 |
52 namespace { | 51 namespace { |
53 | 52 |
54 const char* const kTypeAttribute = "type"; | 53 const char* const kTypeAttribute = "type"; |
55 // The "src" attribute of the <embed> tag. The value is expected to be either | 54 // The "src" attribute of the <embed> tag. The value is expected to be either |
56 // a URL or URI pointing to the manifest file (which is expected to contain | 55 // a URL or URI pointing to the manifest file (which is expected to contain |
57 // JSON matching ISAs with .nexe URLs). | 56 // JSON matching ISAs with .nexe URLs). |
58 const char* const kSrcManifestAttribute = "src"; | 57 const char* const kSrcManifestAttribute = "src"; |
59 // The "nacl" attribute of the <embed> tag. We use the value of this attribute | 58 // The "nacl" attribute of the <embed> tag. We use the value of this attribute |
60 // to find the manifest file when NaCl is registered as a plug-in for another | 59 // to find the manifest file when NaCl is registered as a plug-in for another |
61 // MIME type because the "src" attribute is used to supply us with the resource | 60 // MIME type because the "src" attribute is used to supply us with the resource |
62 // of that MIME type that we're supposed to display. | 61 // of that MIME type that we're supposed to display. |
63 const char* const kNaClManifestAttribute = "nacl"; | 62 const char* const kNaClManifestAttribute = "nacl"; |
64 // The pseudo-ISA used to indicate portable native client. | 63 // The pseudo-architecture used to indicate portable native client. |
65 const char* const kPortableISA = "portable"; | 64 const char* const kPortableArch = "portable"; |
66 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. | 65 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. |
67 // Note that the resulting string object has to have at least one byte extra | 66 // Note that the resulting string object has to have at least one byte extra |
68 // for the null termination character. | 67 // for the null termination character. |
69 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; | 68 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; |
70 | 69 |
71 // Define an argument name to enable 'dev' interfaces. To make sure it doesn't | 70 // Define an argument name to enable 'dev' interfaces. To make sure it doesn't |
72 // collide with any user-defined HTML attribute, make the first character '@'. | 71 // collide with any user-defined HTML attribute, make the first character '@'. |
73 const char* const kDevAttribute = "@dev"; | 72 const char* const kDevAttribute = "@dev"; |
74 | 73 |
75 // URL schemes that we treat in special ways. | 74 // URL schemes that we treat in special ways. |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin))); | 522 PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin))); |
524 return plugin; | 523 return plugin; |
525 } | 524 } |
526 | 525 |
527 | 526 |
528 // All failures of this function will show up as "Missing Plugin-in", so | 527 // All failures of this function will show up as "Missing Plugin-in", so |
529 // there is no need to log to JS console that there was an initialization | 528 // there is no need to log to JS console that there was an initialization |
530 // failure. Note that module loading functions will log their own errors. | 529 // failure. Note that module loading functions will log their own errors. |
531 bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { | 530 bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { |
532 PLUGIN_PRINTF(("Plugin::Init (argc=%" NACL_PRIu32 ")\n", argc)); | 531 PLUGIN_PRINTF(("Plugin::Init (argc=%" NACL_PRIu32 ")\n", argc)); |
533 HistogramEnumerateOsArch(GetSandboxISA()); | 532 HistogramEnumerateOsArch(nacl_interface_->GetSandboxArch()); |
534 init_time_ = NaClGetTimeOfDayMicroseconds(); | 533 init_time_ = NaClGetTimeOfDayMicroseconds(); |
535 url_util_ = pp::URLUtil_Dev::Get(); | 534 url_util_ = pp::URLUtil_Dev::Get(); |
536 if (url_util_ == NULL) | 535 if (url_util_ == NULL) |
537 return false; | 536 return false; |
538 | 537 |
539 PLUGIN_PRINTF(("Plugin::Init (url_util_=%p)\n", | 538 PLUGIN_PRINTF(("Plugin::Init (url_util_=%p)\n", |
540 static_cast<const void*>(url_util_))); | 539 static_cast<const void*>(url_util_))); |
541 | 540 |
542 bool status = EarlyInit(static_cast<int>(argc), argn, argv); | 541 bool status = EarlyInit(static_cast<int>(argc), argn, argv); |
543 if (status) { | 542 if (status) { |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", | 1146 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", |
1148 manifest_json.c_str())); | 1147 manifest_json.c_str())); |
1149 if (error_info == NULL) | 1148 if (error_info == NULL) |
1150 return false; | 1149 return false; |
1151 // Determine whether lookups should use portable (i.e., pnacl versions) | 1150 // Determine whether lookups should use portable (i.e., pnacl versions) |
1152 // rather than platform-specific files. | 1151 // rather than platform-specific files. |
1153 bool is_pnacl = (mime_type() == kPnaclMIMEType); | 1152 bool is_pnacl = (mime_type() == kPnaclMIMEType); |
1154 bool nonsfi_mode_enabled = | 1153 bool nonsfi_mode_enabled = |
1155 PP_ToBool(nacl_interface_->IsNonSFIModeEnabled()); | 1154 PP_ToBool(nacl_interface_->IsNonSFIModeEnabled()); |
1156 bool pnacl_debug = GetNaClInterface()->NaClDebugStubEnabled(); | 1155 bool pnacl_debug = GetNaClInterface()->NaClDebugStubEnabled(); |
| 1156 const char* sandbox_isa = nacl_interface_->GetSandboxArch(); |
1157 nacl::scoped_ptr<JsonManifest> json_manifest( | 1157 nacl::scoped_ptr<JsonManifest> json_manifest( |
1158 new JsonManifest(url_util_, | 1158 new JsonManifest(url_util_, |
1159 manifest_base_url(), | 1159 manifest_base_url(), |
1160 (is_pnacl ? kPortableISA : GetSandboxISA()), | 1160 (is_pnacl ? kPortableArch : sandbox_isa), |
1161 nonsfi_mode_enabled, | 1161 nonsfi_mode_enabled, |
1162 pnacl_debug)); | 1162 pnacl_debug)); |
1163 if (!json_manifest->Init(manifest_json, error_info)) { | 1163 if (!json_manifest->Init(manifest_json, error_info)) { |
1164 return false; | 1164 return false; |
1165 } | 1165 } |
1166 manifest_.reset(json_manifest.release()); | 1166 manifest_.reset(json_manifest.release()); |
1167 return true; | 1167 return true; |
1168 } | 1168 } |
1169 | 1169 |
1170 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, | 1170 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 DCHECK(pp::Module::Get()->core()->IsMainThread()); | 1496 DCHECK(pp::Module::Get()->core()->IsMainThread()); |
1497 DCHECK(nacl_interface_); | 1497 DCHECK(nacl_interface_); |
1498 exit_status_ = exit_status; | 1498 exit_status_ = exit_status; |
1499 nacl_interface_->SetReadOnlyProperty(pp_instance(), | 1499 nacl_interface_->SetReadOnlyProperty(pp_instance(), |
1500 pp::Var("exitStatus").pp_var(), | 1500 pp::Var("exitStatus").pp_var(), |
1501 pp::Var(exit_status_).pp_var()); | 1501 pp::Var(exit_status_).pp_var()); |
1502 } | 1502 } |
1503 | 1503 |
1504 | 1504 |
1505 } // namespace plugin | 1505 } // namespace plugin |
OLD | NEW |