OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Simon Hausmann <hausmann@kde.org> | 5 * 2000 Simon Hausmann <hausmann@kde.org> |
6 * 2000 Stefan Schimanski <1Stein@gmx.de> | 6 * 2000 Stefan Schimanski <1Stein@gmx.de> |
7 * 2001 George Staikos <staikos@kde.org> | 7 * 2001 George Staikos <staikos@kde.org> |
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
9 * rights reserved. | 9 * rights reserved. |
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> | 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 459 } |
460 | 460 |
461 bool LocalFrame::prepareForCommit() { | 461 bool LocalFrame::prepareForCommit() { |
462 return loader().prepareForCommit(); | 462 return loader().prepareForCommit(); |
463 } | 463 } |
464 | 464 |
465 SecurityContext* LocalFrame::securityContext() const { | 465 SecurityContext* LocalFrame::securityContext() const { |
466 return document(); | 466 return document(); |
467 } | 467 } |
468 | 468 |
| 469 String LocalFrame::getTargetFrameDescription(const Frame& targetFrame) const { |
| 470 // URLs aren't available for RemoteFrames, so the error message uses their |
| 471 // origin instead. |
| 472 return targetFrame.isLocalFrame() |
| 473 ? "with URL '" + |
| 474 toLocalFrame(targetFrame).document()->url().getString() + "'" |
| 475 : "with origin '" + |
| 476 targetFrame.securityContext() |
| 477 ->getSecurityOrigin() |
| 478 ->toString() + |
| 479 "'"; |
| 480 } |
| 481 |
469 void LocalFrame::printNavigationErrorMessage(const Frame& targetFrame, | 482 void LocalFrame::printNavigationErrorMessage(const Frame& targetFrame, |
470 const char* reason) { | 483 const char* reason) { |
471 // URLs aren't available for RemoteFrames, so the error message uses their | |
472 // origin instead. | |
473 String targetFrameDescription = | |
474 targetFrame.isLocalFrame() | |
475 ? "with URL '" + | |
476 toLocalFrame(targetFrame).document()->url().getString() + "'" | |
477 : "with origin '" + | |
478 targetFrame.securityContext()->getSecurityOrigin()->toString() + | |
479 "'"; | |
480 String message = | 484 String message = |
481 "Unsafe JavaScript attempt to initiate navigation for frame " + | 485 "Unsafe JavaScript attempt to initiate navigation for frame " + |
482 targetFrameDescription + " from frame with URL '" + | 486 getTargetFrameDescription(targetFrame) + " from frame with URL '" + |
483 document()->url().getString() + "'. " + reason + "\n"; | 487 document()->url().getString() + "'. " + reason + "\n"; |
484 | 488 |
485 domWindow()->printErrorMessage(message); | 489 domWindow()->printErrorMessage(message); |
486 } | 490 } |
487 | 491 |
488 void LocalFrame::printNavigationWarning(const String& message) { | 492 void LocalFrame::printNavigationWarning(const Frame& targetFrame, |
| 493 const char* reason) { |
| 494 String message = "Frame with URL '" + document()->url().getString() + |
| 495 "' attempted to navigate its top-level window " + |
| 496 getTargetFrameDescription(targetFrame) + ". " + reason + |
| 497 "\n"; |
489 m_console->addMessage( | 498 m_console->addMessage( |
490 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); | 499 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
491 } | 500 } |
492 | 501 |
493 WindowProxyManager* LocalFrame::getWindowProxyManager() const { | 502 WindowProxyManager* LocalFrame::getWindowProxyManager() const { |
494 return m_script->getWindowProxyManager(); | 503 return m_script->getWindowProxyManager(); |
495 } | 504 } |
496 | 505 |
497 bool LocalFrame::shouldClose() { | 506 bool LocalFrame::shouldClose() { |
498 // TODO(dcheng): This should be fixed to dispatch beforeunload events to | 507 // TODO(dcheng): This should be fixed to dispatch beforeunload events to |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) | 948 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) |
940 m_frame->client()->frameBlameContext()->Enter(); | 949 m_frame->client()->frameBlameContext()->Enter(); |
941 } | 950 } |
942 | 951 |
943 ScopedFrameBlamer::~ScopedFrameBlamer() { | 952 ScopedFrameBlamer::~ScopedFrameBlamer() { |
944 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) | 953 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) |
945 m_frame->client()->frameBlameContext()->Leave(); | 954 m_frame->client()->frameBlameContext()->Leave(); |
946 } | 955 } |
947 | 956 |
948 } // namespace blink | 957 } // namespace blink |
OLD | NEW |