bool UserScript::operator==(const UserScript &other) const { if (isNull() != other.isNull()) return false; if (isNull()) // neither is valid return true; return worldId() == other.worldId() && runsOnSubFrames() == other.runsOnSubFrames() && injectionPoint() == other.injectionPoint() && name() == other.name() && sourceCode() == other.sourceCode(); }
bool QtWebEnginePage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) { if (m_isPopup) { emit aboutToNavigate(url, type); return false; } if (isMainFrame && url.scheme() == QLatin1String("javascript")) { runJavaScript(url.path()); return false; } if (url.scheme() == QLatin1String("mailto")) { QDesktopServices::openUrl(url); return false; } if (isMainFrame && type == QWebEnginePage::NavigationTypeReload && m_previousNavigationType == QWebEnginePage::NavigationTypeFormSubmitted && SettingsManager::getValue(QLatin1String("Choices/WarnFormResend")).toBool()) { bool cancel(false); bool warn(true); if (m_widget) { ContentsDialog dialog(ThemesManager::getIcon(QLatin1String("dialog-warning")), tr("Question"), tr("Are you sure that you want to send form data again?"), tr("Do you want to resend data?"), (QDialogButtonBox::Yes | QDialogButtonBox::Cancel), NULL, m_widget); dialog.setCheckBox(tr("Do not show this message again"), false); connect(m_widget, SIGNAL(aboutToReload()), &dialog, SLOT(close())); m_widget->showDialog(&dialog); cancel = !dialog.isAccepted(); warn = !dialog.getCheckBoxState(); } else { QMessageBox dialog; dialog.setWindowTitle(tr("Question")); dialog.setText(tr("Are you sure that you want to send form data again?")); dialog.setInformativeText(tr("Do you want to resend data?")); dialog.setIcon(QMessageBox::Question); dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); dialog.setDefaultButton(QMessageBox::Cancel); dialog.setCheckBox(new QCheckBox(tr("Do not show this message again"))); cancel = (dialog.exec() == QMessageBox::Cancel); warn = !dialog.checkBox()->isChecked(); } SettingsManager::setValue(QLatin1String("Choices/WarnFormResend"), warn); if (cancel) { return false; } } if (isMainFrame && type != QWebEnginePage::NavigationTypeReload) { m_previousNavigationType = type; } if (isMainFrame) { scripts().clear(); const QList<UserScript*> scripts(AddonsManager::getUserScriptsForUrl(url)); for (int i = 0; i < scripts.count(); ++i) { QWebEngineScript::InjectionPoint injectionPoint(QWebEngineScript::DocumentReady); if (scripts.at(i)->getInjectionTime() == UserScript::DocumentCreationTime) { injectionPoint = QWebEngineScript::DocumentCreation; } else if (scripts.at(i)->getInjectionTime() == UserScript::DeferredTime) { injectionPoint = QWebEngineScript::Deferred; } QWebEngineScript script; script.setSourceCode(scripts.at(i)->getSource()); script.setRunsOnSubFrames(scripts.at(i)->shouldRunOnSubFrames()); script.setInjectionPoint(injectionPoint); this->scripts().insert(script); } emit aboutToNavigate(url, type); } return true; }