diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 183166321..15a3bfb2d 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -367,7 +367,7 @@ void MainApplication::loadSettings() m_websettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, settings.value("allowJavaScriptOpenWindow", false).toBool()); m_websettings->setAttribute(QWebSettings::JavaEnabled, settings.value("allowJava", true).toBool()); m_websettings->setAttribute(QWebSettings::DnsPrefetchEnabled, settings.value("DNS-Prefetch", false).toBool()); - m_websettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, settings.value("JavaScriptCanAccessClipboard", true).toBool()); + m_websettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, settings.value("allowJavaScriptAccessClipboard", true).toBool()); m_websettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, settings.value("IncludeLinkInFocusChain", false).toBool()); m_websettings->setAttribute(QWebSettings::ZoomTextOnly, settings.value("zoomTextOnly", false).toBool()); m_websettings->setAttribute(QWebSettings::PrintElementBackgrounds, settings.value("PrintElementBackground", true).toBool()); @@ -387,7 +387,7 @@ void MainApplication::loadSettings() #if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) m_websettings->setAttribute(QWebSettings::HyperlinkAuditingEnabled, true); - m_websettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, true); + m_websettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, settings.value("allowJavaScriptCloseWindow", false).toBool()); #endif setWheelScrollLines(settings.value("wheelScrollLines", wheelScrollLines()).toInt()); diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 03e42dbf5..8efdfe4f6 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -92,6 +92,7 @@ SOURCES += \ autofill/autofillnotification.cpp \ rss/rssnotification.cpp \ preferences/sslmanager.cpp \ + preferences/jsoptions.cpp \ tools/animatedwidget.cpp \ tools/htmlhighlighter.cpp \ tools/colors.cpp \ @@ -248,6 +249,7 @@ HEADERS += \ autofill/autofillnotification.h \ rss/rssnotification.h \ preferences/sslmanager.h \ + preferences/jsoptions.h \ tools/animatedwidget.h \ tools/htmlhighlighter.h \ other/sourceviewersearch.h \ @@ -374,6 +376,7 @@ FORMS += \ autofill/autofillnotification.ui \ rss/rssnotification.ui \ preferences/sslmanager.ui \ + preferences/jsoptions.ui \ other/clearprivatedata.ui \ other/sourceviewersearch.ui \ adblock/adblockdialog.ui \ diff --git a/src/lib/other/qzsettings.cpp b/src/lib/other/qzsettings.cpp index 6fce57f39..1138316c4 100644 --- a/src/lib/other/qzsettings.cpp +++ b/src/lib/other/qzsettings.cpp @@ -46,6 +46,10 @@ void QzSettings::loadSettings() loadTabsOnActivation = settings.value("LoadTabsOnActivation", false).toBool(); autoOpenProtocols = settings.value("AutomaticallyOpenProtocols", QStringList()).toStringList(); blockedProtocols = settings.value("BlockOpeningProtocols", QStringList()).toStringList(); + allowJsGeometryChange = settings.value("allowJavaScriptGeometryChange", true).toBool(); + allowJsHideMenuBar = settings.value("allowJavaScriptHideMenuBar", true).toBool(); + allowJsHideStatusBar = settings.value("allowJavaScriptHideStatusBar", true).toBool(); + allowJsHideToolBar = settings.value("allowJavaScriptHideToolBar", true).toBool(); settings.endGroup(); settings.beginGroup("Browser-Tabs-Settings"); diff --git a/src/lib/other/qzsettings.h b/src/lib/other/qzsettings.h index b5a452606..24f0620bc 100644 --- a/src/lib/other/qzsettings.h +++ b/src/lib/other/qzsettings.h @@ -47,6 +47,10 @@ public: // Web-Browser-Settings int defaultZoom; bool loadTabsOnActivation; + bool allowJsGeometryChange; + bool allowJsHideMenuBar; + bool allowJsHideStatusBar; + bool allowJsHideToolBar; QStringList autoOpenProtocols; QStringList blockedProtocols; diff --git a/src/lib/popupwindow/popupwebpage.cpp b/src/lib/popupwindow/popupwebpage.cpp index 2ff9a2b56..1e1dcd750 100644 --- a/src/lib/popupwindow/popupwebpage.cpp +++ b/src/lib/popupwindow/popupwebpage.cpp @@ -21,6 +21,7 @@ #include "qupzilla.h" #include "tabwidget.h" #include "tabbedwebview.h" +#include "qzsettings.h" #include #include @@ -56,7 +57,7 @@ PopupWebPage::PopupWebPage(QWebPage::WebWindowType type, QupZilla* mainClass) void PopupWebPage::slotGeometryChangeRequested(const QRect &rect) { - if (rect.isValid()) { + if (rect.isValid() && qzSettings->allowJsGeometryChange) { m_geometry = rect; m_createNewWindow = true; } @@ -64,16 +65,19 @@ void PopupWebPage::slotGeometryChangeRequested(const QRect &rect) void PopupWebPage::slotMenuBarVisibilityChangeRequested(bool visible) { + if (!qzSettings->allowJsHideMenuBar) return; m_menuBarVisible = visible; } void PopupWebPage::slotStatusBarVisibilityChangeRequested(bool visible) { + if (!qzSettings->allowJsHideStatusBar) return; m_statusBarVisible = visible; } void PopupWebPage::slotToolBarVisibilityChangeRequested(bool visible) { + if (!qzSettings->allowJsHideToolBar) return; m_toolBarVisible = visible; } diff --git a/src/lib/preferences/jsoptions.cpp b/src/lib/preferences/jsoptions.cpp new file mode 100644 index 000000000..4eb27d95f --- /dev/null +++ b/src/lib/preferences/jsoptions.cpp @@ -0,0 +1,65 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2010-2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "jsoptions.h" +#include "ui_jsoptions.h" +#include "mainapplication.h" +#include "settings.h" + +#include + +JsOptions::JsOptions(QWidget* parent) + : QDialog(parent) + , ui(new Ui::JsOptions) +{ + setAttribute(Qt::WA_DeleteOnClose); + ui->setupUi(this); + + Settings settings; + settings.beginGroup("Web-Browser-Settings"); + ui->jscanCloseWindow->setChecked(settings.value("allowJavaScriptCloseWindow", false).toBool()); + ui->jscanOpenWindow->setChecked(settings.value("allowJavaScriptOpenWindow", false).toBool()); + ui->jscanChangeSize->setChecked(settings.value("allowJavaScriptGeometryChange", true).toBool()); + ui->jscanHideMenu->setChecked(settings.value("allowJavaScriptHideMenuBar", true).toBool()); + ui->jscanHideStatus->setChecked(settings.value("allowJavaScriptHideStatusBar", true).toBool()); + ui->jscanHideTool->setChecked(settings.value("allowJavaScriptHideToolBar", true).toBool()); + ui->jscanAccessClipboard->setChecked(settings.value("allowJavaScriptAccessClipboard", false).toBool()); + settings.endGroup(); + + connect(ui->jsoptsbbox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); +} + +void JsOptions::accept() +{ + Settings settings; + settings.beginGroup("Web-Browser-Settings"); + settings.setValue("allowJavaScriptCloseWindow", ui->jscanCloseWindow->isChecked()); + settings.setValue("allowJavaScriptOpenWindow", ui->jscanOpenWindow->isChecked()); + settings.setValue("allowJavaScriptGeometryChange", ui->jscanChangeSize->isChecked()); + settings.setValue("allowJavaScriptHideMenuBar", ui->jscanHideMenu->isChecked()); + settings.setValue("allowJavaScriptHideStatusBar", ui->jscanHideStatus->isChecked()); + settings.setValue("allowJavaScriptHideToolBar", ui->jscanHideTool->isChecked()); + settings.setValue("allowJavaScriptAccessClipboard", ui->jscanAccessClipboard->isChecked()); + settings.endGroup(); + + QDialog::close(); +} + +JsOptions::~JsOptions() +{ + delete ui; +} diff --git a/src/lib/preferences/jsoptions.h b/src/lib/preferences/jsoptions.h new file mode 100644 index 000000000..9259bcacb --- /dev/null +++ b/src/lib/preferences/jsoptions.h @@ -0,0 +1,46 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2010-2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef JSOPTIONS_H +#define JSOPTIONS_H + +#include + +#include "qz_namespace.h" + +namespace Ui +{ +class JsOptions; +} + +class QT_QUPZILLA_EXPORT JsOptions : public QDialog +{ + Q_OBJECT + +public slots: + void accept(); + +public: + explicit JsOptions(QWidget* parent = 0); + ~JsOptions(); + +private: + + Ui::JsOptions* ui; +}; + +#endif // JSOPTIONS_H diff --git a/src/lib/preferences/jsoptions.ui b/src/lib/preferences/jsoptions.ui new file mode 100644 index 000000000..b383625e9 --- /dev/null +++ b/src/lib/preferences/jsoptions.ui @@ -0,0 +1,150 @@ + + + JsOptions + + + + 0 + 0 + 214 + 247 + + + + JavaScript Options + + + + + + Allow JavaScript to: + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Close windows + + + + + + + If enabled, pages will be allowed to automatically open popup windows + + + Open popup windows + + + + + + + Change window size + + + + + + + Hide menu bar + + + + + + + Hide status bar + + + + + + + Hide tool bar + + + + + + + Access clipboard + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + jsoptsbbox + accepted() + JsOptions + accept() + + + 248 + 254 + + + 157 + 274 + + + + + jsoptsbbox + rejected() + JsOptions + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 9a7b1637f..a851dd7db 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -30,6 +30,7 @@ #include "pluginsmanager.h" #include "qtwin.h" #include "sslmanager.h" +#include "jsoptions.h" #include "networkproxyfactory.h" #include "networkmanager.h" #include "desktopnotificationsfactory.h" @@ -252,7 +253,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool()); if (!ui->allowJavaScript->isChecked()) { - ui->blockPopup->setEnabled(false); + ui->jsOptionsButton->setEnabled(false); } connect(ui->allowJavaScript, SIGNAL(toggled(bool)), this, SLOT(allowJavaScriptChanged(bool))); //Cache @@ -289,8 +290,6 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->deleteHtml5storageOnClose->setChecked(settings.value("deleteHTML5StorageOnClose", false).toBool()); connect(ui->html5storage, SIGNAL(toggled(bool)), this, SLOT(allowHtml5storageChanged(bool))); // Other - ui->blockPopup->setChecked(!settings.value("allowJavaScriptOpenWindow", false).toBool()); - ui->jscanAccessClipboard->setChecked(settings.value("JavaScriptCanAccessClipboard", true).toBool()); ui->doNotTrack->setChecked(settings.value("DoNotTrack", false).toBool()); ui->sendReferer->setChecked(settings.value("SendReferer", true).toBool()); @@ -458,6 +457,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) connect(ui->preferredLanguages, SIGNAL(clicked()), this, SLOT(showAcceptLanguage())); connect(ui->deleteHtml5storage, SIGNAL(clicked()), this, SLOT(deleteHtml5storage())); connect(ui->uaManager, SIGNAL(clicked()), this, SLOT(openUserAgentManager())); + connect(ui->jsOptionsButton, SIGNAL(clicked()), this, SLOT(openJsOptions())); connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(showStackedPage(QListWidgetItem*))); ui->listWidget->setItemSelected(ui->listWidget->itemAt(5, 5), true); @@ -604,7 +604,7 @@ void Preferences::setManualProxyConfigurationEnabled(bool state) void Preferences::allowJavaScriptChanged(bool state) { - ui->blockPopup->setEnabled(state); + ui->jsOptionsButton->setEnabled(state); } void Preferences::saveHistoryChanged(bool stat) @@ -637,6 +637,12 @@ void Preferences::openSslManager() m->show(); } +void Preferences::openJsOptions() +{ + JsOptions* m = new JsOptions(this); + m->show(); +} + void Preferences::showAcceptLanguage() { AcceptLanguage a(this); @@ -886,10 +892,8 @@ void Preferences::saveSettings() settings.beginGroup("Web-Browser-Settings"); settings.setValue("allowFlash", ui->allowPlugins->isChecked()); settings.setValue("allowJavaScript", ui->allowJavaScript->isChecked()); - settings.setValue("allowJavaScriptOpenWindow", !ui->blockPopup->isChecked()); settings.setValue("allowJava", ui->allowJava->isChecked()); settings.setValue("DNS-Prefetch", ui->allowDNSPrefetch->isChecked()); - settings.setValue("JavaScriptCanAccessClipboard", ui->jscanAccessClipboard->isChecked()); settings.setValue("IncludeLinkInFocusChain", ui->linksInFocusChain->isChecked()); settings.setValue("zoomTextOnly", ui->zoomTextOnly->isChecked()); settings.setValue("CaretBrowsing", ui->caretBrowsing->isChecked()); diff --git a/src/lib/preferences/preferences.h b/src/lib/preferences/preferences.h index 914d9d4cc..72fa68cb6 100644 --- a/src/lib/preferences/preferences.h +++ b/src/lib/preferences/preferences.h @@ -61,6 +61,7 @@ private slots: void deleteHtml5storage(); void chooseExternalDownloadManager(); void openUserAgentManager(); + void openJsOptions(); void allowJavaScriptChanged(bool state); void saveHistoryChanged(bool state); diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index 5483b3dac..0cb6756cd 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -167,16 +167,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -507,16 +498,7 @@ Themes - - 0 - - - 0 - - - 0 - - + 0 @@ -2047,21 +2029,30 @@ - - + + - JavaScript can access clipboard + Allow storing of cookies - - - - Block popup windows + + + + Qt::Horizontal - + + QSizePolicy::Fixed + + + + 40 + 20 + + + - + Send Referer header to servers @@ -2082,13 +2073,6 @@ - - - - Allow storing of cookies - - - @@ -2112,14 +2096,14 @@ - + Send Do Not Track header to servers - + <b>Other</b> @@ -2188,29 +2172,6 @@ - - - - Delete cookies on close - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - @@ -2228,6 +2189,46 @@ + + + + Delete cookies on close + + + + + + + true + + + <b>JavaScript</b> + + + + + + + false + + + Manage JavaScript privacy options + + + + + + + + 0 + 0 + + + + JavaScript options + + + @@ -2368,16 +2369,7 @@ - - 0 - - - 0 - - - 0 - - + 0