OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "native_client/src/trusted/plugin/ppapi/plugin_ppapi.h" | 7 #include "native_client/src/trusted/plugin/ppapi/plugin_ppapi.h" |
8 | 8 |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "ppapi/c/pp_errors.h" | 29 #include "ppapi/c/pp_errors.h" |
30 #include "ppapi/c/ppp_instance.h" | 30 #include "ppapi/c/ppp_instance.h" |
31 #include "ppapi/cpp/module.h" | 31 #include "ppapi/cpp/module.h" |
32 #include "ppapi/cpp/rect.h" | 32 #include "ppapi/cpp/rect.h" |
33 | 33 |
34 namespace plugin { | 34 namespace plugin { |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 const char* const kSrcAttribute = "src"; // The "src" attr of the <embed> tag. | 38 const char* const kSrcAttribute = "src"; // The "src" attr of the <embed> tag. |
39 const char* const kTypeAttribute = "type"; | |
39 // The "nacl" attribute of the <embed> tag. The value is expected to be either | 40 // The "nacl" attribute of the <embed> tag. The value is expected to be either |
40 // a URL or URI pointing to the manifest file (which is expeceted to contain | 41 // a URL or URI pointing to the manifest file (which is expeceted to contain |
41 // JSON matching ISAs with .nexe URLs). | 42 // JSON matching ISAs with .nexe URLs). |
42 const char* const kNaclManifestAttribute = "nacl"; | 43 const char* const kNaclManifestAttribute = "nacl"; |
43 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. | 44 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. |
44 // Note that the resulting string object has to have at least one byte extra | 45 // Note that the resulting string object has to have at least one byte extra |
45 // for the null termination character. | 46 // for the null termination character. |
46 const ssize_t kNaclManifestMaxFileBytesPlusNull = 1024; | 47 const ssize_t kNaclManifestMaxFileBytesPlusNull = 1024; |
47 const ssize_t kNaclManifestMaxFileBytesNoNull = | 48 const ssize_t kNaclManifestMaxFileBytesNoNull = |
48 kNaclManifestMaxFileBytesPlusNull - 1; | 49 kNaclManifestMaxFileBytesPlusNull - 1; |
(...skipping 11 matching lines...) Expand all Loading... | |
60 PluginPpapi* plugin = | 61 PluginPpapi* plugin = |
61 static_cast<PluginPpapi*>(reinterpret_cast<Plugin*>(obj)); | 62 static_cast<PluginPpapi*>(reinterpret_cast<Plugin*>(obj)); |
62 const char* url = ins[0]->arrays.str; | 63 const char* url = ins[0]->arrays.str; |
63 // TODO(sehr,polina): Ensure that origin checks are performed here. | 64 // TODO(sehr,polina): Ensure that origin checks are performed here. |
64 return plugin->UrlAsNaClDesc( | 65 return plugin->UrlAsNaClDesc( |
65 url, *reinterpret_cast<pp::Var*>(ins[1]->arrays.oval)); | 66 url, *reinterpret_cast<pp::Var*>(ins[1]->arrays.oval)); |
66 } | 67 } |
67 | 68 |
68 } // namespace | 69 } // namespace |
69 | 70 |
71 const char* const kNaClMIMEType = "application/x-nacl"; | |
polina
2011/04/15 06:24:57
please put this at the top with other constants
abarth-chromium
2011/04/15 06:36:40
The constants above have internal linkage, prevent
polina
2011/04/15 22:52:10
Might be better to make it a static member of the
| |
72 | |
70 bool PluginPpapi::SetAsyncCallback(void* obj, SrpcParams* params) { | 73 bool PluginPpapi::SetAsyncCallback(void* obj, SrpcParams* params) { |
71 PluginPpapi* plugin = | 74 PluginPpapi* plugin = |
72 static_cast<PluginPpapi*>(reinterpret_cast<Plugin*>(obj)); | 75 static_cast<PluginPpapi*>(reinterpret_cast<Plugin*>(obj)); |
73 if (plugin->service_runtime_ == NULL) { | 76 if (plugin->service_runtime_ == NULL) { |
74 params->set_exception_string("No subprocess running"); | 77 params->set_exception_string("No subprocess running"); |
75 return false; | 78 return false; |
76 } | 79 } |
77 if (plugin->receive_thread_running_) { | 80 if (plugin->receive_thread_running_) { |
78 params->set_exception_string("A callback has already been registered"); | 81 params->set_exception_string("A callback has already been registered"); |
79 return false; | 82 return false; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 static_cast<void*>(scriptable_handle()))); | 139 static_cast<void*>(scriptable_handle()))); |
137 bool status = Plugin::Init( | 140 bool status = Plugin::Init( |
138 browser_interface, | 141 browser_interface, |
139 PPInstanceToInstanceIdentifier(static_cast<pp::Instance*>(this)), | 142 PPInstanceToInstanceIdentifier(static_cast<pp::Instance*>(this)), |
140 static_cast<int>(argc), | 143 static_cast<int>(argc), |
141 // TODO(polina): Can we change the args on our end to be const to | 144 // TODO(polina): Can we change the args on our end to be const to |
142 // avoid these ugly casts? This will also require changes to npapi code. | 145 // avoid these ugly casts? This will also require changes to npapi code. |
143 const_cast<char**>(argn), | 146 const_cast<char**>(argn), |
144 const_cast<char**>(argv)); | 147 const_cast<char**>(argv)); |
145 if (status) { | 148 if (status) { |
149 const char* type_attr = LookupArgument(kTypeAttribute); | |
150 if (type_attr != NULL) { | |
151 mime_type_ = std::string(type_attr); | |
152 std::transform(mime_type_.begin(), mime_type_.end(), mime_type_.begin(), | |
153 tolower); | |
154 } | |
146 // Note: The order of attribute lookup is important. This pattern looks | 155 // Note: The order of attribute lookup is important. This pattern looks |
147 // for a "nacl" attribute first, then a "src" attribute, and finally a | 156 // for a "nacl" attribute first, then a "src" attribute, and finally a |
148 // "nexes" attribute. | 157 // "nexes" attribute. |
149 const char* nacl_attr = LookupArgument(kNaclManifestAttribute); | 158 const char* nacl_attr = LookupArgument(kNaclManifestAttribute); |
150 PLUGIN_PRINTF(("PluginPpapi::Init (nacl_attr=%s)\n", nacl_attr)); | 159 PLUGIN_PRINTF(("PluginPpapi::Init (nacl_attr=%s)\n", nacl_attr)); |
151 if (nacl_attr != NULL) { | 160 if (nacl_attr != NULL) { |
152 // Issue a GET for the "nacl" attribute. The value of the attribute | 161 // Issue a GET for the "nacl" attribute. The value of the attribute |
153 // can be a data: URI, or a URL that must be fetched. In either case, | 162 // can be a data: URI, or a URL that must be fetched. In either case, |
154 // the GET is started here, and once a valid .nexe file has been | 163 // the GET is started here, and once a valid .nexe file has been |
155 // determined, SetSrcPropertyImpl() is called to shut down the current | 164 // determined, SetSrcPropertyImpl() is called to shut down the current |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 | 586 |
578 | 587 |
579 bool PluginPpapi::Failure(const nacl::string& error) { | 588 bool PluginPpapi::Failure(const nacl::string& error) { |
580 PLUGIN_PRINTF(("PluginPpapi::Failure (error='%s')\n", error.c_str())); | 589 PLUGIN_PRINTF(("PluginPpapi::Failure (error='%s')\n", error.c_str())); |
581 browser_interface()->AddToConsole(instance_id(), error); | 590 browser_interface()->AddToConsole(instance_id(), error); |
582 ShutdownProxy(); | 591 ShutdownProxy(); |
583 return false; | 592 return false; |
584 } | 593 } |
585 | 594 |
586 } // namespace plugin | 595 } // namespace plugin |
OLD | NEW |