mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Send Referer header when opening new tab from webview.
This commit is contained in:
parent
950b7fb745
commit
cb603f409a
@ -125,17 +125,6 @@ void QupZilla::postLaunch()
|
|||||||
m_tabWidget->restorePinnedTabs();
|
m_tabWidget->restorePinnedTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Open tab from command line argument
|
|
||||||
bool addTab = true;
|
|
||||||
const QStringList &arguments = qApp->arguments();
|
|
||||||
for (int i = 0; i < qApp->arguments().count(); i++) {
|
|
||||||
QString arg = arguments.at(i);
|
|
||||||
if (arg.startsWith("-url=")) {
|
|
||||||
m_tabWidget->addView(QUrl(arg.remove("-url=")), Qz::NT_SelectedTabAtTheEnd);
|
|
||||||
addTab = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup("Web-URL-Settings");
|
settings.beginGroup("Web-URL-Settings");
|
||||||
int afterLaunch = settings.value("afterLaunch", 1).toInt();
|
int afterLaunch = settings.value("afterLaunch", 1).toInt();
|
||||||
@ -144,6 +133,7 @@ void QupZilla::postLaunch()
|
|||||||
bool startingAfterCrash = settings.value("isCrashed", false).toBool();
|
bool startingAfterCrash = settings.value("isCrashed", false).toBool();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
bool addTab = true;
|
||||||
QUrl startUrl;
|
QUrl startUrl;
|
||||||
switch (afterLaunch) {
|
switch (afterLaunch) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -146,7 +146,7 @@ void HistoryModel::slotDeleteHistoryEntry(const QList<int> &list)
|
|||||||
QSqlDatabase db = QSqlDatabase::database();
|
QSqlDatabase db = QSqlDatabase::database();
|
||||||
db.transaction();
|
db.transaction();
|
||||||
|
|
||||||
foreach (int index, list) {
|
foreach(int index, list) {
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT id, count, date, url, title FROM history WHERE id=?");
|
query.prepare("SELECT id, count, date, url, title FROM history WHERE id=?");
|
||||||
query.bindValue(0, index);
|
query.bindValue(0, index);
|
||||||
|
@ -104,7 +104,7 @@ OpenSearchEngine* OpenSearchReader::read()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_searchXml.contains(QLatin1String("http://a9.com/-/spec/opensearch/1.1/")) &&
|
if (!m_searchXml.contains(QLatin1String("http://a9.com/-/spec/opensearch/1.1/")) &&
|
||||||
!m_searchXml.contains(QLatin1String("http://www.mozilla.org/2006/browser/search/"))) {
|
!m_searchXml.contains(QLatin1String("http://www.mozilla.org/2006/browser/search/"))) {
|
||||||
raiseError(QObject::tr("The file is not an OpenSearch 1.1 file."));
|
raiseError(QObject::tr("The file is not an OpenSearch 1.1 file."));
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView
|
|||||||
|
|
||||||
QList<QPair<QByteArray, QByteArray> > queryItems;
|
QList<QPair<QByteArray, QByteArray> > queryItems;
|
||||||
QWebElementCollection allInputs = formElement.findAll("input");
|
QWebElementCollection allInputs = formElement.findAll("input");
|
||||||
foreach (QWebElement e, allInputs) {
|
foreach(QWebElement e, allInputs) {
|
||||||
if (element == e || !e.hasAttribute("name")) {
|
if (element == e || !e.hasAttribute("name")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
void addEngine(OpenSearchEngine* engine);
|
void addEngine(OpenSearchEngine* engine);
|
||||||
void addEngine(const Engine &engine);
|
void addEngine(const Engine &engine);
|
||||||
|
|
||||||
void addEngineFromForm(const QWebElement &element, WebView *view);
|
void addEngineFromForm(const QWebElement &element, WebView* view);
|
||||||
|
|
||||||
void removeEngine(const Engine &engine);
|
void removeEngine(const Engine &engine);
|
||||||
|
|
||||||
|
@ -58,14 +58,17 @@ QWidget* PopupWebView::overlayForJsAlert()
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position)
|
void PopupWebView::openUrlInNewTab(const QUrl &urla, Qz::NewTabPositionFlag position)
|
||||||
{
|
{
|
||||||
Q_UNUSED(position)
|
Q_UNUSED(position)
|
||||||
|
|
||||||
QupZilla* window = mApp->getWindow();
|
QupZilla* window = mApp->getWindow();
|
||||||
|
|
||||||
if (window) {
|
if (window) {
|
||||||
window->tabWidget()->addView(url, Qz::NT_SelectedTab);
|
QNetworkRequest req(urla);
|
||||||
|
req.setRawHeader("Referer", url().toEncoded());
|
||||||
|
|
||||||
|
window->tabWidget()->addView(req, Qz::NT_SelectedTab);
|
||||||
window->raise();
|
window->raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
PopupWebPage* webPage();
|
PopupWebPage* webPage();
|
||||||
|
|
||||||
QWidget* overlayForJsAlert();
|
QWidget* overlayForJsAlert();
|
||||||
void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position);
|
void openUrlInNewTab(const QUrl &urla, Qz::NewTabPositionFlag position);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ void TreeWidget::deleteItem(QTreeWidgetItem* item)
|
|||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeWidget::deleteItems(const QList<QTreeWidgetItem *> &items)
|
void TreeWidget::deleteItems(const QList<QTreeWidgetItem*> &items)
|
||||||
{
|
{
|
||||||
m_refreshAllItemsNeeded = true;
|
m_refreshAllItemsNeeded = true;
|
||||||
|
|
||||||
|
@ -345,14 +345,17 @@ void TabbedWebView::stop()
|
|||||||
slotLoadFinished();
|
slotLoadFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedWebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position)
|
void TabbedWebView::openUrlInNewTab(const QUrl &urla, Qz::NewTabPositionFlag position)
|
||||||
{
|
{
|
||||||
m_tabWidget->addView(url, position);
|
QNetworkRequest req(urla);
|
||||||
|
req.setRawHeader("Referer", url().toEncoded());
|
||||||
|
|
||||||
|
m_tabWidget->addView(req, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedWebView::openNewTab()
|
void TabbedWebView::openNewTab()
|
||||||
{
|
{
|
||||||
m_tabWidget->addView();
|
m_tabWidget->addView(QUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedWebView::getFocus(const QUrl &urla)
|
void TabbedWebView::getFocus(const QUrl &urla)
|
||||||
|
@ -70,7 +70,7 @@ public slots:
|
|||||||
void loadingProgress(int prog);
|
void loadingProgress(int prog);
|
||||||
|
|
||||||
void closeView();
|
void closeView();
|
||||||
void openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlag position);
|
void openUrlInNewTab(const QUrl &urla, Qz::NewTabPositionFlag position);
|
||||||
void openNewTab();
|
void openNewTab();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -244,11 +244,22 @@ void TabWidget::actionChangeIndex()
|
|||||||
|
|
||||||
int TabWidget::addView(const QUrl &url, const Qz::NewTabPositionFlags &openFlags, bool selectLine)
|
int TabWidget::addView(const QUrl &url, const Qz::NewTabPositionFlags &openFlags, bool selectLine)
|
||||||
{
|
{
|
||||||
return addView(url, tr("New tab"), openFlags, selectLine);
|
return addView(QNetworkRequest(url), openFlags, selectLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::addView(QUrl url, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position)
|
int TabWidget::addView(const QNetworkRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine)
|
||||||
{
|
{
|
||||||
|
return addView(req, tr("New tab"), openFlags, selectLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TabWidget::addView(const QUrl &url, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position)
|
||||||
|
{
|
||||||
|
return addView(QNetworkRequest(url), title, openFlags, selectLine, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position)
|
||||||
|
{
|
||||||
|
QUrl url = req.url();
|
||||||
m_lastTabIndex = currentIndex();
|
m_lastTabIndex = currentIndex();
|
||||||
|
|
||||||
if (url.isEmpty() && !(openFlags & Qz::NT_CleanTab)) {
|
if (url.isEmpty() && !(openFlags & Qz::NT_CleanTab)) {
|
||||||
@ -303,7 +314,8 @@ int TabWidget::addView(QUrl url, const QString &title, const Qz::NewTabPositionF
|
|||||||
connect(webView, SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));
|
connect(webView, SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));
|
||||||
|
|
||||||
if (url.isValid()) {
|
if (url.isValid()) {
|
||||||
webView->load(url);
|
req.setUrl(url);
|
||||||
|
webView->load(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectLine) {
|
if (selectLine) {
|
||||||
@ -469,7 +481,10 @@ int TabWidget::duplicateTab(int index)
|
|||||||
QDataStream tabHistoryStream(&history, QIODevice::WriteOnly);
|
QDataStream tabHistoryStream(&history, QIODevice::WriteOnly);
|
||||||
tabHistoryStream << *weView(index)->history();
|
tabHistoryStream << *weView(index)->history();
|
||||||
|
|
||||||
int id = addView(url, tabText(index), Qz::NT_CleanNotSelectedTab);
|
QNetworkRequest req(url);
|
||||||
|
req.setRawHeader("Referer", url.toEncoded());
|
||||||
|
|
||||||
|
int id = addView(req, tabText(index), Qz::NT_CleanNotSelectedTab);
|
||||||
QDataStream historyStream(history);
|
QDataStream historyStream(history);
|
||||||
historyStream >> *weView(id)->history();
|
historyStream >> *weView(id)->history();
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
#include "toolbutton.h"
|
#include "toolbutton.h"
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
@ -81,7 +82,11 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
int addView(const QUrl &url, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false);
|
int addView(const QUrl &url, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false);
|
||||||
int addView(QUrl url = QUrl(), const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1);
|
int addView(const QNetworkRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false);
|
||||||
|
|
||||||
|
int addView(const QUrl &url, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1);
|
||||||
|
int addView(QNetworkRequest req, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1);
|
||||||
|
|
||||||
int duplicateTab(int index);
|
int duplicateTab(int index);
|
||||||
|
|
||||||
void closeTab(int index = -1);
|
void closeTab(int index = -1);
|
||||||
|
@ -116,6 +116,13 @@ void WebView::setPage(QWebPage* page)
|
|||||||
|
|
||||||
void WebView::load(const QUrl &url)
|
void WebView::load(const QUrl &url)
|
||||||
{
|
{
|
||||||
|
load(QNetworkRequest(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &body)
|
||||||
|
{
|
||||||
|
const QUrl &url = request.url();
|
||||||
|
|
||||||
if (url.scheme() == "javascript") {
|
if (url.scheme() == "javascript") {
|
||||||
// Getting scriptSource from PercentEncoding to properly load bookmarklets
|
// Getting scriptSource from PercentEncoding to properly load bookmarklets
|
||||||
QString scriptSource = QUrl::fromPercentEncoding(url.toString().mid(11).toUtf8());
|
QString scriptSource = QUrl::fromPercentEncoding(url.toString().mid(11).toUtf8());
|
||||||
@ -124,7 +131,7 @@ void WebView::load(const QUrl &url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isUrlValid(url)) {
|
if (isUrlValid(url)) {
|
||||||
QWebView::load(url);
|
QWebView::load(request, operation, body);
|
||||||
emit urlChanged(url);
|
emit urlChanged(url);
|
||||||
m_aboutToLoadUrl = url;
|
m_aboutToLoadUrl = url;
|
||||||
return;
|
return;
|
||||||
@ -132,8 +139,10 @@ void WebView::load(const QUrl &url)
|
|||||||
|
|
||||||
const QUrl &searchUrl = mApp->searchEnginesManager()->searchUrl(url.toString());
|
const QUrl &searchUrl = mApp->searchEnginesManager()->searchUrl(url.toString());
|
||||||
QWebView::load(searchUrl);
|
QWebView::load(searchUrl);
|
||||||
|
|
||||||
emit urlChanged(searchUrl);
|
emit urlChanged(searchUrl);
|
||||||
m_aboutToLoadUrl = searchUrl;
|
m_aboutToLoadUrl = searchUrl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebView::isLoading() const
|
bool WebView::isLoading() const
|
||||||
@ -504,7 +513,7 @@ bool WebView::isMediaElement(const QWebElement &element)
|
|||||||
return (element.tagName().toLower() == "video" || element.tagName().toLower() == "audio");
|
return (element.tagName().toLower() == "video" || element.tagName().toLower() == "audio");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::checkForForm(QMenu *menu, const QWebElement &element)
|
void WebView::checkForForm(QMenu* menu, const QWebElement &element)
|
||||||
{
|
{
|
||||||
QWebElement parentElement = element.parent();
|
QWebElement parentElement = element.parent();
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
|
|
||||||
void setPage(QWebPage* page);
|
void setPage(QWebPage* page);
|
||||||
|
|
||||||
|
void load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray());
|
||||||
|
|
||||||
bool isLoading() const;
|
bool isLoading() const;
|
||||||
int loadProgress() const;
|
int loadProgress() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user