Chromium Code Reviews| Index: chrome/renderer/chrome_content_renderer_client.cc |
| =================================================================== |
| --- chrome/renderer/chrome_content_renderer_client.cc (revision 121325) |
| +++ chrome/renderer/chrome_content_renderer_client.cc (working copy) |
| @@ -405,7 +405,8 @@ |
| is_nacl_enabled = true; |
| } |
| if (is_nacl_plugin || is_nacl_mime_type) { |
| - if (!IsNaClAllowed(plugin, |
| + if (!IsNaClAllowed(frame, |
| + plugin, |
| url, |
| actual_mime_type, |
| is_nacl_mime_type, |
| @@ -485,6 +486,7 @@ |
| } |
| bool ChromeContentRendererClient::IsNaClAllowed( |
|
Mihai Parparita -not on Chrome
2012/02/10 23:03:33
This is complex enough that a unit tests would be
|
| + WebFrame* frame, |
| const webkit::WebPluginInfo& plugin, |
| const GURL& url, |
| const std::string& actual_mime_type, |
| @@ -515,32 +517,42 @@ |
| } |
| } |
| - // Determine if the manifest URL is part of an extension. |
| + // Determine if the manifest is part of an extension. |
| const Extension* extension = |
| extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
| ExtensionURLInfo(manifest_url)); |
| - // Only component, unpacked, and Chrome Web Store extensions are allowed. |
| + // Only allow component, unpacked, and Chrome Web Store extensions. |
| bool allowed_extension = extension && |
| (extension->from_webstore() || |
| extension->location() == Extension::COMPONENT || |
| extension->location() == Extension::LOAD); |
| - // Block any other use of NaCl plugin, unless --enable-nacl is set. |
| - if (!allowed_extension && !enable_nacl) |
| + // Check if this NaCl app's top level URL is whitelisted. |
| + bool whitelisted_url = false; |
| + GURL top_url = frame->top()->document().url(); |
| + if (top_url.SchemeIs("http") || top_url.SchemeIs("https")) { |
|
Mihai Parparita -not on Chrome
2012/02/10 23:03:33
Nit: why not merge this into the whilelisted_url b
|
| + whitelisted_url = ((top_url.host() == "plus.google.com" || |
| + top_url.host() == "plus.sandbox.google.com") && |
| + top_url.path().find("/games") == 0); |
| + } |
| + |
| + if (!allowed_extension && !whitelisted_url && !enable_nacl) |
| return false; |
| - // Allow dev interfaces for non-extension apps. |
| + // Block dev interfaces for production apps. These are packaged apps from |
| + // the Chrome Web Store and apps inside whitelisted URLs. |
| bool allow_dev_interfaces = true; |
| if (allowed_extension) { |
| - // Allow dev interfaces for component and unpacked extensions. |
| if (extension->location() != Extension::COMPONENT && |
| extension->location() != Extension::LOAD) { |
| - // Whitelist all other allowed extensions. |
| + // Don't block whitelisted apps. |
| allow_dev_interfaces = |
| // PDF Viewer plugin |
| - (manifest_url.scheme() == "chrome-extension" && |
| + (manifest_url.SchemeIs("chrome-extension") && |
| manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh"); |
| } |
| + } else if (whitelisted_url) { |
| + allow_dev_interfaces = false; |
| } |
| WebString dev_attribute = WebString::fromUTF8("@dev"); |