summaryrefslogtreecommitdiffstats
path: root/webkit/pending
diff options
context:
space:
mode:
authorpatrick@chromium.org <patrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 21:43:30 +0000
committerpatrick@chromium.org <patrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 21:43:30 +0000
commit1de1aa61414b1769e5e3dcda683ed10ab96de06e (patch)
tree0fa830aba628387dbc2232042d06bba60909905e /webkit/pending
parentcbbe217d6eab1301dde860aa6452aaf7b0e76dba (diff)
downloadchromium_src-1de1aa61414b1769e5e3dcda683ed10ab96de06e.zip
chromium_src-1de1aa61414b1769e5e3dcda683ed10ab96de06e.tar.gz
chromium_src-1de1aa61414b1769e5e3dcda683ed10ab96de06e.tar.bz2
Add a new switch: --allow-scripts-to-close-windows.
With this switch, window.close() will always be enabled. Currently the switch is only available in test_shell. Review URL: http://codereview.chromium.org/2915 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2333 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/pending')
-rw-r--r--webkit/pending/DOMWindow.cpp9
-rw-r--r--webkit/pending/Settings.cpp6
-rw-r--r--webkit/pending/Settings.h4
3 files changed, 18 insertions, 1 deletions
diff --git a/webkit/pending/DOMWindow.cpp b/webkit/pending/DOMWindow.cpp
index d01eb9a..85a5a86 100644
--- a/webkit/pending/DOMWindow.cpp
+++ b/webkit/pending/DOMWindow.cpp
@@ -46,6 +46,7 @@
#include "PlatformScreen.h"
#include "PlatformString.h"
#include "Screen.h"
+#include "Settings.h"
#include <algorithm>
#include <wtf/MathExtras.h>
@@ -345,7 +346,13 @@ void DOMWindow::close()
if (!m_frame)
return;
- if (m_frame->loader()->openedByDOM() || m_frame->loader()->getHistoryLength() <= 1)
+ Settings* settings = m_frame->settings();
+ bool allow_scripts_to_close_windows =
+ (settings && settings->allowScriptsToCloseWindows());
+
+ if (m_frame->loader()->openedByDOM()
+ || m_frame->loader()->getHistoryLength() <= 1
+ || allow_scripts_to_close_windows)
m_frame->scheduleClose();
}
diff --git a/webkit/pending/Settings.cpp b/webkit/pending/Settings.cpp
index 8bcd6be..2cc4cca 100644
--- a/webkit/pending/Settings.cpp
+++ b/webkit/pending/Settings.cpp
@@ -72,6 +72,7 @@ Settings::Settings(Page* page)
, m_needsSiteSpecificQuirks(false)
, m_fontRenderingMode(0)
, m_usesEncodingDetector(false)
+ , m_allow_scripts_to_close_windows(false)
{
// A Frame may not have been created yet, so we initialize the AtomicString
// hash before trying to use it.
@@ -329,4 +330,9 @@ void Settings::setUsesUniversalDetector(bool usesEncodingDetector)
m_usesEncodingDetector = usesEncodingDetector;
}
+void Settings::setAllowScriptsToCloseWindows(bool allow_scripts_to_close_windows)
+{
+ m_allow_scripts_to_close_windows = allow_scripts_to_close_windows;
+}
+
} // namespace WebCore
diff --git a/webkit/pending/Settings.h b/webkit/pending/Settings.h
index 7604c48..3e2e1bf 100644
--- a/webkit/pending/Settings.h
+++ b/webkit/pending/Settings.h
@@ -153,6 +153,9 @@ namespace WebCore {
void setNeedsSiteSpecificQuirks(bool);
bool needsSiteSpecificQuirks() const { return m_needsSiteSpecificQuirks; }
+ void setAllowScriptsToCloseWindows(bool);
+ bool allowScriptsToCloseWindows() const { return m_allow_scripts_to_close_windows; }
+
private:
Page* m_page;
@@ -191,6 +194,7 @@ namespace WebCore {
bool m_needsSiteSpecificQuirks : 1;
unsigned m_fontRenderingMode : 1;
bool m_usesEncodingDetector : 1;
+ bool m_allow_scripts_to_close_windows : 1;
};
} // namespace WebCore