bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const String& defaultValue, String& result) { QString x = result; FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client()); bool rc = m_webPage->javaScriptPrompt(fl->webFrame(), (QString)message, (QString)defaultValue, &x); result = x; return rc; }
/*! Returns a list of all frames that are direct children of this frame. \sa parentFrame() */ QList<QWebFrame*> QWebFrame::childFrames() const { QList<QWebFrame*> rc; if (d->frame) { FrameTree *tree = d->frame->tree(); for (Frame *child = tree->firstChild(); child; child = child->tree()->nextSibling()) { FrameLoader *loader = child->loader(); FrameLoaderClientQt *client = static_cast<FrameLoaderClientQt*>(loader->client()); if (client) rc.append(client->webFrame()); } } return rc; }
bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const String& defaultValue, String& result) { QString x = result; FrameLoaderClientQt* fl = static_cast<FrameLoaderClientQt*>(f->loader()->client()); bool rc = m_webPage->javaScriptPrompt(fl->webFrame(), (QString)message, (QString)defaultValue, &x); // Fix up a quirk in the QInputDialog class. If no input happened the string should be empty // but it is null. See https://bugs.webkit.org/show_bug.cgi?id=30914. if (rc && x.isNull()) result = String(""); else result = x; return rc; }
void MediaPlayerPrivate::load(const String& url) { // We are now loading if (m_networkState != MediaPlayer::Loading) { m_networkState = MediaPlayer::Loading; m_player->networkStateChanged(); } // And we don't have any data yet if (m_readyState != MediaPlayer::HaveNothing) { m_readyState = MediaPlayer::HaveNothing; m_player->readyStateChanged(); } const QUrl rUrl = QUrl(QString(url)); const QString scheme = rUrl.scheme().toLower(); // Grab the client media element HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_player->mediaPlayerClient()); // Construct the media content with a network request if the resource is http[s] if (scheme == "http" || scheme == "https") { QNetworkRequest request = QNetworkRequest(rUrl); // Grab the current document Document* document = element->document(); if (!document) document = element->ownerDocument(); // Grab the frame and network manager Frame* frame = document ? document->frame() : 0; FrameLoaderClientQt* frameLoader = frame ? static_cast<FrameLoaderClientQt*>(frame->loader()->client()) : 0; QNetworkAccessManager* manager = frameLoader ? frameLoader->webFrame()->page()->networkAccessManager() : 0; if (document && manager) { // Set the cookies QNetworkCookieJar* jar = manager->cookieJar(); QList<QNetworkCookie> cookies = jar->cookiesForUrl(rUrl); // Don't set the header if there are no cookies. // This prevents a warning from being emitted. if (!cookies.isEmpty()) request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies)); // Set the refferer, but not when requesting insecure content from a secure page QUrl documentUrl = QUrl(QString(document->documentURI())); if (documentUrl.scheme().toLower() == "http" || scheme == "https") request.setRawHeader("Referer", documentUrl.toEncoded()); // Set the user agent request.setRawHeader("User-Agent", frameLoader->userAgent(rUrl).utf8().data()); } m_mediaPlayer->setMedia(QMediaContent(request)); } else { // Otherwise, just use the URL m_mediaPlayer->setMedia(QMediaContent(rUrl)); } // Set the current volume and mute status // We get these from the element, rather than the player, in case we have // transitioned from a media engine which doesn't support muting, to a media // engine which does. m_mediaPlayer->setMuted(element->muted()); m_mediaPlayer->setVolume(static_cast<int>(element->volume() * 100.0)); }
bool ChromeClientQt::runJavaScriptConfirm(Frame* f, const String& msg) { QString x = msg; FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client()); return m_webPage->javaScriptConfirm(fl->webFrame(), x); }
void ChromeClientQt::runJavaScriptAlert(Frame* f, const String& msg) { QString x = msg; FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client()); m_webPage->javaScriptAlert(fl->webFrame(), x); }