本文整理汇总了C++中SecurityOrigin类的典型用法代码示例。如果您正苦于以下问题:C++ SecurityOrigin类的具体用法?C++ SecurityOrigin怎么用?C++ SecurityOrigin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SecurityOrigin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void EventSource::connect()
{
ASSERT(m_state == CONNECTING);
ASSERT(!m_requestInFlight);
ResourceRequest request(m_url);
request.setHTTPMethod("GET");
request.setHTTPHeaderField("Accept", "text/event-stream");
request.setHTTPHeaderField("Cache-Control", "no-cache");
if (!m_lastEventId.isEmpty())
request.setHTTPHeaderField("Last-Event-ID", m_lastEventId);
SecurityOrigin* origin = executionContext()->securityOrigin();
ThreadableLoaderOptions options;
options.sniffContent = DoNotSniffContent;
options.allowCredentials = (origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
options.credentialsRequested = m_withCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials;
options.preflightPolicy = PreventPreflight;
options.crossOriginRequestPolicy = UseAccessControl;
options.dataBufferingPolicy = DoNotBufferData;
options.securityOrigin = origin;
options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPolicy : EnforceConnectSrcDirective;
m_loader = ThreadableLoader::create(executionContext(), this, request, options);
if (m_loader)
m_requestInFlight = true;
}
示例2: ENABLE
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: webkitResolveLocalFileSystemURL
void DOMWindowFileSystem::webkitResolveLocalFileSystemURL(DOMWindow* window, const String& url, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
{
if (!window->isCurrentlyDisplayedInFrame())
return;
Document* document = window->document();
if (!document)
return;
SecurityOrigin* securityOrigin = document->securityOrigin();
KURL completedURL = document->completeURL(url);
if (!securityOrigin->canAccessFileSystem() || !securityOrigin->canRequest(completedURL)) {
DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
return;
}
FileSystemType type;
String filePath;
if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) {
DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::ENCODING_ERR));
return;
}
LocalFileSystem::from(document)->readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, type, filePath));
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:25,代码来源:DOMWindowFileSystem.cpp
示例5: ASSERT
void EventSource::connect()
{
ASSERT(m_state == CONNECTING);
ASSERT(!m_requestInFlight);
ASSERT(executionContext());
ExecutionContext& executionContext = *this->executionContext();
ResourceRequest request(m_url);
request.setHTTPMethod("GET");
request.setHTTPHeaderField("Accept", "text/event-stream");
request.setHTTPHeaderField("Cache-Control", "no-cache");
request.setRequestContext(WebURLRequest::RequestContextEventSource);
if (!m_lastEventId.isEmpty())
request.setHTTPHeaderField("Last-Event-ID", m_lastEventId);
SecurityOrigin* origin = executionContext.securityOrigin();
ThreadableLoaderOptions options;
options.preflightPolicy = PreventPreflight;
options.crossOriginRequestPolicy = UseAccessControl;
options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypassMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConnectSrcDirective;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = (origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
resourceLoaderOptions.credentialsRequested = m_withCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials;
resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
resourceLoaderOptions.securityOrigin = origin;
InspectorInstrumentation::willSendEventSourceRequest(&executionContext, this);
// InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient will be called synchronously.
m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions);
if (m_loader)
m_requestInFlight = true;
}
示例6: ASSERT
void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName, DatabaseDetails details)
{
WebFrame* webFrame = WebFrame::fromCoreFrame(*frame);
ASSERT(webFrame);
SecurityOrigin* origin = frame->document()->securityOrigin();
DatabaseManager& dbManager = DatabaseManager::singleton();
uint64_t currentQuota = dbManager.quotaForOrigin(origin);
uint64_t currentOriginUsage = dbManager.usageForOrigin(origin);
uint64_t newQuota = 0;
RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(WebCore::SecurityOrigin::createFromDatabaseIdentifier(origin->databaseIdentifier()));
newQuota = m_page->injectedBundleUIClient().didExceedDatabaseQuota(m_page, securityOrigin.get(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage());
if (!newQuota) {
unsigned syncSendFlags = IPC::InformPlatformProcessWillSuspend;
if (WebPage::synchronousMessagesShouldSpinRunLoop())
syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
WebProcess::singleton().parentProcessConnection()->sendSync(
Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID(), std::chrono::milliseconds::max(), syncSendFlags);
}
dbManager.setQuota(origin, newQuota);
}
示例7: ASSERT
void V8DOMWindowShell::setSecurityToken()
{
ASSERT(m_world->isMainWorld());
Document* document = m_frame->document();
// Ask the document's SecurityOrigin to generate a security token.
// 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.
SecurityOrigin* origin = document->securityOrigin();
String token;
if (!origin->domainWasSetInDOM())
token = document->securityOrigin()->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.
if (token.isEmpty() || token == "null") {
m_context->UseDefaultSecurityToken();
return;
}
CString utf8Token = token.utf8();
// NOTE: V8 does identity comparison in fast path, must use a symbol
// as the security token.
m_context->SetSecurityToken(v8::String::NewSymbol(utf8Token.data(), utf8Token.length()));
}
示例8: canAccessAncestor
static bool canAccessAncestor(const SecurityOrigin& activeSecurityOrigin,
const Frame* targetFrame) {
// targetFrame can be 0 when we're trying to navigate a top-level frame
// that has a 0 opener.
if (!targetFrame)
return false;
const bool isLocalActiveOrigin = activeSecurityOrigin.isLocal();
for (const Frame* ancestorFrame = targetFrame; ancestorFrame;
ancestorFrame = ancestorFrame->tree().parent()) {
const SecurityOrigin* ancestorSecurityOrigin =
ancestorFrame->securityContext()->getSecurityOrigin();
if (activeSecurityOrigin.canAccess(ancestorSecurityOrigin))
return true;
// Allow file URL descendant navigation even when
// allowFileAccessFromFileURLs is false.
// FIXME: It's a bit strange to special-case local origins here. Should we
// be doing something more general instead?
if (isLocalActiveOrigin && ancestorSecurityOrigin->isLocal())
return true;
}
return false;
}
示例9: request
// 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);
}
示例10: ASSERT
void EventSource::connect()
{
ASSERT(m_state == CONNECTING);
ASSERT(!m_requestInFlight);
ResourceRequest request(m_url);
request.setHTTPMethod("GET");
request.setHTTPHeaderField("Accept", "text/event-stream");
request.setHTTPHeaderField("Cache-Control", "no-cache");
if (!m_lastEventId.isEmpty())
request.setHTTPHeaderField("Last-Event-ID", m_lastEventId);
SecurityOrigin* origin = scriptExecutionContext()->securityOrigin();
ThreadableLoaderOptions options;
options.sendLoadCallbacks = SendCallbacks;
options.sniffContent = DoNotSniffContent;
options.allowCredentials = (origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
options.preflightPolicy = PreventPreflight;
options.crossOriginRequestPolicy = UseAccessControl;
options.dataBufferingPolicy = DoNotBufferData;
options.securityOrigin = origin;
m_loader = ThreadableLoader::create(scriptExecutionContext(), this, request, options);
if (m_loader)
m_requestInFlight = true;
}
示例11: ENABLE
void ChromeClientBlackBerry::exceededDatabaseQuota(Frame* frame, const String& name)
{
#if ENABLE(SQL_DATABASE)
Document* document = frame->document();
if (!document)
return;
SecurityOrigin* origin = document->securityOrigin();
#if ENABLE_DRT
if (m_webPagePrivate->m_dumpRenderTree) {
m_webPagePrivate->m_dumpRenderTree->exceededDatabaseQuota(origin, name);
return;
}
#endif
DatabaseTracker& tracker = DatabaseTracker::tracker();
unsigned long long totalUsage = tracker.totalDatabaseUsage();
unsigned long long originUsage = tracker.usageForOrigin(origin);
DatabaseDetails details = tracker.detailsForNameAndOrigin(name, origin);
unsigned long long estimatedSize = details.expectedUsage();
const String& nameStr = details.displayName();
String originStr = origin->databaseIdentifier();
unsigned long long quota = m_webPagePrivate->m_client->databaseQuota(originStr.characters(), originStr.length(),
nameStr.characters(), nameStr.length(), totalUsage, originUsage, estimatedSize);
tracker.setQuota(origin, quota);
#endif
}
示例12: ASSERT
FetchRequest PreloadRequest::resourceRequest(Document* document)
{
ASSERT(isMainThread());
FetchInitiatorInfo initiatorInfo;
initiatorInfo.name = AtomicString(m_initiatorName);
initiatorInfo.position = m_initiatorPosition;
ResourceRequest resourceRequest(completeURL(document));
resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer(m_referrerPolicy, resourceRequest.url(), document->outgoingReferrer()));
FetchRequest request(resourceRequest, initiatorInfo);
if (m_resourceType == Resource::ImportResource) {
SecurityOrigin* securityOrigin = document->contextDocument()->securityOrigin();
bool sameOrigin = securityOrigin->canRequest(request.url());
request.setCrossOriginAccessControl(securityOrigin,
sameOrigin ? AllowStoredCredentials : DoNotAllowStoredCredentials,
ClientDidNotRequestCredentials);
}
if (m_isCORSEnabled)
request.setCrossOriginAccessControl(document->securityOrigin(), m_allowCredentials);
request.setDefer(m_defer);
request.setResourceWidth(m_resourceWidth);
request.clientHintsPreferences().updateFrom(m_clientHintsPreferences);
return request;
}
示例13: countDeprecationCrossOriginIframe
void Deprecation::countDeprecationCrossOriginIframe(const LocalFrame* frame, UseCounter::Feature feature)
{
// Check to see if the frame can script into the top level document.
SecurityOrigin* securityOrigin = frame->securityContext()->getSecurityOrigin();
Frame* top = frame->tree().top();
if (top && !securityOrigin->canAccess(top->securityContext()->getSecurityOrigin()))
countDeprecation(frame, feature);
}
示例14: 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());
}
示例15: matchesOrigin
OriginAccessEntry::MatchResult OriginAccessEntry::matchesOrigin(const SecurityOrigin& origin) const
{
ASSERT(origin.protocol() == origin.protocol().lower());
if (m_protocol != origin.protocol())
return DoesNotMatchOrigin;
return matchesDomain(origin);
}