| Index: chrome/renderer/render_view.cc
|
| ===================================================================
|
| --- chrome/renderer/render_view.cc (revision 30634)
|
| +++ chrome/renderer/render_view.cc (working copy)
|
| @@ -2422,6 +2422,31 @@
|
| origin.toString().utf8()));
|
| }
|
|
|
| +bool RenderView::allowScript(WebFrame* frame, bool enabled_per_settings) {
|
| + if (enabled_per_settings)
|
| + return true;
|
| +
|
| + WebSecurityOrigin origin = frame->securityOrigin();
|
| + if (origin.isEmpty())
|
| + return false; // Uninitialized document?
|
| +
|
| + if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme))
|
| + return true; // Browser UI elements should still work.
|
| +
|
| + // If the scheme is ftp: or file:, an empty file name indicates a directory
|
| + // listing, which requires JavaScript to function properly.
|
| + GURL frame_url = frame->url();
|
| + const char* kDirProtocols[] = { "ftp", "file" };
|
| + for (size_t i = 0; i < arraysize(kDirProtocols); ++i) {
|
| + if (EqualsASCII(origin.protocol(), kDirProtocols[i])) {
|
| + return frame_url.SchemeIs(kDirProtocols[i]) &&
|
| + frame_url.ExtractFileName().empty();
|
| + }
|
| + }
|
| +
|
| + return false; // Other protocols fall through here.
|
| +}
|
| +
|
| void RenderView::didExhaustMemoryAvailableForScript(WebFrame* frame) {
|
| Send(new ViewHostMsg_JSOutOfMemory(routing_id_));
|
| }
|
|
|