WebPage::WebPage(QObject* parent) : QWebPage(parent) , m_view(0) , m_fileWatcher(0) , m_runningLoop(0) , m_loadProgress(-1) , m_blockAlerts(false) , m_secureStatus(false) , m_adjustingScheduled(false) { m_javaScriptEnabled = QWebSettings::globalSettings()->testAttribute(QWebSettings::JavascriptEnabled); m_networkProxy = new NetworkManagerProxy(this); m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager()); m_networkProxy->setPage(this); setNetworkAccessManager(m_networkProxy); setForwardUnsupportedContent(true); setPluginFactory(new WebPluginFactory(this)); history()->setMaximumItemCount(20); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished())); connect(this, SIGNAL(printRequested(QWebFrame*)), this, SLOT(printFrame(QWebFrame*))); connect(this, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest))); connect(this, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); frameCreated(mainFrame()); connect(this, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(frameCreated(QWebFrame*))); connect(this, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)), this, SLOT(dbQuotaExceeded(QWebFrame*))); connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject())); #if QTWEBKIT_FROM_2_2 connect(this, SIGNAL(featurePermissionRequested(QWebFrame*,QWebPage::Feature)), this, SLOT(featurePermissionRequested(QWebFrame*,QWebPage::Feature))); #endif #if QTWEBKIT_FROM_2_3 connect(this, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin*,quint64,quint64)), this, SLOT(appCacheQuotaExceeded(QWebSecurityOrigin*,quint64))); #elif QTWEBKIT_FROM_2_2 connect(this, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin*,quint64)), this, SLOT(appCacheQuotaExceeded(QWebSecurityOrigin*,quint64))); #endif s_livingPages.append(this); }
AMPWebView::AMPWebView( PHIAHistory *history, QWidget *parent ) : PHIAAbstractWebView( history, parent ), _webPage( 0 ), _webView( 0 ), _isLoading( false ), _reply( 0 ) //_cursorSetByWebCore( false ), _usesWebCoreCursor( true ) { qDebug( "AMPWebView::AMPWebView()" ); _webView=new QWebView( this ); _webPage=new AMPWebPage( this ); QVBoxLayout *layout=new QVBoxLayout(); layout->setContentsMargins( 0, 0, 0 ,0 ); layout->addWidget( _webView ); setLayout( layout ); Q_ASSERT( _networkAccessManager ); _webPage->setNetworkAccessManager( _networkAccessManager ); _webPage->setForwardUnsupportedContent( true ); _webView->setPage( _webPage ); //_webPage->setLinkDelegationPolicy( QWebPage::DelegateAllLinks ); QWebFrame *frame=_webPage->mainFrame(); connect( frame, SIGNAL( titleChanged( const QString& ) ), this, SLOT( slotTitleChanged( const QString& ) ) ); connect( frame, SIGNAL( iconChanged() ), this, SLOT( slotIconChanged() ) ); connect( frame, SIGNAL( urlChanged( const QUrl& ) ), this, SLOT( slotUrlChanged( const QUrl& ) ) ); connect( _webPage, SIGNAL( loadProgress( int ) ), this, SIGNAL( loadProgress( int ) ) ); connect( _webPage, SIGNAL( statusBarMessage( const QString& ) ), this, SLOT( slotStatusBarMessage( const QString& ) ) ); connect( _webPage, SIGNAL( windowCloseRequested() ), this, SIGNAL( windowCloseRequested() ) ); connect( _webPage, SIGNAL( unsupportedContent( QNetworkReply* ) ), this, SLOT( slotUnsupportedContent( QNetworkReply* ) ) ); connect( _webPage, SIGNAL( linkHovered( const QString&, const QString&, const QString& ) ), this, SLOT( slotLinkHovered( const QString&, const QString&, const QString& ) ) ); connect( _webPage, SIGNAL( loadFinished( bool ) ), this, SLOT( slotLoadFinished( bool ) ) ); connect( _webPage, SIGNAL( loadStarted() ), this, SLOT( slotLoadStarted() ) ); connect( _webPage, SIGNAL( javaScriptMessage( const QString&, int, const QString& ) ), this, SIGNAL( javaScriptConsoleMessage( const QString&, int, const QString& ) ) ); connect( _webPage, SIGNAL( geometryChangeRequested( const QRect& ) ), this, SIGNAL( geometryChangeRequested( const QRect& ) ) ); connect( _webPage, SIGNAL( statusBarVisibilityChangeRequested( bool ) ), this, SIGNAL( statusBarVisibilityChangeRequested( bool ) ) ); connect( _webPage, SIGNAL( menuBarVisibilityChangeRequested( bool ) ), this, SIGNAL( menuBarVisibilityChangeRequested( bool ) ) ); connect( _webPage, SIGNAL( toolBarVisibilityChangeRequested( bool ) ), this, SIGNAL( toolBarVisibilityChangeRequested( bool ) ) ); connect( _webPage, SIGNAL( printRequested( QWebFrame* ) ), this, SLOT( slotPrintRequest( QWebFrame* ) ) ); connect( _networkAccessManager, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( slotReplyFinished( QNetworkReply* ) ) ); update(); }
WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) { m_loading = false; m_failed = false; m_manager = manager; m_uuid = QUuid::createUuid().toString(); m_confirmAction = true; m_promptAction = false; setForwardUnsupportedContent(true); loadJavascript(); setUserStylesheet(); this->setCustomNetworkAccessManager(); connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted())); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); connect(this, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(frameCreated(QWebFrame *))); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*))); connect(this, SIGNAL(windowCloseRequested()), this, SLOT(remove())); settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); settings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true); settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); if(QFileInfo("tmp").isDir()) { settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); settings()->setOfflineWebApplicationCachePath("tmp"); } createWindow(); }
WebPage::WebPage(QUrl baseUrl, QWidget *parent) : QWebPage(parent), baseUrl_(baseUrl), navigated_(false) { settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); setNetworkAccessManager(new NetworkAccessManager(sharedSecret, parent)); defaultSaveDir_ = QDir::home(); connect(this, SIGNAL(windowCloseRequested()), SLOT(closeRequested())); }
void MainWindow::buildUI() { #if defined(Q_OS_SYMBIAN) delete urlEdit; #endif delete m_toolBar; m_toolBar = addToolBar("Navigation"); #if defined(Q_OS_SYMBIAN) m_toolBar->setIconSize(QSize(16, 16)); #endif QAction* reloadAction = page()->action(QWebPage::Reload); connect(reloadAction, SIGNAL(triggered()), this, SLOT(changeLocation())); m_toolBar->addAction(page()->action(QWebPage::Back)); m_toolBar->addAction(page()->action(QWebPage::Forward)); m_toolBar->addAction(reloadAction); m_toolBar->addAction(page()->action(QWebPage::Stop)); urlEdit = new LocationEdit(m_toolBar); urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy()); connect(urlEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QCompleter* completer = new QCompleter(m_toolBar); urlEdit->setCompleter(completer); completer->setModel(&urlModel); #if defined(Q_OS_SYMBIAN) addToolBarBreak(); addToolBar("Location")->addWidget(urlEdit); #else m_toolBar->addWidget(urlEdit); #endif connect(page()->mainFrame(), SIGNAL(titleChanged(const QString&)), this, SLOT(setWindowTitle(const QString&))); connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(setAddressUrl(QUrl))); connect(page(), SIGNAL(loadProgress(int)), urlEdit, SLOT(setProgress(int))); connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); // short-cuts page()->action(QWebPage::Back)->setShortcut(QKeySequence::Back); page()->action(QWebPage::Stop)->setShortcut(Qt::Key_Escape); page()->action(QWebPage::Forward)->setShortcut(QKeySequence::Forward); page()->action(QWebPage::Reload)->setShortcut(QKeySequence::Refresh); page()->action(QWebPage::Undo)->setShortcut(QKeySequence::Undo); page()->action(QWebPage::Redo)->setShortcut(QKeySequence::Redo); page()->action(QWebPage::Cut)->setShortcut(QKeySequence::Cut); page()->action(QWebPage::Copy)->setShortcut(QKeySequence::Copy); page()->action(QWebPage::Paste)->setShortcut(QKeySequence::Paste); page()->action(QWebPage::ToggleBold)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_B)); page()->action(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I)); page()->action(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U)); }
void Platform::boot(const QString core) { QString app = adjustPath(core); if (!isDebugMode() && !QFile::exists(app)) { QMessageBox::critical(this, tr("ThinReportsEditor Booting Error"), "Unable to load application."); exit(0); } view->load(app); setup(); connect(view, SIGNAL(loadFinished(bool)), this, SLOT(init())); connect(view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScript())); connect(view->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(view, SIGNAL(linkClicked(QUrl)), this, SLOT(openUrl(QUrl))); show(); }
void MainWindow::buildUI() { delete m_toolBar; m_toolBar = addToolBar("Navigation"); QAction* reloadAction = page()->action(QWebPage::Reload); connect(reloadAction, SIGNAL(triggered()), this, SLOT(changeLocation())); m_toolBar->addAction(page()->action(QWebPage::Back)); m_toolBar->addAction(page()->action(QWebPage::Forward)); m_toolBar->addAction(reloadAction); m_toolBar->addAction(page()->action(QWebPage::Stop)); #ifndef QT_NO_INPUTDIALOG urlEdit = new LocationEdit(m_toolBar); urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy()); connect(urlEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QCompleter* completer = new QCompleter(m_toolBar); urlEdit->setCompleter(completer); completer->setModel(&urlModel); m_toolBar->addWidget(urlEdit); connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(setAddressUrl(QUrl))); connect(page(), SIGNAL(loadProgress(int)), urlEdit, SLOT(setProgress(int))); #endif connect(page()->mainFrame(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(page()->mainFrame(), SIGNAL(iconChanged()), this, SLOT(onIconChanged())); connect(page()->mainFrame(), SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString))); connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); #ifndef QT_NO_SHORTCUT // short-cuts page()->action(QWebPage::Back)->setShortcut(QKeySequence::Back); page()->action(QWebPage::Stop)->setShortcut(Qt::Key_Escape); page()->action(QWebPage::Forward)->setShortcut(QKeySequence::Forward); page()->action(QWebPage::Reload)->setShortcut(QKeySequence::Refresh); #ifndef QT_NO_UNDOSTACK page()->action(QWebPage::Undo)->setShortcut(QKeySequence::Undo); page()->action(QWebPage::Redo)->setShortcut(QKeySequence::Redo); #endif page()->action(QWebPage::Cut)->setShortcut(QKeySequence::Cut); page()->action(QWebPage::Copy)->setShortcut(QKeySequence::Copy); page()->action(QWebPage::Paste)->setShortcut(QKeySequence::Paste); page()->action(QWebPage::SelectAll)->setShortcut(QKeySequence::SelectAll); page()->action(QWebPage::ToggleBold)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_B)); page()->action(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I)); page()->action(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U)); #endif }
WebPage::WebPage(QUrl baseUrl, QWidget *parent, bool allowExternalNavigate) : QWebEnginePage(new WebProfile(baseUrl), parent), baseUrl_(baseUrl), allowExternalNav_(allowExternalNavigate) { settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true); settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, true); settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true); defaultSaveDir_ = QDir::home(); connect(this, SIGNAL(windowCloseRequested()), SLOT(closeRequested())); connect(profile(), &QWebEngineProfile::downloadRequested, onDownloadRequested); connect(profile(), &WebProfile::urlIntercepted, this, &WebPage::onUrlIntercepted, Qt::DirectConnection); }
void KWebKitPart::connectWebPageSignals(WebPage* page) { if (!page) return; connect(page, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); connect(page, SIGNAL(loadAborted(QUrl)), this, SLOT(slotLoadAborted(QUrl))); connect(page, SIGNAL(linkHovered(QString,QString,QString)), this, SLOT(slotLinkHovered(QString,QString,QString))); connect(page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)), this, SLOT(slotSaveFrameState(QWebFrame*,QWebHistoryItem*))); connect(page, SIGNAL(restoreFrameStateRequested(QWebFrame*)), this, SLOT(slotRestoreFrameState(QWebFrame*))); connect(page, SIGNAL(statusBarMessage(QString)), this, SLOT(slotSetStatusBarText(QString))); connect(page, SIGNAL(windowCloseRequested()), this, SLOT(slotWindowCloseRequested())); connect(page, SIGNAL(printRequested(QWebFrame*)), m_browserExtension, SLOT(slotPrintRequested(QWebFrame*))); connect(page, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(slotFrameCreated(QWebFrame*))); connect(m_webView, SIGNAL(linkShiftClicked(QUrl)), page, SLOT(downloadUrl(QUrl))); connect(page, SIGNAL(loadProgress(int)), m_browserExtension, SIGNAL(loadingProgress(int))); connect(page, SIGNAL(selectionChanged()), m_browserExtension, SLOT(updateEditActions())); connect(m_browserExtension, SIGNAL(saveUrl(QUrl)), page, SLOT(downloadUrl(QUrl))); connect(page->mainFrame(), SIGNAL(loadFinished(bool)), this, SLOT(slotMainFrameLoadFinished(bool))); KWebWallet *wallet = page->wallet(); if (wallet) { connect(wallet, SIGNAL(saveFormDataRequested(QString,QUrl)), this, SLOT(slotSaveFormDataRequested(QString,QUrl))); connect(wallet, SIGNAL(fillFormRequestCompleted(bool)), this, SLOT(slotFillFormRequestCompleted(bool))); connect(wallet, SIGNAL(walletClosed()), this, SLOT(slotWalletClosed())); } }
/** * Call after setPage * @brief WebView::initSignals */ void WebView::initSignals() { connect(page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )), this, SLOT(handleSslErrors(QNetworkReply*, const QList<QSslError> & ))); connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(handleWindowCloseRequested())); connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SLOT(handlePrintRequested(QWebFrame*))); }
PopupWindow::PopupWindow(PopupWebView* view) : QWidget() , m_view(view) , m_page(view->webPage()) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); m_layout->setSpacing(0); m_locationBar = new PopupLocationBar(this); m_locationBar->setView(m_view); m_statusBar = new QStatusBar(this); m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); m_layout->addWidget(m_locationBar); m_layout->addWidget(m_view); m_layout->addWidget(m_statusBar); setLayout(m_layout); connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*))); connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged())); connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl))); connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showIcon())); connect(m_view, SIGNAL(statusBarMessage(QString)), m_statusBar, SLOT(showMessage(QString))); connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), m_statusBar, SLOT(showMessage(QString))); connect(m_page, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(setWindowGeometry(QRect))); connect(m_page, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(setStatusBarVisibility(bool))); connect(m_page, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(setMenuBarVisibility(bool))); connect(m_page, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(setToolBarVisibility(bool))); connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(close())); m_view->setFocus(); titleChanged(); QUrl urlToShow = m_view->url(); if (urlToShow.isEmpty()) { urlToShow = m_view->page()->mainFrame()->requestedUrl(); } m_locationBar->showUrl(urlToShow); }
void TabbedWebView::setWebPage(WebPage* page) { if (m_page == page) { return; } if (m_page) { delete m_page; m_page = 0; } m_page = page; m_page->setWebView(this); m_page->setParent(this); setPage(m_page); connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(linkHovered(QString, QString, QString))); connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(closeView())); }
QWebPage* PHIWebPage::createWindow( QWebPage::WebWindowType type ) { QWebView *view=new QWebView(); PHIWebPage *page=new PHIWebPage(); view->setPage( page ); page->setView( view ); if ( type==QWebPage::WebModalDialog ) view->setWindowModality( Qt::ApplicationModal); view->setPage( page ); view->setAttribute( Qt::WA_DeleteOnClose ); connect( page, SIGNAL( geometryChangeRequested( const QRect& ) ), page, SLOT( slotUpdateGeometry( const QRect& ) ) ); connect( page, SIGNAL( windowCloseRequested() ), view, SLOT( close() ) ); connect( page, SIGNAL( microFocusChanged() ), view, SLOT( updateMicroFocus() ) ); connect( page, SIGNAL( linkClicked( const QUrl& ) ), page, SLOT( slotLinkClicked( const QUrl& ) ) ); connect( view, &QWebView::titleChanged, view, &QWebView::setWindowTitle ); connect( view, &QWebView::iconChanged, page, &PHIWebPage::slotIconChanged ); view->show(); return page; }
WebPopup::WebPopup( const QUrl& url, const QSize& size ) : QWebView( 0 ) { setAttribute( Qt::WA_DeleteOnClose, true ); settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true ); settings()->setAttribute( QWebSettings::JavascriptCanCloseWindows, true ); page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAsNeeded ); page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAsNeeded ); connect( page(), SIGNAL( windowCloseRequested() ), SLOT( close() ) ); if ( !size.isEmpty() ) { resize( size ); } load( url ); show(); }
bool DeclarativeWebContainer::activatePage(int tabId, bool force, int parentId) { if (!m_model) { return false; } m_webPages->initialize(this, m_webPageComponent.data()); if ((m_model->loaded() || force) && tabId > 0 && m_webPages->initialized()) { WebPageActivationData activationData = m_webPages->page(tabId, parentId); setWebPage(activationData.webPage); // Reset always height so that orentation change is taken into account. m_webPage->forceChrome(false); m_webPage->setChrome(true); connect(m_webPage, SIGNAL(imeNotification(int,bool,int,int,QString)), this, SLOT(imeNotificationChanged(int,bool,int,int,QString)), Qt::UniqueConnection); connect(m_webPage, SIGNAL(windowCloseRequested()), this, SLOT(closeWindow()), Qt::UniqueConnection); connect(m_webPage, SIGNAL(urlChanged()), this, SLOT(onPageUrlChanged()), Qt::UniqueConnection); connect(m_webPage, SIGNAL(loadingChanged()), this, SLOT(updateLoading()), Qt::UniqueConnection); connect(m_webPage, SIGNAL(loadProgressChanged()), this, SLOT(updateLoadProgress()), Qt::UniqueConnection); connect(m_webPage, SIGNAL(titleChanged()), this, SLOT(onPageTitleChanged()), Qt::UniqueConnection); connect(m_webPage, SIGNAL(domContentLoadedChanged()), this, SLOT(sendVkbOpenCompositionMetrics()), Qt::UniqueConnection); connect(m_webPage, SIGNAL(backgroundChanged()), this, SIGNAL(backgroundChanged()), Qt::UniqueConnection); return activationData.activated; }
DumpRenderTree::DumpRenderTree() : m_dumpPixels(false) , m_stdin(0) , m_enableTextOutput(false) , m_standAloneMode(false) , m_graphicsBased(false) , m_persistentStoragePath(QString(getenv("DUMPRENDERTREE_TEMP"))) { QByteArray viewMode = getenv("QT_DRT_WEBVIEW_MODE"); if (viewMode == "graphics") setGraphicsBased(true); DumpRenderTreeSupportQt::overwritePluginDirectories(); DumpRenderTreeSupportQt::activeMockDeviceOrientationClient(true); QWebSettings::enablePersistentStorage(m_persistentStoragePath); m_networkAccessManager = new NetworkAccessManager(this); // create our primary testing page/view. if (isGraphicsBased()) { WebViewGraphicsBased* view = new WebViewGraphicsBased(0); m_page = new WebPage(view, this); view->setPage(m_page); m_mainView = view; } else { QWebView* view = new QWebView(0); m_page = new WebPage(view, this); view->setPage(m_page); m_mainView = view; } // Use a frame group name for all pages created by DumpRenderTree to allow // testing of cross-page frame lookup. DumpRenderTreeSupportQt::webPageSetGroupName(m_page, "org.webkit.qt.DumpRenderTree"); m_mainView->setContextMenuPolicy(Qt::NoContextMenu); m_mainView->resize(QSize(LayoutTestController::maxViewWidth, LayoutTestController::maxViewHeight)); // clean up cache by resetting quota. qint64 quota = webPage()->settings()->offlineWebApplicationCacheQuota(); webPage()->settings()->setOfflineWebApplicationCacheQuota(quota); // create our controllers. This has to be done before connectFrame, // as it exports there to the JavaScript DOM window. m_controller = new LayoutTestController(this); connect(m_controller, SIGNAL(showPage()), this, SLOT(showPage())); connect(m_controller, SIGNAL(hidePage()), this, SLOT(hidePage())); // async geolocation permission set by controller connect(m_controller, SIGNAL(geolocationPermissionSet()), this, SLOT(geolocationPermissionSet())); connect(m_controller, SIGNAL(done()), this, SLOT(dump())); m_eventSender = new EventSender(m_page); m_textInputController = new TextInputController(m_page); m_plainTextController = new PlainTextController(m_page); m_gcController = new GCController(m_page); // now connect our different signals connect(m_page, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(connectFrame(QWebFrame *))); connectFrame(m_page->mainFrame()); connect(m_page, SIGNAL(loadFinished(bool)), m_controller, SLOT(maybeDump(bool))); // We need to connect to loadStarted() because notifyDone should only // dump results itself when the last page loaded in the test has finished loading. connect(m_page, SIGNAL(loadStarted()), m_controller, SLOT(resetLoadFinished())); connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(m_page, SIGNAL(printRequested(QWebFrame*)), this, SLOT(dryRunPrint(QWebFrame*))); connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)), SLOT(titleChanged(const QString&))); connect(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)), this, SLOT(dumpDatabaseQuota(QWebFrame*,QString))); connect(m_page, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin *, quint64)), this, SLOT(dumpApplicationCacheQuota(QWebSecurityOrigin *, quint64))); connect(m_page, SIGNAL(statusBarMessage(const QString&)), this, SLOT(statusBarMessage(const QString&))); QObject::connect(this, SIGNAL(quit()), qApp, SLOT(quit()), Qt::QueuedConnection); DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(true); QFocusEvent event(QEvent::FocusIn, Qt::ActiveWindowFocusReason); QApplication::sendEvent(m_mainView, &event); }
emptyWidget->setAutoFillBackground(true); disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); addTab(emptyWidget, tr("(Untitled)")); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); return 0; } // webview WBWebView *webView = new WBWebView; urlLineEdit->setWebView(webView); connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), this, SIGNAL(geometryChangeRequested(const QRect &))); connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); connect(webView, SIGNAL(pixmapCaptured(const QPixmap&, bool)), UBApplication::applicationController, SLOT(addCapturedPixmap(const QPixmap &, bool))); connect(webView, SIGNAL(embedCodeCaptured(const QString&)), UBApplication::applicationController, SLOT(addCapturedEmbedCode(const QString&))); addTab(webView, tr("(Untitled)")); if (makeCurrent) setCurrentWidget(webView); // webview actions
void CustomWebPage::handleUnsupportedContent (QNetworkReply *reply) { Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy); emit hookUnsupportedContent (proxy, this, reply); if (proxy->IsCancelled ()) return; std::shared_ptr<void> replyGuard = std::shared_ptr<void> (nullptr, [reply] (void*) -> void { reply->abort (); reply->deleteLater (); }); const auto& url = reply->url (); const auto& mime = reply->header (QNetworkRequest::ContentTypeHeader).toString (); qDebug () << Q_FUNC_INFO << reply->url () << reply->errorString (); auto sendEnt = [reply, mime, url, this] () -> void { auto e = Util::MakeEntity (url, {}, LeechCraft::FromUserInitiated, mime); e.Additional_ ["IgnorePlugins"] = "org.LeechCraft.Poshuku"; emit gotEntity (e); if (XmlSettingsManager::Instance ()-> property ("CloseEmptyDelegatedPages").toBool () && history ()->currentItem ().url ().isEmpty ()) emit windowCloseRequested (); }; switch (reply->error ()) { case QNetworkReply::ProtocolUnknownError: if (XmlSettingsManager::Instance ()-> property ("ExternalSchemes").toString ().split (' ') .contains (url.scheme ())) QDesktopServices::openUrl (url); else sendEnt (); break; case QNetworkReply::NoError: { auto found = FindFrame (url); if (!found) { if (XmlSettingsManager::Instance ()-> property ("ParanoidDownloadsDetection").toBool () || !mime.isEmpty ()) { sendEnt (); break; } else qDebug () << Q_FUNC_INFO << mime; } else qDebug () << Q_FUNC_INFO << "but frame is found"; } default: { int statusCode = reply->attribute (QNetworkRequest::HttpStatusCodeAttribute).toInt (); qDebug () << Q_FUNC_INFO << "general unsupported content" << url << reply->error () << reply->errorString (); const auto& data = MakeErrorReplyContents (statusCode, url, reply->errorString (), QtNetwork); if (auto found = FindFrame (url)) found->setHtml (data, url); else if (LoadingURL_ == url) mainFrame ()->setHtml (data, url); break; } } }
} void Btms::loadPageSettings() { connect(ui->webView->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )), this, SLOT(sslErrorHandler(QNetworkReply*, const QList<QSslError> & ))); connect(ui->webView->page(), SIGNAL(printRequested(QWebFrame*)), SLOT(doPrint(QWebFrame*))); btmsJs = new BtmsJavascript(); QObject::connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJSObject())); connect(ui->webView->page(), SIGNAL(windowCloseRequested()), SLOT(close())); connect(ui->webView->page(), SIGNAL(downloadRequested(const QNetworkRequest&)), this, SLOT(downloadRequested(const QNetworkRequest&))); connect(ui->webView->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(downloadContent(QNetworkReply*))); } void Btms::loadWebSettings() { loadPageSettings(); ui->webView->settings()->setAttribute(QWebSettings::AutoLoadImages, true); ui->webView->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled,false); ui->webView->settings()->setAttribute(QWebSettings::LocalStorageEnabled,false); ui->webView->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,true); ui->webView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled,false); ui->webView->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled,true); ui->webView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); ui->webView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); ui->webView->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);