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 "native_client/src/trusted/plugin/plugin.h" | 10 #include "native_client/src/trusted/plugin/plugin.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const char* const kTypeAttribute = "type"; | 69 const char* const kTypeAttribute = "type"; |
70 // The "src" attribute of the <embed> tag. The value is expected to be either | 70 // The "src" attribute of the <embed> tag. The value is expected to be either |
71 // a URL or URI pointing to the manifest file (which is expected to contain | 71 // a URL or URI pointing to the manifest file (which is expected to contain |
72 // JSON matching ISAs with .nexe URLs). | 72 // JSON matching ISAs with .nexe URLs). |
73 const char* const kSrcManifestAttribute = "src"; | 73 const char* const kSrcManifestAttribute = "src"; |
74 // The "nacl" attribute of the <embed> tag. We use the value of this attribute | 74 // The "nacl" attribute of the <embed> tag. We use the value of this attribute |
75 // to find the manifest file when NaCl is registered as a plug-in for another | 75 // to find the manifest file when NaCl is registered as a plug-in for another |
76 // MIME type because the "src" attribute is used to supply us with the resource | 76 // MIME type because the "src" attribute is used to supply us with the resource |
77 // of that MIME type that we're supposed to display. | 77 // of that MIME type that we're supposed to display. |
78 const char* const kNaClManifestAttribute = "nacl"; | 78 const char* const kNaClManifestAttribute = "nacl"; |
| 79 // The pseudo-ISA used to indicate portable native client. |
| 80 const char* const kPortableISA = "portable"; |
79 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. | 81 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. |
80 // Note that the resulting string object has to have at least one byte extra | 82 // Note that the resulting string object has to have at least one byte extra |
81 // for the null termination character. | 83 // for the null termination character. |
82 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; | 84 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; |
83 | 85 |
84 // Define an argument name to enable 'dev' interfaces. To make sure it doesn't | 86 // Define an argument name to enable 'dev' interfaces. To make sure it doesn't |
85 // collide with any user-defined HTML attribute, make the first character '@'. | 87 // collide with any user-defined HTML attribute, make the first character '@'. |
86 const char* const kDevAttribute = "@dev"; | 88 const char* const kDevAttribute = "@dev"; |
87 | 89 |
88 // URL schemes that we treat in special ways. | 90 // URL schemes that we treat in special ways. |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 // not taken. Hence it does not need to be deleted when ProgressEvent is | 570 // not taken. Hence it does not need to be deleted when ProgressEvent is |
569 // destroyed. | 571 // destroyed. |
570 const char* event_type_; | 572 const char* event_type_; |
571 nacl::string url_; | 573 nacl::string url_; |
572 Plugin::LengthComputable length_computable_; | 574 Plugin::LengthComputable length_computable_; |
573 uint64_t loaded_bytes_; | 575 uint64_t loaded_bytes_; |
574 uint64_t total_bytes_; | 576 uint64_t total_bytes_; |
575 }; | 577 }; |
576 | 578 |
577 const char* const Plugin::kNaClMIMEType = "application/x-nacl"; | 579 const char* const Plugin::kNaClMIMEType = "application/x-nacl"; |
| 580 const char* const Plugin::kPnaclMIMEType = "application/x-pnacl"; |
578 | 581 |
579 bool Plugin::NexeIsContentHandler() const { | 582 bool Plugin::NexeIsContentHandler() const { |
580 // Tests if the MIME type is not a NaCl MIME type. | 583 // Tests if the MIME type is not a NaCl MIME type. |
581 // If the MIME type is foreign, then this NEXE is being used as a content | 584 // If the MIME type is foreign, then this NEXE is being used as a content |
582 // type handler rather than directly by an HTML document. | 585 // type handler rather than directly by an HTML document. |
583 return | 586 return |
584 !mime_type().empty() && | 587 !mime_type().empty() && |
585 mime_type() != kNaClMIMEType; | 588 mime_type() != kNaClMIMEType && |
| 589 mime_type() != kPnaclMIMEType; |
586 } | 590 } |
587 | 591 |
588 | 592 |
589 Plugin* Plugin::New(PP_Instance pp_instance) { | 593 Plugin* Plugin::New(PP_Instance pp_instance) { |
590 PLUGIN_PRINTF(("Plugin::New (pp_instance=%"NACL_PRId32")\n", pp_instance)); | 594 PLUGIN_PRINTF(("Plugin::New (pp_instance=%"NACL_PRId32")\n", pp_instance)); |
591 Plugin* plugin = new Plugin(pp_instance); | 595 Plugin* plugin = new Plugin(pp_instance); |
592 PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin))); | 596 PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin))); |
593 if (plugin == NULL) { | 597 if (plugin == NULL) { |
594 return NULL; | 598 return NULL; |
595 } | 599 } |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 | 1249 |
1246 | 1250 |
1247 bool Plugin::SetManifestObject(const nacl::string& manifest_json, | 1251 bool Plugin::SetManifestObject(const nacl::string& manifest_json, |
1248 ErrorInfo* error_info) { | 1252 ErrorInfo* error_info) { |
1249 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", | 1253 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", |
1250 manifest_json.c_str())); | 1254 manifest_json.c_str())); |
1251 if (error_info == NULL) | 1255 if (error_info == NULL) |
1252 return false; | 1256 return false; |
1253 // Determine whether lookups should use portable (i.e., pnacl versions) | 1257 // Determine whether lookups should use portable (i.e., pnacl versions) |
1254 // rather than platform-specific files. | 1258 // rather than platform-specific files. |
1255 bool should_prefer_portable = | 1259 bool is_pnacl = (mime_type() == kPnaclMIMEType); |
1256 (getenv("NACL_PREFER_PORTABLE_IN_MANIFEST") != NULL); | |
1257 nacl::scoped_ptr<JsonManifest> json_manifest( | 1260 nacl::scoped_ptr<JsonManifest> json_manifest( |
1258 new JsonManifest(url_util_, | 1261 new JsonManifest(url_util_, |
1259 manifest_base_url(), | 1262 manifest_base_url(), |
1260 GetSandboxISA(), | 1263 (is_pnacl ? kPortableISA : GetSandboxISA()))); |
1261 should_prefer_portable)); | |
1262 if (!json_manifest->Init(manifest_json, error_info)) { | 1264 if (!json_manifest->Init(manifest_json, error_info)) { |
1263 return false; | 1265 return false; |
1264 } | 1266 } |
1265 manifest_.reset(json_manifest.release()); | 1267 manifest_.reset(json_manifest.release()); |
1266 return true; | 1268 return true; |
1267 } | 1269 } |
1268 | 1270 |
1269 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, | 1271 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, |
1270 FileDownloader*& url_downloader, | 1272 FileDownloader*& url_downloader, |
1271 PP_CompletionCallback callback) { | 1273 PP_CompletionCallback callback) { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 static_cast<uint32_t>(text.size())); | 1639 static_cast<uint32_t>(text.size())); |
1638 const PPB_Console* console_interface = | 1640 const PPB_Console* console_interface = |
1639 static_cast<const PPB_Console*>( | 1641 static_cast<const PPB_Console*>( |
1640 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | 1642 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); |
1641 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1643 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
1642 var_interface->Release(prefix); | 1644 var_interface->Release(prefix); |
1643 var_interface->Release(str); | 1645 var_interface->Release(str); |
1644 } | 1646 } |
1645 | 1647 |
1646 } // namespace plugin | 1648 } // namespace plugin |
OLD | NEW |