本文整理汇总了C++中KURL函数的典型用法代码示例。如果您正苦于以下问题:C++ KURL函数的具体用法?C++ KURL怎么用?C++ KURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KURL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(CSPSourceTest, InsecureHostSchemePortMatchesSecurePort) {
KURL base;
CSPSource source(csp.get(), "http", "example.com", 80, "/",
CSPSource::NoWildcard, CSPSource::NoWildcard);
EXPECT_TRUE(source.matches(KURL(base, "http://example.com/")));
EXPECT_TRUE(source.matches(KURL(base, "http://example.com:80/")));
EXPECT_TRUE(source.matches(KURL(base, "http://example.com:443/")));
EXPECT_TRUE(source.matches(KURL(base, "https://example.com/")));
EXPECT_TRUE(source.matches(KURL(base, "https://example.com:80/")));
EXPECT_TRUE(source.matches(KURL(base, "https://example.com:443/")));
EXPECT_FALSE(source.matches(KURL(base, "http://example.com:8443/")));
EXPECT_FALSE(source.matches(KURL(base, "https://example.com:8443/")));
EXPECT_FALSE(source.matches(KURL(base, "http://not-example.com/")));
EXPECT_FALSE(source.matches(KURL(base, "http://not-example.com:80/")));
EXPECT_FALSE(source.matches(KURL(base, "http://not-example.com:443/")));
EXPECT_FALSE(source.matches(KURL(base, "https://not-example.com/")));
EXPECT_FALSE(source.matches(KURL(base, "https://not-example.com:80/")));
EXPECT_FALSE(source.matches(KURL(base, "https://not-example.com:443/")));
}
示例2: kdDebug
void PakProtocol::get(const KURL &url) {
kdDebug(PAK_DEBUG_ID) << "ArchiveProtocol::get " << url << endl;
QString path;
KIO::Error errorNum;
if ( !checkNewFile( url, path, errorNum ) )
{
if ( errorNum == KIO::ERR_CANNOT_OPEN_FOR_READING )
{
// If we cannot open, it might be a problem with the archive header (e.g. unsupported format)
// Therefore give a more specific error message
error( KIO::ERR_SLAVE_DEFINED,
i18n( "Could not open the file, probably due to an unsupported file format.\n%1")
.arg( url.prettyURL() ) );
return;
}
else
{
// We have any other error
error( errorNum, url.prettyURL() );
return;
}
}
kdDebug(PAK_DEBUG_ID) << "Continue getting" << endl;
path = QString::fromLocal8Bit(remoteEncoding()->encode(path));
kdDebug(PAK_DEBUG_ID) << "Path > " << path << endl;
const KArchiveDirectory* root = _pakFile->directory();
const KArchiveEntry* archiveEntry = root->entry( path );
kdDebug(PAK_DEBUG_ID) << "Check if no archiveEntry > " << archiveEntry << endl;
if ( !archiveEntry )
{
error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
return;
}
kdDebug(PAK_DEBUG_ID) << "archiveEntry::name > " << archiveEntry->name() << endl;
if ( archiveEntry->isDirectory() )
{
error( KIO::ERR_IS_DIRECTORY, url.prettyURL() );
return;
}
const KArchiveFile* archiveFileEntry = static_cast<const KArchiveFile *>(archiveEntry);
if ( !archiveEntry->symlink().isEmpty() )
{
kdDebug(7109) << "Redirection to " << archiveEntry->symlink() << endl;
KURL realURL;
if (archiveEntry->symlink().startsWith("/")) { // absolute path
realURL.setPath(archiveEntry->symlink() ); // goes out of tar:/, back into file:
} else {
realURL = KURL( url, archiveEntry->symlink() );
}
kdDebug(7109) << "realURL= " << realURL << endl;
redirection( realURL );
finished();
return;
}
//kdDebug(7109) << "Preparing to get the archive data" << endl;
/*
* The easy way would be to get the data by calling archiveFileEntry->data()
* However this has drawbacks:
* - the complete file must be read into the memory
* - errors are skipped, resulting in an empty file
*/
QIODevice* io = 0;
// Getting the device is hard, as archiveFileEntry->device() is not virtual!
if ( url.protocol() == "pak" )
{
io = archiveFileEntry->device();
}
else
{
// Wrong protocol? Why was this not catched by checkNewFile?
kdWarning(7109) << "Protocol " << url.protocol() << " not supported by this IOSlave; " << k_funcinfo << endl;
error( KIO::ERR_UNSUPPORTED_PROTOCOL, url.protocol() );
return;
}
if (!io)
{
error( KIO::ERR_SLAVE_DEFINED,
i18n( "The archive file could not be opened, perhaps because the format is unsupported.\n%1" )
.arg( url.prettyURL() ) );
return;
}
if ( !io->open( IO_ReadOnly ) )
{
error( KIO::ERR_CANNOT_OPEN_FOR_READING, url.prettyURL() );
return;
}
totalSize( archiveFileEntry->size() );
// Size of a QIODevice read. It must be large enough so that the mime type check will not fail
const int maxSize = 0x100000; // 1MB
//.........这里部分代码省略.........
示例3: FrameFetchContextUpgradeTest
FrameFetchContextUpgradeTest()
: exampleOrigin(SecurityOrigin::create(KURL(ParsedURLString, "https://example.test/")))
, secureOrigin(SecurityOrigin::create(KURL(ParsedURLString, "https://secureorigin.test/image.png")))
{
}
示例4: KURL
KURL HistoryItem::url() const
{
return KURL(m_urlString);
}
示例5: KURL
KURL HistoryItem::originalURL() const
{
return KURL(ParsedURLString, m_originalURLString);
}
示例6: createResource
static PassRefPtr<ArchiveResource> createResource(CFDictionaryRef dictionary)
{
ASSERT(dictionary);
if (!dictionary)
return 0;
CFDataRef resourceData = static_cast<CFDataRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceDataKey));
if (resourceData && CFGetTypeID(resourceData) != CFDataGetTypeID()) {
LOG(Archives, "LegacyWebArchive - Resource data is not of type CFData, cannot create invalid resource");
return 0;
}
CFStringRef frameName = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceFrameNameKey));
if (frameName && CFGetTypeID(frameName) != CFStringGetTypeID()) {
LOG(Archives, "LegacyWebArchive - Frame name is not of type CFString, cannot create invalid resource");
return 0;
}
CFStringRef mimeType = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceMIMETypeKey));
if (mimeType && CFGetTypeID(mimeType) != CFStringGetTypeID()) {
LOG(Archives, "LegacyWebArchive - MIME type is not of type CFString, cannot create invalid resource");
return 0;
}
CFStringRef url = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceURLKey));
if (url && CFGetTypeID(url) != CFStringGetTypeID()) {
LOG(Archives, "LegacyWebArchive - URL is not of type CFString, cannot create invalid resource");
return 0;
}
CFStringRef textEncoding = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceTextEncodingNameKey));
if (textEncoding && CFGetTypeID(textEncoding) != CFStringGetTypeID()) {
LOG(Archives, "LegacyWebArchive - Text encoding is not of type CFString, cannot create invalid resource");
return 0;
}
ResourceResponse response;
CFDataRef resourceResponseData = static_cast<CFDataRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceResponseKey));
if (resourceResponseData) {
if (CFGetTypeID(resourceResponseData) != CFDataGetTypeID()) {
LOG(Archives, "LegacyWebArchive - Resource response data is not of type CFData, cannot create invalid resource");
return 0;
}
CFStringRef resourceResponseVersion = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary, LegacyWebArchiveResourceResponseVersionKey));
if (resourceResponseVersion && CFGetTypeID(resourceResponseVersion) != CFStringGetTypeID()) {
LOG(Archives, "LegacyWebArchive - Resource response version is not of type CFString, cannot create invalid resource");
return 0;
}
response = createResourceResponseFromPropertyListData(resourceResponseData, resourceResponseVersion);
}
return ArchiveResource::create(SharedBuffer::create(CFDataGetBytePtr(resourceData), CFDataGetLength(resourceData)), KURL(url), mimeType, textEncoding, frameName, response);
}
示例7: ASSERT
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Frame* frame, Vector<Node*>& nodes)
{
ASSERT(frame);
const ResourceResponse& response = frame->loader()->documentLoader()->response();
KURL responseURL = response.url();
// it's possible to have a response without a URL here
// <rdar://problem/5454935>
if (responseURL.isNull())
responseURL = KURL("");
PassRefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame->tree()->name());
Vector<PassRefPtr<LegacyWebArchive> > subframeArchives;
Vector<PassRefPtr<ArchiveResource> > subresources;
HashSet<KURL> uniqueSubresources;
Vector<Node*>::iterator it = nodes.begin();
Vector<Node*>::iterator end = nodes.end();
for (; it != end; ++it) {
Frame* childFrame;
if (((*it)->hasTagName(HTMLNames::frameTag) || (*it)->hasTagName(HTMLNames::iframeTag) || (*it)->hasTagName(HTMLNames::objectTag)) &&
(childFrame = static_cast<HTMLFrameOwnerElement*>(*it)->contentFrame())) {
RefPtr<LegacyWebArchive> subframeArchive;
if (Document* document = childFrame->document())
subframeArchive = LegacyWebArchive::create(document);
else
subframeArchive = create(childFrame);
if (subframeArchive)
subframeArchives.append(subframeArchive);
else
LOG_ERROR("Unabled to archive subframe %s", childFrame->tree()->name().string().utf8().data());
} else {
ListHashSet<KURL> subresourceURLs;
(*it)->getSubresourceURLs(subresourceURLs);
DocumentLoader* documentLoader = frame->loader()->documentLoader();
ListHashSet<KURL>::iterator iterEnd = subresourceURLs.end();
for (ListHashSet<KURL>::iterator iter = subresourceURLs.begin(); iter != iterEnd; ++iter) {
const KURL& subresourceURL = *iter;
if (uniqueSubresources.contains(subresourceURL))
continue;
uniqueSubresources.add(subresourceURL);
RefPtr<ArchiveResource> resource = documentLoader->subresource(subresourceURL);
if (resource) {
subresources.append(resource.release());
continue;
}
CachedResource *cachedResource = cache()->resourceForURL(subresourceURL);
if (cachedResource) {
resource = ArchiveResource::create(cachedResource->data(), subresourceURL, cachedResource->response());
if (resource) {
subresources.append(resource.release());
continue;
}
}
// FIXME: should do something better than spew to console here
LOG_ERROR("Failed to archive subresource for %s", subresourceURL.string().utf8().data());
}
}
}
// Add favicon if one exists for this page
if (iconDatabase() && iconDatabase()->isEnabled()) {
const String& iconURL = iconDatabase()->iconURLForPageURL(responseURL);
if (!iconURL.isEmpty() && iconDatabase()->iconDataKnownForIconURL(iconURL)) {
if (Image* iconImage = iconDatabase()->iconForPageURL(responseURL, IntSize(16, 16))) {
RefPtr<ArchiveResource> resource = ArchiveResource::create(iconImage->data(), KURL(iconURL), "image/x-icon", "", "");
subresources.append(resource.release());
}
}
}
return create(mainResource, subresources, subframeArchives);
}
示例8: String
String Navigator::userAgent() const
{
if (!m_frame)
return String();
return m_frame->loader()->userAgent(m_frame->document() ? m_frame->document()->url() : KURL());
}
示例9: ASSERT
void WebSharedWorkerImpl::initializeLoader(const WebURL& url)
{
// Create 'shadow page'. This page is never displayed, it is used to proxy the
// loading requests from the worker context to the rest of WebKit and Chromium
// infrastructure.
ASSERT(!m_webView);
m_webView = WebView::create(0);
m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled());
// FIXME: Settings information should be passed to the Worker process from Browser process when the worker
// is created (similar to RenderThread::OnCreateNewView).
m_mainFrame = WebFrame::create(this);
m_webView->setMainFrame(m_mainFrame);
WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame());
// Construct substitute data source for the 'shadow page'. We only need it
// to have same origin as the worker so the loading checks work correctly.
CString content("");
int length = static_cast<int>(content.length());
RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length));
webFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(url), SubstituteData(buffer, "text/html", "UTF-8", KURL())));
// This document will be used as 'loading context' for the worker.
m_loadingDocument = webFrame->frame()->document();
}
示例10: KURL
PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)
{
RefPtr<Document> ownerDocument = &sourceNode->document();
bool sourceIsDocument = (sourceNode == ownerDocument.get());
String documentSource = sourceString;
RefPtr<Document> result;
if (sourceMIMEType == "text/plain") {
result = Document::create(DocumentInit(sourceIsDocument ? ownerDocument->url() : KURL(), frame));
transformTextStringToXHTMLDocumentString(documentSource);
} else
result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : KURL(), false);
// Before parsing, we need to save & detach the old document and get the new document
// in place. We have to do this only if we're rendering the result document.
if (frame) {
if (FrameView* view = frame->view())
view->clear();
if (Document* oldDocument = frame->document()) {
result->setTransformSourceDocument(oldDocument);
result->setSecurityOrigin(oldDocument->securityOrigin());
result->setCookieURL(oldDocument->cookieURL());
result->contentSecurityPolicy()->copyStateFrom(oldDocument->contentSecurityPolicy());
}
frame->domWindow()->setDocument(result);
}
result->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : WTF::TextEncoding(sourceEncoding));
result->setContent(documentSource);
return result.release();
}
示例11: typeMismatchFor
bool URLInputType::typeMismatchFor(const String& value) const
{
return !value.isEmpty() && !KURL(KURL(), value).isValid();
}
示例12: KURL
StyleCachedImage* CSSImageValue::cachedImage(DocLoader* loader, const String& url)
{
if (!m_accessedImage) {
m_accessedImage = true;
CachedImage* cachedImage = 0;
if (loader)
cachedImage = loader->requestImage(url);
else {
// FIXME: Should find a way to make these images sit in their own memory partition, since they are user agent images.
cachedImage = static_cast<CachedImage*>(cache()->requestResource(0, CachedResource::ImageResource, KURL(ParsedURLString, url), String()));
}
if (cachedImage) {
cachedImage->addClient(this);
m_image = StyleCachedImage::create(cachedImage);
}
}
return m_image.get();
}
示例13: if
PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionState& exceptionState)
{
if (configuration.isUndefinedOrNull())
return nullptr;
ArrayValue iceServers;
bool ok = configuration.get("iceServers", iceServers);
if (!ok || iceServers.isUndefinedOrNull()) {
exceptionState.throwTypeError("Malformed RTCConfiguration");
return nullptr;
}
size_t numberOfServers;
ok = iceServers.length(numberOfServers);
if (!ok) {
exceptionState.throwTypeError("Malformed RTCConfiguration");
return nullptr;
}
RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();
for (size_t i = 0; i < numberOfServers; ++i) {
Dictionary iceServer;
ok = iceServers.get(i, iceServer);
if (!ok) {
exceptionState.throwTypeError("Malformed RTCIceServer");
return nullptr;
}
Vector<String> names;
iceServer.getOwnPropertyNames(names);
Vector<String> urlStrings;
if (names.contains("urls")) {
if (!iceServer.get("urls", urlStrings) || !urlStrings.size()) {
String urlString;
if (iceServer.get("urls", urlString)) {
urlStrings.append(urlString);
} else {
exceptionState.throwTypeError("Malformed RTCIceServer");
return nullptr;
}
}
} else if (names.contains("url")) {
String urlString;
if (iceServer.get("url", urlString)) {
urlStrings.append(urlString);
} else {
exceptionState.throwTypeError("Malformed RTCIceServer");
return nullptr;
}
} else {
exceptionState.throwTypeError("Malformed RTCIceServer");
return nullptr;
}
String username, credential;
iceServer.get("username", username);
iceServer.get("credential", credential);
for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStrings.end(); ++iter) {
KURL url(KURL(), *iter);
if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("turns") || url.protocolIs("stun"))) {
exceptionState.throwTypeError("Malformed URL");
return nullptr;
}
rtcConfiguration->appendServer(RTCIceServer::create(url, username, credential));
}
}
return rtcConfiguration.release();
}
示例14: WTF_LOG
void WebSocket::connect(const String& url, const Vector<String>& protocols, ExceptionState& exceptionState)
{
WTF_LOG(Network, "WebSocket %p connect() url='%s'", this, url.utf8().data());
m_url = KURL(KURL(), url);
if (!m_url.isValid()) {
m_state = CLOSED;
exceptionState.throwDOMException(SyntaxError, "The URL '" + url + "' is invalid.");
return;
}
if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) {
m_state = CLOSED;
exceptionState.throwDOMException(SyntaxError, "The URL's scheme must be either 'ws' or 'wss'. '" + m_url.protocol() + "' is not allowed.");
return;
}
if (MixedContentChecker::isMixedContent(executionContext()->securityOrigin(), m_url)) {
// FIXME: Throw an exception and close the connection.
String message = "Connecting to a non-secure WebSocket server from a secure origin is deprecated.";
executionContext()->addConsoleMessage(JSMessageSource, WarningMessageLevel, message);
}
if (m_url.hasFragmentIdentifier()) {
m_state = CLOSED;
exceptionState.throwDOMException(SyntaxError, "The URL contains a fragment identifier ('" + m_url.fragmentIdentifier() + "'). Fragment identifiers are not allowed in WebSocket URLs.");
return;
}
if (!portAllowed(m_url)) {
m_state = CLOSED;
exceptionState.throwSecurityError("The port " + String::number(m_url.port()) + " is not allowed.");
return;
}
// FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
bool shouldBypassMainWorldContentSecurityPolicy = false;
if (executionContext()->isDocument()) {
Document* document = toDocument(executionContext());
shouldBypassMainWorldContentSecurityPolicy = document->frame()->script().shouldBypassMainWorldContentSecurityPolicy();
}
if (!shouldBypassMainWorldContentSecurityPolicy && !executionContext()->contentSecurityPolicy()->allowConnectToSource(m_url)) {
m_state = CLOSED;
// The URL is safe to expose to JavaScript, as this check happens synchronously before redirection.
exceptionState.throwSecurityError("Refused to connect to '" + m_url.elidedString() + "' because it violates the document's Content Security Policy.");
return;
}
m_channel = WebSocketChannel::create(executionContext(), this);
// FIXME: There is a disagreement about restriction of subprotocols between WebSocket API and hybi-10 protocol
// draft. The former simply says "only characters in the range U+0021 to U+007E are allowed," while the latter
// imposes a stricter rule: "the elements MUST be non-empty strings with characters as defined in [RFC2616],
// and MUST all be unique strings."
//
// Here, we throw SyntaxError if the given protocols do not meet the latter criteria. This behavior does not
// comply with WebSocket API specification, but it seems to be the only reasonable way to handle this conflict.
for (size_t i = 0; i < protocols.size(); ++i) {
if (!isValidProtocolString(protocols[i])) {
m_state = CLOSED;
exceptionState.throwDOMException(SyntaxError, "The subprotocol '" + encodeProtocolString(protocols[i]) + "' is invalid.");
releaseChannel();
return;
}
}
HashSet<String> visited;
for (size_t i = 0; i < protocols.size(); ++i) {
if (!visited.add(protocols[i]).isNewEntry) {
m_state = CLOSED;
exceptionState.throwDOMException(SyntaxError, "The subprotocol '" + encodeProtocolString(protocols[i]) + "' is duplicated.");
releaseChannel();
return;
}
}
String protocolString;
if (!protocols.isEmpty())
protocolString = joinStrings(protocols, subProtocolSeperator());
m_channel->connect(m_url, protocolString);
}
示例15: KURL
PassRefPtr<DOMFileSystem> InspectorFrontendHost::isolatedFileSystem(const String& fileSystemName, const String& rootURL)
{
ScriptExecutionContext* context = m_frontendPage->mainFrame()->document();
return DOMFileSystem::create(context, fileSystemName, FileSystemTypeIsolated, KURL(ParsedURLString, rootURL), AsyncFileSystem::create());
}