Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: ppapi/native_client/src/trusted/plugin/plugin.cc

Issue 8301006: Packaged (CRX) extensions shouldn't be able to get 'dev' interfaces in NaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // The "nacl" attribute of the <embed> tag. We use the value of this attribute 96 // The "nacl" attribute of the <embed> tag. We use the value of this attribute
97 // to find the manifest file when NaCl is registered as a plug-in for another 97 // to find the manifest file when NaCl is registered as a plug-in for another
98 // MIME type because the "src" attribute is used to supply us with the resource 98 // MIME type because the "src" attribute is used to supply us with the resource
99 // of that MIME type that we're supposed to display. 99 // of that MIME type that we're supposed to display.
100 const char* const kNaClManifestAttribute = "nacl"; 100 const char* const kNaClManifestAttribute = "nacl";
101 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. 101 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file.
102 // Note that the resulting string object has to have at least one byte extra 102 // Note that the resulting string object has to have at least one byte extra
103 // for the null termination character. 103 // for the null termination character.
104 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; 104 const size_t kNaClManifestMaxFileBytes = 1024 * 1024;
105 105
106 // Define an argument name to enable 'dev' interfaces. To make sure it doesn't
107 // collide with any user-defined HTML attribute, make the first character '@'.
108 const char* const kDevAttribute = "@dev";
109
106 // URL schemes that we treat in special ways. 110 // URL schemes that we treat in special ways.
107 const char* const kChromeExtensionUriScheme = "chrome-extension"; 111 const char* const kChromeExtensionUriScheme = "chrome-extension";
108 const char* const kDataUriScheme = "data"; 112 const char* const kDataUriScheme = "data";
109 113
110 // The key used to find the dictionary nexe URLs in the manifest file. 114 // The key used to find the dictionary nexe URLs in the manifest file.
111 const char* const kNexesKey = "nexes"; 115 const char* const kNexesKey = "nexes";
112 116
113 bool GetLastError(void* obj, SrpcParams* params) { 117 bool GetLastError(void* obj, SrpcParams* params) {
114 NaClSrpcArg** outs = params->outs(); 118 NaClSrpcArg** outs = params->outs();
115 PLUGIN_PRINTF(("GetLastError (obj=%p)\n", obj)); 119 PLUGIN_PRINTF(("GetLastError (obj=%p)\n", obj));
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 static_cast<const void*>(url_util_))); 889 static_cast<const void*>(url_util_)));
886 890
887 bool status = Plugin::Init( 891 bool status = Plugin::Init(
888 browser_interface, 892 browser_interface,
889 static_cast<int>(argc), 893 static_cast<int>(argc),
890 // TODO(polina): Can we change the args on our end to be const to 894 // TODO(polina): Can we change the args on our end to be const to
891 // avoid these ugly casts? 895 // avoid these ugly casts?
892 const_cast<char**>(argn), 896 const_cast<char**>(argn),
893 const_cast<char**>(argv)); 897 const_cast<char**>(argv));
894 if (status) { 898 if (status) {
899 // Look for the developer attribute; if it's present, enable 'dev'
900 // interfaces.
901 const char* dev_settings = LookupArgument(kDevAttribute);
902 enable_dev_interfaces_ = (dev_settings != NULL);
903
895 const char* type_attr = LookupArgument(kTypeAttribute); 904 const char* type_attr = LookupArgument(kTypeAttribute);
896 if (type_attr != NULL) { 905 if (type_attr != NULL) {
897 mime_type_ = nacl::string(type_attr); 906 mime_type_ = nacl::string(type_attr);
898 std::transform(mime_type_.begin(), mime_type_.end(), mime_type_.begin(), 907 std::transform(mime_type_.begin(), mime_type_.end(), mime_type_.begin(),
899 tolower); 908 tolower);
900 } 909 }
901 910
902 const char* manifest_url = LookupArgument(kSrcManifestAttribute); 911 const char* manifest_url = LookupArgument(kSrcManifestAttribute);
903 // If the MIME type is foreign, then 'src' will be the URL for the content 912 // If the MIME type is foreign, then 'src' will be the URL for the content
904 // and 'nacl' will be the URL for the manifest. 913 // and 'nacl' will be the URL for the manifest.
905 if (IsForeignMIMEType()) { 914 if (IsForeignMIMEType()) {
906 manifest_url = LookupArgument(kNaClManifestAttribute); 915 manifest_url = LookupArgument(kNaClManifestAttribute);
907 enable_dev_interfaces_ = RequiresDevInterfaces(manifest_url);
908 } 916 }
909 // Use the document URL as the base for resolving relative URLs to find the 917 // Use the document URL as the base for resolving relative URLs to find the
910 // manifest. This takes into account the setting of <base> tags that 918 // manifest. This takes into account the setting of <base> tags that
911 // precede the embed/object. 919 // precede the embed/object.
912 CHECK(url_util_ != NULL); 920 CHECK(url_util_ != NULL);
913 pp::Var base_var = url_util_->GetDocumentURL(*this); 921 pp::Var base_var = url_util_->GetDocumentURL(*this);
914 if (!base_var.is_string()) { 922 if (!base_var.is_string()) {
915 PLUGIN_PRINTF(("Plugin::Init (unable to find document url)\n")); 923 PLUGIN_PRINTF(("Plugin::Init (unable to find document url)\n"));
916 return false; 924 return false;
917 } 925 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 UNREFERENCED_PARAMETER(pp_error); 1301 UNREFERENCED_PARAMETER(pp_error);
1294 if (was_successful) { 1302 if (was_successful) {
1295 ReportLoadSuccess(LENGTH_IS_NOT_COMPUTABLE, 1303 ReportLoadSuccess(LENGTH_IS_NOT_COMPUTABLE,
1296 kUnknownBytes, 1304 kUnknownBytes,
1297 kUnknownBytes); 1305 kUnknownBytes);
1298 } else { 1306 } else {
1299 ReportLoadError(error_info); 1307 ReportLoadError(error_info);
1300 } 1308 }
1301 } 1309 }
1302 1310
1303 // Check manifest_url and return whether or not to enable PPAPI Dev interfaces.
1304 // Returning true here will enable the PPAPI Dev interfaces regardless of
1305 // the environment variable NACL_ENABLE_PPAPI_DEV.
1306 bool Plugin::RequiresDevInterfaces(const nacl::string& manifest_url) {
1307 const char* extensions[] = {
1308 "chrome-extension://acadkphlmlegjaadjagenfimbpphcgnh/", // PDF
1309 };
1310 for (size_t i = 0; i < sizeof(extensions) / sizeof(const char*); ++i) {
1311 if (manifest_url.find(extensions[i]) == 0) {
1312 return true;
1313 }
1314 }
1315 return false;
1316 }
1317
1318 bool Plugin::StartProxiedExecution(NaClSrpcChannel* srpc_channel, 1311 bool Plugin::StartProxiedExecution(NaClSrpcChannel* srpc_channel,
1319 ErrorInfo* error_info) { 1312 ErrorInfo* error_info) {
1320 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (srpc_channel=%p)\n", 1313 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (srpc_channel=%p)\n",
1321 static_cast<void*>(srpc_channel))); 1314 static_cast<void*>(srpc_channel)));
1322 1315
1323 // Log the amound of time that has passed between the trusted plugin being 1316 // Log the amound of time that has passed between the trusted plugin being
1324 // initialized and the untrusted plugin being initialized. This is (roughly) 1317 // initialized and the untrusted plugin being initialized. This is (roughly)
1325 // the cost of using NaCl, in terms of startup time. 1318 // the cost of using NaCl, in terms of startup time.
1326 HistogramStartupTimeMedium( 1319 HistogramStartupTimeMedium(
1327 "NaCl.Perf.StartupTime.NaClOverhead", 1320 "NaCl.Perf.StartupTime.NaClOverhead",
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, 2001 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin,
2009 comps.scheme.len); 2002 comps.scheme.len);
2010 if (scheme == kChromeExtensionUriScheme) 2003 if (scheme == kChromeExtensionUriScheme)
2011 return SCHEME_CHROME_EXTENSION; 2004 return SCHEME_CHROME_EXTENSION;
2012 if (scheme == kDataUriScheme) 2005 if (scheme == kDataUriScheme)
2013 return SCHEME_DATA; 2006 return SCHEME_DATA;
2014 return SCHEME_OTHER; 2007 return SCHEME_OTHER;
2015 } 2008 }
2016 2009
2017 } // namespace plugin 2010 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/plugin.h ('k') | ppapi/native_client/tests/ppapi_browser/ppb_dev/ppapi_ppb_dev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698