Changeset View
Changeset View
Standalone View
Standalone View
webenginepart/src/webenginepart.cpp
Show All 28 Lines | |||||
29 | #include <QWebEngineProfile> | 29 | #include <QWebEngineProfile> | ||
30 | #include <QUrlQuery> | 30 | #include <QUrlQuery> | ||
31 | 31 | | |||
32 | #include "webenginepart_ext.h" | 32 | #include "webenginepart_ext.h" | ||
33 | #include "webengineview.h" | 33 | #include "webengineview.h" | ||
34 | #include "webenginepage.h" | 34 | #include "webenginepage.h" | ||
35 | #include "websslinfo.h" | 35 | #include "websslinfo.h" | ||
36 | #include "webhistoryinterface.h" | 36 | #include "webhistoryinterface.h" | ||
37 | #include "webenginewallet.h" | ||||
37 | 38 | | |||
38 | #include "ui/searchbar.h" | 39 | #include "ui/searchbar.h" | ||
39 | #include "ui/passwordbar.h" | 40 | #include "ui/passwordbar.h" | ||
40 | #include "ui/featurepermissionbar.h" | 41 | #include "ui/featurepermissionbar.h" | ||
41 | #include "settings/webenginesettings.h" | 42 | #include "settings/webenginesettings.h" | ||
42 | 43 | | |||
43 | #include <kcodecaction.h> | 44 | #include <kcodecaction.h> | ||
44 | #include <kio/global.h> | 45 | #include <kio/global.h> | ||
Show All 30 Lines | 75 | WebEnginePart::WebEnginePart(QWidget *parentWidget, QObject *parent, | |||
75 | const QByteArray& cachedHistory, const QStringList& /*args*/) | 76 | const QByteArray& cachedHistory, const QStringList& /*args*/) | ||
76 | :KParts::ReadOnlyPart(parent), | 77 | :KParts::ReadOnlyPart(parent), | ||
77 | m_emitOpenUrlNotify(true), | 78 | m_emitOpenUrlNotify(true), | ||
78 | m_hasCachedFormData(false), | 79 | m_hasCachedFormData(false), | ||
79 | m_doLoadFinishedActions(false), | 80 | m_doLoadFinishedActions(false), | ||
80 | m_statusBarWalletLabel(0), | 81 | m_statusBarWalletLabel(0), | ||
81 | m_searchBar(0), | 82 | m_searchBar(0), | ||
82 | m_passwordBar(0), | 83 | m_passwordBar(0), | ||
83 | m_featurePermissionBar(0) | 84 | m_featurePermissionBar(0), | ||
85 | m_wallet(Q_NULLPTR) | ||||
84 | { | 86 | { | ||
85 | KAboutData about = KAboutData(QStringLiteral("webenginepart"), | 87 | KAboutData about = KAboutData(QStringLiteral("webenginepart"), | ||
86 | i18nc("Program Name", "WebEnginePart"), | 88 | i18nc("Program Name", "WebEnginePart"), | ||
87 | /*version*/ QStringLiteral("1.3.0"), | 89 | /*version*/ QStringLiteral("1.3.0"), | ||
88 | i18nc("Short Description", "QtWebEngine Browser Engine Component"), | 90 | i18nc("Short Description", "QtWebEngine Browser Engine Component"), | ||
89 | KAboutLicense::LGPL, | 91 | KAboutLicense::LGPL, | ||
90 | i18n("(C) 2009-2010 Dawit Alemayehu\n" | 92 | i18n("(C) 2009-2010 Dawit Alemayehu\n" | ||
91 | "(C) 2008-2010 Urs Wolfer\n" | 93 | "(C) 2008-2010 Urs Wolfer\n" | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 161 | // this, SLOT(slotSelectionClipboardUrlPasted(QUrl,QString))); | |||
163 | // Connect the signals from the page... | 165 | // Connect the signals from the page... | ||
164 | connectWebEnginePageSignals(page()); | 166 | connectWebEnginePageSignals(page()); | ||
165 | 167 | | |||
166 | // Init the QAction we are going to use... | 168 | // Init the QAction we are going to use... | ||
167 | initActions(); | 169 | initActions(); | ||
168 | 170 | | |||
169 | // Load plugins once we are fully ready | 171 | // Load plugins once we are fully ready | ||
170 | loadPlugins(); | 172 | loadPlugins(); | ||
173 | setWallet(page()->wallet()); | ||||
171 | } | 174 | } | ||
172 | 175 | | |||
173 | WebEnginePart::~WebEnginePart() | 176 | WebEnginePart::~WebEnginePart() | ||
174 | { | 177 | { | ||
175 | } | 178 | } | ||
176 | 179 | | |||
177 | WebEnginePage* WebEnginePart::page() | 180 | WebEnginePage* WebEnginePart::page() | ||
178 | { | 181 | { | ||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | |||||
306 | // page, SLOT(downloadUrl(QUrl))); | 309 | // page, SLOT(downloadUrl(QUrl))); | ||
307 | 310 | | |||
308 | connect(page, &QWebEnginePage::iconUrlChanged, [page, this](const QUrl& url) { | 311 | connect(page, &QWebEnginePage::iconUrlChanged, [page, this](const QUrl& url) { | ||
309 | if (WebEngineSettings::self()->favIconsEnabled() | 312 | if (WebEngineSettings::self()->favIconsEnabled() | ||
310 | && !page->profile()->isOffTheRecord()){ | 313 | && !page->profile()->isOffTheRecord()){ | ||
311 | m_browserExtension->setIconUrl(url); | 314 | m_browserExtension->setIconUrl(url); | ||
312 | } | 315 | } | ||
313 | }); | 316 | }); | ||
317 | } | ||||
314 | 318 | | |||
315 | #if 0 | 319 | void WebEnginePart::setWallet(WebEngineWallet* wallet) | ||
316 | KWebWallet *wallet = page->wallet(); | 320 | { | ||
317 | if (wallet) { | 321 | if(m_wallet){ | ||
dfaure: this code looks like it was duplicated by.... | |||||
318 | connect(wallet, SIGNAL(saveFormDataRequested(QString,QUrl)), | 322 | disconnect(m_wallet, &WebEngineWallet::saveFormDataRequested, | ||
319 | this, SLOT(slotSaveFormDataRequested(QString,QUrl))); | 323 | this, &WebEnginePart::slotSaveFormDataRequested); | ||
320 | connect(wallet, SIGNAL(fillFormRequestCompleted(bool)), | 324 | disconnect(m_wallet, &WebEngineWallet::fillFormRequestCompleted, | ||
321 | this, SLOT(slotFillFormRequestCompleted(bool))); | 325 | this, &WebEnginePart::slotFillFormRequestCompleted); | ||
322 | connect(wallet, SIGNAL(walletClosed()), this, SLOT(slotWalletClosed())); | 326 | disconnect(m_wallet, &WebEngineWallet::walletClosed, this, &WebEnginePart::slotWalletClosed); | ||
327 | } | ||||
328 | m_wallet = wallet; | ||||
329 | if (m_wallet) { | ||||
330 | connect(m_wallet, &WebEngineWallet::saveFormDataRequested, | ||||
331 | this, &WebEnginePart::slotSaveFormDataRequested); | ||||
332 | connect(m_wallet, &WebEngineWallet::fillFormRequestCompleted, | ||||
dfaure: why the old form here (SIGNAL() / SLOT()) and the new form for connect? | |||||
333 | this, &WebEnginePart::slotFillFormRequestCompleted); | ||||
334 | connect(m_wallet, &WebEngineWallet::walletClosed, this, &WebEnginePart::slotWalletClosed); | ||||
323 | } | 335 | } | ||
324 | #endif | | |||
325 | } | 336 | } | ||
326 | 337 | | |||
327 | bool WebEnginePart::openUrl(const QUrl &_u) | 338 | bool WebEnginePart::openUrl(const QUrl &_u) | ||
328 | { | 339 | { | ||
329 | QUrl u (_u); | 340 | QUrl u (_u); | ||
... this code. Should the first one be removed? dfaure: ... this code.
Should the first one be removed?
I can't tell because context is missing. | |||||
330 | 341 | | |||
331 | qDebug() << u; | 342 | qDebug() << u; | ||
332 | 343 | | |||
333 | // Ignore empty requests... | 344 | // Ignore empty requests... | ||
334 | if (u.isEmpty()) | 345 | if (u.isEmpty()) | ||
335 | return false; | 346 | return false; | ||
336 | 347 | | |||
337 | // If the URL given is a supported local protocol, e.g. "bookmark" but lacks | 348 | // If the URL given is a supported local protocol, e.g. "bookmark" but lacks | ||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | 451 | if (m_webView->title().trimmed().isEmpty()) { | |||
446 | // The urlChanged signal is emitted if and only if the main frame | 457 | // The urlChanged signal is emitted if and only if the main frame | ||
447 | // receives the title of the page so we manually invoke the slot as a | 458 | // receives the title of the page so we manually invoke the slot as a | ||
448 | // work around here for pages that do not contain it, such as text | 459 | // work around here for pages that do not contain it, such as text | ||
449 | // documents... | 460 | // documents... | ||
450 | slotUrlChanged(url); | 461 | slotUrlChanged(url); | ||
451 | } | 462 | } | ||
452 | if (!Utils::isBlankUrl(url())) { | 463 | if (!Utils::isBlankUrl(url())) { | ||
453 | m_hasCachedFormData = false; | 464 | m_hasCachedFormData = false; | ||
454 | | ||||
455 | if (WebEngineSettings::self()->isNonPasswordStorableSite(url().host())) { | 465 | if (WebEngineSettings::self()->isNonPasswordStorableSite(url().host())) { | ||
456 | addWalletStatusBarIcon(); | 466 | addWalletStatusBarIcon(); | ||
457 | } else { | 467 | } | ||
468 | else { | ||||
458 | // Attempt to fill the web form... | 469 | // Attempt to fill the web form... | ||
459 | // KWebWallet *webWallet = page() ? page()->wallet() : 0; | 470 | WebEngineWallet *wallet = page() ? page()->wallet() : 0; | ||
460 | // if (webWallet) { | 471 | if (wallet){ | ||
461 | // webWallet->fillFormData(frame, false); | 472 | wallet->fillFormData(page()); | ||
462 | // } | 473 | } | ||
463 | } | 474 | } | ||
464 | } | 475 | } | ||
465 | 476 | | |||
466 | bool pending = false; | 477 | bool pending = false; | ||
467 | // QWebFrame* frame = (page() ? page()->currentFrame() : 0); | 478 | // QWebFrame* frame = (page() ? page()->currentFrame() : 0); | ||
468 | // if (ok && | 479 | // if (ok && | ||
469 | // frame == page()->mainFrame() && | 480 | // frame == page()->mainFrame() && | ||
coding style: newline after if(wallet), I'd recommend curly braces too { ... } even for one-line statements, matching the KF5 coding style. dfaure: coding style: newline after if(wallet), I'd recommend curly braces too { ... } even for one… | |||||
470 | // !frame->findFirstElement(QL1S("head>meta[http-equiv=refresh]")).isNull()) { | 481 | // !frame->findFirstElement(QL1S("head>meta[http-equiv=refresh]")).isNull()) { | ||
471 | // if (WebEngineSettings::self()->autoPageRefresh()) { | 482 | // if (WebEngineSettings::self()->autoPageRefresh()) { | ||
472 | // pending = true; | 483 | // pending = true; | ||
473 | // } else { | 484 | // } else { | ||
474 | // frame->page()->triggerAction(QWebEnginePage::Stop); | 485 | // frame->page()->triggerAction(QWebEnginePage::Stop); | ||
475 | // } | 486 | // } | ||
476 | // } | 487 | // } | ||
477 | emit completed ((ok && pending)); | 488 | emit completed ((ok && pending)); | ||
▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Line(s) | |||||
761 | void WebEnginePart::slotDeleteNonPasswordStorableSite() | 772 | void WebEnginePart::slotDeleteNonPasswordStorableSite() | ||
762 | { | 773 | { | ||
763 | if (m_webView) | 774 | if (m_webView) | ||
764 | WebEngineSettings::self()->removeNonPasswordStorableSite(m_webView->url().host()); | 775 | WebEngineSettings::self()->removeNonPasswordStorableSite(m_webView->url().host()); | ||
765 | } | 776 | } | ||
766 | 777 | | |||
767 | void WebEnginePart::slotRemoveCachedPasswords() | 778 | void WebEnginePart::slotRemoveCachedPasswords() | ||
768 | { | 779 | { | ||
769 | if (!page()) // || !page()->wallet()) | 780 | if (!page() || !page()->wallet()) | ||
770 | return; | 781 | return; | ||
771 | 782 | | |||
772 | // page()->wallet()->removeFormData(page()->mainFrame(), true); | 783 | page()->wallet()->removeFormData(page()); | ||
773 | m_hasCachedFormData = false; | 784 | m_hasCachedFormData = false; | ||
774 | } | 785 | } | ||
775 | 786 | | |||
776 | void WebEnginePart::slotSetTextEncoding(QTextCodec * codec) | 787 | void WebEnginePart::slotSetTextEncoding(QTextCodec * codec) | ||
dfaure: one space too many before || | |||||
777 | { | 788 | { | ||
778 | // FIXME: The code below that sets the text encoding has been reported not to work. | 789 | // FIXME: The code below that sets the text encoding has been reported not to work. | ||
779 | if (!page()) | 790 | if (!page()) | ||
780 | return; | 791 | return; | ||
781 | 792 | | |||
782 | QWebEngineSettings *localSettings = page()->settings(); | 793 | QWebEngineSettings *localSettings = page()->settings(); | ||
783 | if (!localSettings) | 794 | if (!localSettings) | ||
784 | return; | 795 | return; | ||
Show All 32 Lines | 824 | { | |||
817 | 828 | | |||
818 | if (!m_featurePermissionBar) { | 829 | if (!m_featurePermissionBar) { | ||
819 | m_featurePermissionBar = new FeaturePermissionBar(widget()); | 830 | m_featurePermissionBar = new FeaturePermissionBar(widget()); | ||
820 | 831 | | |||
821 | connect(m_featurePermissionBar, SIGNAL(permissionGranted(QWebEnginePage::Feature)), | 832 | connect(m_featurePermissionBar, SIGNAL(permissionGranted(QWebEnginePage::Feature)), | ||
822 | this, SLOT(slotFeaturePermissionGranted(QWebEnginePage::Feature))); | 833 | this, SLOT(slotFeaturePermissionGranted(QWebEnginePage::Feature))); | ||
823 | connect(m_featurePermissionBar, SIGNAL(permissionDenied(QWebEnginePage::Feature)), | 834 | connect(m_featurePermissionBar, SIGNAL(permissionDenied(QWebEnginePage::Feature)), | ||
824 | this, SLOT(slotFeaturePermissionDenied(QWebEnginePage::Feature))); | 835 | this, SLOT(slotFeaturePermissionDenied(QWebEnginePage::Feature))); | ||
825 | // connect(m_passwordBar, SIGNAL(done()), | 836 | connect(m_passwordBar, SIGNAL(done()), | ||
826 | // this, SLOT(slotSaveFormDataDone())); | 837 | this, SLOT(slotSaveFormDataDone())); | ||
827 | QBoxLayout* lay = qobject_cast<QBoxLayout*>(widget()->layout()); | 838 | QBoxLayout* lay = qobject_cast<QBoxLayout*>(widget()->layout()); | ||
828 | if (lay) | 839 | if (lay) | ||
829 | lay->insertWidget(0, m_featurePermissionBar); | 840 | lay->insertWidget(0, m_featurePermissionBar); | ||
830 | } | 841 | } | ||
831 | m_featurePermissionBar->setFeature(feature); | 842 | m_featurePermissionBar->setFeature(feature); | ||
832 | // m_featurePermissionBar->setText(i18n("<html>Do you want to grant the site <b>%1</b> " | 843 | // m_featurePermissionBar->setText(i18n("<html>Do you want to grant the site <b>%1</b> " | ||
833 | // "access to information about your current physical location?", | 844 | // "access to information about your current physical location?", | ||
834 | // url.host())); | 845 | // url.host())); | ||
Show All 22 Lines | 864 | { | |||
857 | if (!WebEngineSettings::self()->askToSaveSitePassword()) | 868 | if (!WebEngineSettings::self()->askToSaveSitePassword()) | ||
858 | return; | 869 | return; | ||
859 | 870 | | |||
860 | if (m_passwordBar && m_passwordBar->isVisible()) | 871 | if (m_passwordBar && m_passwordBar->isVisible()) | ||
861 | return; | 872 | return; | ||
862 | 873 | | |||
863 | if (!m_passwordBar) { | 874 | if (!m_passwordBar) { | ||
864 | m_passwordBar = new PasswordBar(widget()); | 875 | m_passwordBar = new PasswordBar(widget()); | ||
865 | #if 0 | 876 | if (!m_wallet) { | ||
866 | KWebWallet* wallet = page()->wallet(); | 877 | qDebug() << "No m_wallet instance found! This should never happen!"; | ||
867 | if (!wallet) { | | |||
868 | kWarning() << "No wallet instance found! This should never happen!"; | | |||
869 | return; | 878 | return; | ||
870 | } | 879 | } | ||
871 | connect(m_passwordBar, SIGNAL(saveFormDataAccepted(QString)), | 880 | connect(m_passwordBar, SIGNAL(saveFormDataAccepted(QString)), | ||
872 | wallet, SLOT(acceptSaveFormDataRequest(QString))); | 881 | m_wallet, SLOT(acceptSaveFormDataRequest(QString))); | ||
873 | connect(m_passwordBar, SIGNAL(saveFormDataRejected(QString)), | 882 | connect(m_passwordBar, SIGNAL(saveFormDataRejected(QString)), | ||
874 | wallet, SLOT(rejectSaveFormDataRequest(QString))); | 883 | m_wallet, SLOT(rejectSaveFormDataRequest(QString))); | ||
875 | connect(m_passwordBar, SIGNAL(done()), | 884 | connect(m_passwordBar, SIGNAL(done()), | ||
876 | this, SLOT(slotSaveFormDataDone())); | 885 | this, SLOT(slotSaveFormDataDone())); | ||
877 | #endif | | |||
878 | } | 886 | } | ||
879 | 887 | | |||
880 | Q_ASSERT(m_passwordBar); | 888 | Q_ASSERT(m_passwordBar); | ||
881 | 889 | | |||
882 | m_passwordBar->setUrl(url); | 890 | m_passwordBar->setUrl(url); | ||
883 | m_passwordBar->setRequestKey(key); | 891 | m_passwordBar->setRequestKey(key); | ||
884 | m_passwordBar->setText(i18n("<html>Do you want %1 to remember the login " | 892 | m_passwordBar->setText(i18n("<html>Do you want %1 to remember the login " | ||
885 | "information for <b>%2</b>?</html>", | 893 | "information for <b>%2</b>?</html>", | ||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
this code looks like it was duplicated by....