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

Unified Diff: Source/core/frame/RemoteDOMWindow.cpp

Issue 1176843006: Move window.close implementation to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/frame/RemoteFrame.h » ('j') | Source/web/tests/WebFrameTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « no previous file | Source/core/frame/RemoteFrame.h » ('j') | Source/web/tests/WebFrameTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698