OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_
frame->document()->url(), eventHandlerPosition().m_line)) | 592 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_
frame->document()->url(), eventHandlerPosition().m_line)) |
593 return true; | 593 return true; |
594 | 594 |
595 // We need to hold onto the Frame here because executing script can | 595 // We need to hold onto the Frame here because executing script can |
596 // destroy the frame. | 596 // destroy the frame. |
597 RefPtr<Frame> protector(m_frame); | 597 RefPtr<Frame> protector(m_frame); |
598 RefPtr<Document> ownerDocument(m_frame->document()); | 598 RefPtr<Document> ownerDocument(m_frame->document()); |
599 | 599 |
600 const int javascriptSchemeLength = sizeof("javascript:") - 1; | 600 const int javascriptSchemeLength = sizeof("javascript:") - 1; |
601 | 601 |
602 bool locationChangeBefore = m_frame->navigationScheduler()->locationChangePe
nding(); | 602 bool locationChangeBefore = m_frame->navigationScheduler().locationChangePen
ding(); |
603 | 603 |
604 String decodedURL = decodeURLEscapeSequences(url.string()); | 604 String decodedURL = decodeURLEscapeSequences(url.string()); |
605 ScriptValue result = evaluateScriptInMainWorld(ScriptSourceCode(decodedURL.s
ubstring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecuteScriptWhe
nScriptsDisabled); | 605 ScriptValue result = evaluateScriptInMainWorld(ScriptSourceCode(decodedURL.s
ubstring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecuteScriptWhe
nScriptsDisabled); |
606 | 606 |
607 // If executing script caused this frame to be removed from the page, we | 607 // If executing script caused this frame to be removed from the page, we |
608 // don't want to try to replace its document! | 608 // don't want to try to replace its document! |
609 if (!m_frame->page()) | 609 if (!m_frame->page()) |
610 return true; | 610 return true; |
611 | 611 |
612 String scriptResult; | 612 String scriptResult; |
613 if (!result.getString(scriptResult)) | 613 if (!result.getString(scriptResult)) |
614 return true; | 614 return true; |
615 | 615 |
616 // We're still in a frame, so there should be a DocumentLoader. | 616 // We're still in a frame, so there should be a DocumentLoader. |
617 ASSERT(m_frame->document()->loader()); | 617 ASSERT(m_frame->document()->loader()); |
618 | 618 |
619 if (!locationChangeBefore && m_frame->navigationScheduler()->locationChangeP
ending()) | 619 if (!locationChangeBefore && m_frame->navigationScheduler().locationChangePe
nding()) |
620 return true; | 620 return true; |
621 | 621 |
622 // DocumentWriter::replaceDocument can cause the DocumentLoader to get deref
'ed and possible destroyed, | 622 // DocumentWriter::replaceDocument can cause the DocumentLoader to get deref
'ed and possible destroyed, |
623 // so protect it with a RefPtr. | 623 // so protect it with a RefPtr. |
624 if (RefPtr<DocumentLoader> loader = m_frame->document()->loader()) | 624 if (RefPtr<DocumentLoader> loader = m_frame->document()->loader()) |
625 loader->replaceDocument(scriptResult, ownerDocument.get()); | 625 loader->replaceDocument(scriptResult, ownerDocument.get()); |
626 return true; | 626 return true; |
627 } | 627 } |
628 | 628 |
629 void ScriptController::executeScriptInMainWorld(const String& script, ExecuteScr
iptPolicy policy) | 629 void ScriptController::executeScriptInMainWorld(const String& script, ExecuteScr
iptPolicy policy) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 v8Results = evaluateHandleScope.Close(resultArray); | 699 v8Results = evaluateHandleScope.Close(resultArray); |
700 } | 700 } |
701 | 701 |
702 if (results && !v8Results.IsEmpty()) { | 702 if (results && !v8Results.IsEmpty()) { |
703 for (size_t i = 0; i < v8Results->Length(); ++i) | 703 for (size_t i = 0; i < v8Results->Length(); ++i) |
704 results->append(ScriptValue(v8Results->Get(i), m_isolate)); | 704 results->append(ScriptValue(v8Results->Get(i), m_isolate)); |
705 } | 705 } |
706 } | 706 } |
707 | 707 |
708 } // namespace WebCore | 708 } // namespace WebCore |
OLD | NEW |