| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 if (!document) | 1989 if (!document) |
| 1990 return false; | 1990 return false; |
| 1991 | 1991 |
| 1992 SecurityOrigin* origin = document->securityOrigin(); | 1992 SecurityOrigin* origin = document->securityOrigin(); |
| 1993 if (origin->protocol().isEmpty()) | 1993 if (origin->protocol().isEmpty()) |
| 1994 return false; // Uninitialized document | 1994 return false; // Uninitialized document |
| 1995 | 1995 |
| 1996 if (origin->protocol() == "http" || origin->protocol() == "https") | 1996 if (origin->protocol() == "http" || origin->protocol() == "https") |
| 1997 return false; // Web site | 1997 return false; // Web site |
| 1998 | 1998 |
| 1999 // TODO(darin): the following are application decisions, and they should |
| 2000 // not be made at this layer. instead, we should bridge out to the |
| 2001 // embedder to allow them to override policy here. |
| 2002 |
| 1999 if (origin->protocol() == ChromiumBridge::uiResourceProtocol()) | 2003 if (origin->protocol() == ChromiumBridge::uiResourceProtocol()) |
| 2000 return true; // Embedder's scripts are ok to run | 2004 return true; // Embedder's scripts are ok to run |
| 2001 | 2005 |
| 2002 // If the scheme is ftp: or file:, an empty file name indicates a directory | 2006 // If the scheme is ftp: or file:, an empty file name indicates a directory |
| 2003 // listing, which requires JavaScript to function properly. | 2007 // listing, which requires JavaScript to function properly. |
| 2004 const char* kDirProtocols[] = { "ftp", "file" }; | 2008 const char* kDirProtocols[] = { "ftp", "file" }; |
| 2005 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { | 2009 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { |
| 2006 if (origin->protocol() == kDirProtocols[i]) { | 2010 if (origin->protocol() == kDirProtocols[i]) { |
| 2007 const KURL& url = document->url(); | 2011 const KURL& url = document->url(); |
| 2008 return url.pathAfterLastSlash() == url.pathEnd(); | 2012 return url.pathAfterLastSlash() == url.pathEnd(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2201 | 2205 |
| 2202 const SecurityOrigin* active_security_origin = origin_window->securityOrigin
(); | 2206 const SecurityOrigin* active_security_origin = origin_window->securityOrigin
(); |
| 2203 const SecurityOrigin* target_security_origin = target_window->securityOrigin
(); | 2207 const SecurityOrigin* target_security_origin = target_window->securityOrigin
(); |
| 2204 | 2208 |
| 2205 // We have seen crashes were the security origin of the target has not been | 2209 // We have seen crashes were the security origin of the target has not been |
| 2206 // initialized. Defend against that. | 2210 // initialized. Defend against that. |
| 2207 ASSERT(target_security_origin); | 2211 ASSERT(target_security_origin); |
| 2208 if (!target_security_origin) | 2212 if (!target_security_origin) |
| 2209 return false; | 2213 return false; |
| 2210 | 2214 |
| 2211 String ui_resource_protocol = ChromiumBridge::uiResourceProtocol(); | |
| 2212 if (active_security_origin->protocol() == ui_resource_protocol) { | |
| 2213 KURL inspector_url = ChromiumBridge::inspectorURL(); | |
| 2214 ASSERT(inspector_url.protocol() == ui_resource_protocol); | |
| 2215 | |
| 2216 // The Inspector can access anything. | |
| 2217 if (active_security_origin->host() == inspector_url.host()) | |
| 2218 return true; | |
| 2219 | |
| 2220 // To mitigate XSS vulnerabilities on the browser itself, UI resources | |
| 2221 // besides the Inspector can't access other documents. | |
| 2222 return false; | |
| 2223 } | |
| 2224 | |
| 2225 if (active_security_origin->canAccess(target_security_origin)) | 2215 if (active_security_origin->canAccess(target_security_origin)) |
| 2226 return true; | 2216 return true; |
| 2227 | 2217 |
| 2228 // Allow access to a "about:blank" page if the dynamic context is a | 2218 // Allow access to a "about:blank" page if the dynamic context is a |
| 2229 // detached context of the same frame as the blank page. | 2219 // detached context of the same frame as the blank page. |
| 2230 if (target_security_origin->isEmpty() && | 2220 if (target_security_origin->isEmpty() && |
| 2231 origin_window->frame() == target_window->frame()) | 2221 origin_window->frame() == target_window->frame()) |
| 2232 return true; | 2222 return true; |
| 2233 | 2223 |
| 2234 return false; | 2224 return false; |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3520 } | 3510 } |
| 3521 return ToWebCoreString(v8::Debug::Call(frame_source_name)); | 3511 return ToWebCoreString(v8::Debug::Call(frame_source_name)); |
| 3522 } | 3512 } |
| 3523 | 3513 |
| 3524 void V8Proxy::RegisterExtension(v8::Extension* extension) { | 3514 void V8Proxy::RegisterExtension(v8::Extension* extension) { |
| 3525 v8::RegisterExtension(extension); | 3515 v8::RegisterExtension(extension); |
| 3526 m_extensions.push_back(extension); | 3516 m_extensions.push_back(extension); |
| 3527 } | 3517 } |
| 3528 | 3518 |
| 3529 } // namespace WebCore | 3519 } // namespace WebCore |
| OLD | NEW |