OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. 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 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2252 // Unfortunately, we cannot just use that method since it is private, and | 2252 // Unfortunately, we cannot just use that method since it is private, and |
2253 // it also doesn't quite behave as we require it to for bookmarklets. The | 2253 // it also doesn't quite behave as we require it to for bookmarklets. The |
2254 // key difference is that we need to suppress loading the string result | 2254 // key difference is that we need to suppress loading the string result |
2255 // from evaluating the JS URL if executing the JS URL resulted in a | 2255 // from evaluating the JS URL if executing the JS URL resulted in a |
2256 // location change. We also allow a JS URL to be loaded even if scripts on | 2256 // location change. We also allow a JS URL to be loaded even if scripts on |
2257 // the page are otherwise disabled. | 2257 // the page are otherwise disabled. |
2258 | 2258 |
2259 if (!m_frame->document() || !m_frame->page()) | 2259 if (!m_frame->document() || !m_frame->page()) |
2260 return; | 2260 return; |
2261 | 2261 |
| 2262 RefPtr<Document> ownerDocument(m_frame->document()); |
| 2263 |
2262 // Protect privileged pages against bookmarklets and other javascript manipu
lations. | 2264 // Protect privileged pages against bookmarklets and other javascript manipu
lations. |
2263 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(m_frame-
>document()->url().protocol())) | 2265 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(m_frame-
>document()->url().protocol())) |
2264 return; | 2266 return; |
2265 | 2267 |
2266 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); | 2268 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); |
2267 ScriptValue result = m_frame->script()->executeScript(script, true); | 2269 ScriptValue result = m_frame->script()->executeScript(script, true); |
2268 | 2270 |
2269 String scriptResult; | 2271 String scriptResult; |
2270 if (!result.getString(scriptResult)) | 2272 if (!result.getString(scriptResult)) |
2271 return; | 2273 return; |
2272 | 2274 |
2273 if (!m_frame->navigationScheduler()->locationChangePending()) | 2275 if (!m_frame->navigationScheduler()->locationChangePending()) |
2274 m_frame->document()->loader()->writer()->replaceDocument(scriptResult); | 2276 m_frame->document()->loader()->writer()->replaceDocument(scriptResult, o
wnerDocument.get()); |
2275 } | 2277 } |
2276 | 2278 |
2277 } // namespace WebKit | 2279 } // namespace WebKit |
OLD | NEW |