Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: Source/bindings/v8/ScriptController.cpp

Issue 32793003: Have Frame::navigationScheduler() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698