本文整理汇总了C++中SecurityOrigin::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ SecurityOrigin::toString方法的具体用法?C++ SecurityOrigin::toString怎么用?C++ SecurityOrigin::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityOrigin
的用法示例。
在下文中一共展示了SecurityOrigin::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: originsMatch
// This function mimics the result of string comparison of serialized origins
bool originsMatch(const SecurityOrigin& origin1, const SecurityOrigin& origin2)
{
if (&origin1 == &origin2)
return true;
bool result = areOriginsMatching(origin1, origin2);
ASSERT(result == (origin1.toString() == origin2.toString()));
return result;
}
示例2: exceededDatabaseQuota
void ChromeClientBlackBerry::exceededDatabaseQuota(Frame* frame, const String& name, DatabaseDetails details)
{
#if ENABLE(SQL_DATABASE)
Document* document = frame->document();
if (!document)
return;
SecurityOrigin* origin = document->securityOrigin();
#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
if (m_webPagePrivate->m_dumpRenderTree) {
m_webPagePrivate->m_dumpRenderTree->exceededDatabaseQuota(origin, name);
return;
}
#endif
DatabaseManager& manager = DatabaseManager::manager();
unsigned long long originUsage = manager.usageForOrigin(origin);
unsigned long long currentQuota = manager.quotaForOrigin(origin);
unsigned long long estimatedSize = details.expectedUsage();
const String& nameStr = details.displayName();
String originStr = origin->toString();
unsigned long long quota = m_webPagePrivate->m_client->databaseQuota(originStr, nameStr, originUsage, currentQuota, estimatedSize);
manager.setQuota(origin, quota);
#endif
}
示例3: frameOrigin
static CString frameOrigin(Frame* frame)
{
DOMWindow* window = frame->domWindow();
SecurityOrigin* origin = window->securityOrigin();
CString latinOrigin = origin->toString().latin1();
return latinOrigin;
}
示例4: sendPing
// http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
void PingLoader::sendPing(Frame* frame, const KURL& pingURL, const KURL& destinationURL)
{
ResourceRequest request(pingURL);
#if PLATFORM(BLACKBERRY)
request.setTargetType(ResourceRequest::TargetIsSubresource);
#endif
request.setHTTPMethod("POST");
request.setHTTPContentType("text/ping");
request.setHTTPBody(FormData::create("PING"));
request.setHTTPHeaderField("Cache-Control", "max-age=0");
frame->loader()->addExtraFieldsToSubresourceRequest(request);
SecurityOrigin* sourceOrigin = frame->document()->securityOrigin();
RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL);
FrameLoader::addHTTPOriginIfNeeded(request, sourceOrigin->toString());
request.setHTTPHeaderField("Ping-To", destinationURL);
if (!SecurityPolicy::shouldHideReferrer(pingURL, frame->loader()->outgoingReferrer())) {
request.setHTTPHeaderField("Ping-From", frame->document()->url());
if (!sourceOrigin->isSameSchemeHostPort(pingOrigin.get())) {
String referrer = SecurityPolicy::generateReferrerHeader(frame->document()->referrerPolicy(), pingURL, frame->loader()->outgoingReferrer());
if (!referrer.isEmpty())
request.setHTTPReferrer(referrer);
}
}
OwnPtr<PingLoader> pingLoader = adoptPtr(new PingLoader(frame, request));
// Leak the ping loader, since it will kill itself as soon as it receives a response.
PingLoader* leakedPingLoader = pingLoader.leakPtr();
UNUSED_PARAM(leakedPingLoader);
}
示例5: requestPermission
void NotificationManager::requestPermission(ScriptExecutionContext* context, PassRefPtr<NotificationPermissionCallback> callback)
{
SecurityOrigin* origin = context->securityOrigin();
String requestID = createCanonicalUUIDString();
m_originToIDMap.set(origin, requestID);
m_idToOriginMap.set(requestID, origin);
m_idToCallbackMap.set(requestID, callback);
m_webPagePrivate->client()->requestNotificationPermission(requestID, origin->toString());
}
示例6: appendToFormData
void HTMLKeygenElement::appendToFormData(FormData& formData) {
// Only RSA is supported at this time.
const AtomicString& keyType = fastGetAttribute(keytypeAttr);
if (!keyType.isNull() && !equalIgnoringCase(keyType, "rsa"))
return;
SecurityOrigin* topOrigin =
document().frame()->tree().top()->securityContext()->getSecurityOrigin();
String value = Platform::current()->signedPublicKeyAndChallengeString(
shadowSelect()->selectedIndex(), fastGetAttribute(challengeAttr),
document().baseURL(), KURL(KURL(), topOrigin->toString()));
if (!value.isNull())
formData.append(name(), value);
}
示例7: toLocalFrame
void WindowProxy::setSecurityToken(SecurityOrigin* origin)
{
// If two tokens are equal, then the SecurityOrigins canAccess each other.
// If two tokens are not equal, then we have to call canAccess.
// Note: we can't use the HTTPOrigin if it was set from the DOM.
String token;
// There are several situations where v8 needs to do a full canAccess check,
// so set an empty security token instead:
// - document.domain was modified
// - the frame is showing the initial empty document
// - the frame is remote
bool delaySet = m_frame->isRemoteFrame() || (m_world->isMainWorld() && (origin->domainWasSetInDOM() || toLocalFrame(m_frame)->loader().stateMachine()->isDisplayingInitialEmptyDocument()));
if (origin && !delaySet)
token = origin->toString();
// An empty or "null" token means we always have to call
// canAccess. The toString method on securityOrigins returns the
// string "null" for empty security origins and for security
// origins that should only allow access to themselves. In this
// case, we use the global object as the security token to avoid
// calling canAccess when a script accesses its own objects.
v8::HandleScope handleScope(m_isolate);
v8::Local<v8::Context> context = m_scriptState->context();
if (token.isEmpty() || token == "null") {
context->UseDefaultSecurityToken();
return;
}
if (m_world->isPrivateScriptIsolatedWorld()) {
token = "private-script://" + token;
} else if (m_world->isIsolatedWorld()) {
SecurityOrigin* frameSecurityOrigin = m_frame->securityContext()->getSecurityOrigin();
String frameSecurityToken = frameSecurityOrigin->toString();
// We need to check the return value of domainWasSetInDOM() on the
// frame's SecurityOrigin because, if that's the case, only
// SecurityOrigin::m_domain would have been modified.
// m_domain is not used by SecurityOrigin::toString(), so we would end
// up generating the same token that was already set.
if (frameSecurityOrigin->domainWasSetInDOM() || frameSecurityToken.isEmpty() || frameSecurityToken == "null") {
context->UseDefaultSecurityToken();
return;
}
token = frameSecurityToken + token;
}
CString utf8Token = token.utf8();
// NOTE: V8 does identity comparison in fast path, must use a symbol
// as the security token.
context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8Token.length()));
}
示例8: addOriginAccessWhitelistEntry
void SecurityPolicy::addOriginAccessWhitelistEntry(const SecurityOrigin& sourceOrigin, const String& destinationProtocol, const String& destinationDomain, bool allowDestinationSubdomains)
{
ASSERT(isMainThread());
ASSERT(!sourceOrigin.isUnique());
if (sourceOrigin.isUnique())
return;
String sourceString = sourceOrigin.toString();
pair<OriginAccessMap::iterator, bool> result = originAccessMap().add(sourceString, nullptr);
if (result.second)
result.first->second = adoptPtr(new OriginAccessWhiteList);
OriginAccessWhiteList* list = result.first->second.get();
list->append(OriginAccessEntry(destinationProtocol, destinationDomain, allowDestinationSubdomains ? OriginAccessEntry::AllowSubdomains : OriginAccessEntry::DisallowSubdomains));
}
示例9: addOriginAccessWhitelistEntry
void SecurityPolicy::addOriginAccessWhitelistEntry(const SecurityOrigin& sourceOrigin, const String& destinationProtocol, const String& destinationDomain, bool allowDestinationSubdomains)
{
ASSERT(isMainThread());
ASSERT(!sourceOrigin.isUnique());
if (sourceOrigin.isUnique())
return;
String sourceString = sourceOrigin.toString();
OriginAccessMap::AddResult result = originAccessMap().add(sourceString, nullptr);
if (result.isNewEntry)
result.iterator->value = std::make_unique<OriginAccessWhiteList>();
OriginAccessWhiteList* list = result.iterator->value.get();
list->append(OriginAccessEntry(destinationProtocol, destinationDomain, allowDestinationSubdomains ? OriginAccessEntry::AllowSubdomains : OriginAccessEntry::DisallowSubdomains));
}
示例10: queryInfo
ScriptPromise StorageQuota::queryInfo(ExecutionContext* executionContext, String type)
{
ASSERT(executionContext);
ScriptPromise promise = ScriptPromise::createPending(executionContext);
RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promise, executionContext);
SecurityOrigin* securityOrigin = executionContext->securityOrigin();
if (securityOrigin->isUnique()) {
resolver->reject(DOMError::create(NotSupportedError));
return promise;
}
KURL storagePartition = KURL(KURL(), securityOrigin->toString());
blink::Platform::current()->queryStorageUsageAndQuota(storagePartition, stringToStorageQuotaType(type), WebStorageQuotaCallbacksImpl::createLeakedPtr(resolver, executionContext));
return promise;
}
示例11: removeOriginAccessWhitelistEntry
void SecurityPolicy::removeOriginAccessWhitelistEntry(const SecurityOrigin& sourceOrigin, const String& destinationProtocol, const String& destinationDomain, bool allowDestinationSubdomains)
{
ASSERT(isMainThread());
ASSERT(!sourceOrigin.isUnique());
if (sourceOrigin.isUnique())
return;
String sourceString = sourceOrigin.toString();
OriginAccessMap& map = originAccessMap();
OriginAccessMap::iterator it = map.find(sourceString);
if (it == map.end())
return;
OriginAccessWhiteList& list = *it->value;
OriginAccessEntry originAccessEntry(destinationProtocol, destinationDomain, allowDestinationSubdomains ? OriginAccessEntry::AllowSubdomains : OriginAccessEntry::DisallowSubdomains);
if (!list.removeFirst(originAccessEntry))
return;
if (list.isEmpty())
map.remove(it);
}
示例12: queryUsageAndQuota
void DeprecatedStorageQuota::queryUsageAndQuota(ExecutionContext* executionContext, PassOwnPtr<StorageUsageCallback> successCallback, PassOwnPtr<StorageErrorCallback> errorCallback)
{
ASSERT(executionContext);
blink::WebStorageQuotaType storageType = static_cast<blink::WebStorageQuotaType>(m_type);
if (storageType != blink::WebStorageQuotaTypeTemporary && storageType != blink::WebStorageQuotaTypePersistent) {
// Unknown storage type is requested.
executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
return;
}
SecurityOrigin* securityOrigin = executionContext->securityOrigin();
if (securityOrigin->isUnique()) {
executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
return;
}
KURL storagePartition = KURL(KURL(), securityOrigin->toString());
OwnPtr<StorageQuotaCallbacks> callbacks = DeprecatedStorageQuotaCallbacksImpl::create(successCallback, errorCallback);
blink::Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, callbacks.release());
}
示例13: removeOriginAccessWhitelistEntry
void SecurityPolicy::removeOriginAccessWhitelistEntry(const SecurityOrigin& sourceOrigin, const String& destinationProtocol, const String& destinationDomain, bool allowDestinationSubdomains)
{
ASSERT(isMainThread());
ASSERT(!sourceOrigin.isUnique());
if (sourceOrigin.isUnique())
return;
String sourceString = sourceOrigin.toString();
OriginAccessMap& map = originAccessMap();
OriginAccessMap::iterator it = map.find(sourceString);
if (it == map.end())
return;
OriginAccessWhiteList* list = it->second.get();
size_t index = list->find(OriginAccessEntry(destinationProtocol, destinationDomain, allowDestinationSubdomains ? OriginAccessEntry::AllowSubdomains : OriginAccessEntry::DisallowSubdomains));
if (index == notFound)
return;
list->remove(index);
if (list->isEmpty())
map.remove(it);
}
示例14: passesTimingAllowCheck
static bool passesTimingAllowCheck(
const ResourceResponse& response,
const SecurityOrigin& initiatorSecurityOrigin,
const AtomicString& originalTimingAllowOrigin,
ExecutionContext* context) {
RefPtr<SecurityOrigin> resourceOrigin =
SecurityOrigin::create(response.url());
if (resourceOrigin->isSameSchemeHostPort(&initiatorSecurityOrigin))
return true;
const AtomicString& timingAllowOriginString =
originalTimingAllowOrigin.isEmpty()
? response.httpHeaderField(HTTPNames::Timing_Allow_Origin)
: originalTimingAllowOrigin;
if (timingAllowOriginString.isEmpty() ||
equalIgnoringASCIICase(timingAllowOriginString, "null"))
return false;
if (timingAllowOriginString == "*") {
UseCounter::count(context, UseCounter::StarInTimingAllowOrigin);
return true;
}
const String& securityOrigin = initiatorSecurityOrigin.toString();
Vector<String> timingAllowOrigins;
timingAllowOriginString.getString().split(' ', timingAllowOrigins);
if (timingAllowOrigins.size() > 1)
UseCounter::count(context, UseCounter::MultipleOriginsInTimingAllowOrigin);
else if (timingAllowOrigins.size() == 1)
UseCounter::count(context, UseCounter::SingleOriginInTimingAllowOrigin);
for (const String& allowOrigin : timingAllowOrigins) {
if (allowOrigin == securityOrigin)
return true;
}
return false;
}
示例15: cancelUserMediaRequest
void UserMediaClientImpl::cancelUserMediaRequest(UserMediaRequest* request)
{
UserMediaRequestsMap::iterator it = userMediaRequestsMap().find(request);
if (it == userMediaRequestsMap().end())
return;
SecurityOrigin* origin = request->scriptExecutionContext()->securityOrigin();
m_page->client()->cancelUserMediaRequest(WebUserMediaRequest(request->audio(), request->video(), origin->toString(), it->value.get()));
userMediaRequestsMap().remove(it);
}