Chromium Code Reviews| Index: Source/core/frame/RemoteDOMWindow.cpp |
| diff --git a/Source/core/frame/RemoteDOMWindow.cpp b/Source/core/frame/RemoteDOMWindow.cpp |
| index 0e8ee426bcae2aa53c13c5397c4b3fdf9dc40b93..d3b0948ca9e782285a28b528e669599a37985a1f 100644 |
| --- a/Source/core/frame/RemoteDOMWindow.cpp |
| +++ b/Source/core/frame/RemoteDOMWindow.cpp |
| @@ -9,6 +9,10 @@ |
| #include "core/css/CSSRuleList.h" |
| #include "core/css/CSSStyleDeclaration.h" |
| #include "core/css/MediaQueryList.h" |
| +#include "core/dom/Document.h" |
| +#include "core/frame/Settings.h" |
| +#include "core/page/Page.h" |
| +#include "wtf/MainThread.h" |
| namespace blink { |
| @@ -226,9 +230,34 @@ void RemoteDOMWindow::blur() |
| // FIXME: Implement. |
| } |
| -void RemoteDOMWindow::close(ExecutionContext* override) |
| +void RemoteDOMWindow::close(ExecutionContext* context) |
| { |
| - // FIXME: Implement. |
| + if (!frame() || !frame()->isMainFrame()) |
| + return; |
| + |
| + Page* page = frame()->page(); |
| + if (!page) |
| + return; |
| + |
| + if (context) { |
| + ASSERT(isMainThread()); |
| + Document* activeDocument = toDocument(context); |
| + if (!activeDocument) |
| + return; |
| + |
| + if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*frame())) |
| + return; |
| + } |
| + |
| + Settings* settings = frame()->settings(); |
| + bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseWindows(); |
| + |
| + if (!page->openedByDOM() && !allowScriptsToCloseWindows) |
| + return; |
|
nasko
2015/06/11 00:04:39
Most of the above checks are somewhat redundant be
|
| + |
| + m_frame->close(); |
| + |
| + m_windowIsClosing = true; |
| } |
| void RemoteDOMWindow::print() |