本文整理汇总了C++中PrincipalInfo::type方法的典型用法代码示例。如果您正苦于以下问题:C++ PrincipalInfo::type方法的具体用法?C++ PrincipalInfo::type怎么用?C++ PrincipalInfo::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrincipalInfo
的用法示例。
在下文中一共展示了PrincipalInfo::type方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnregisterServiceWorkerCallback
bool
ServiceWorkerManagerParent::RecvUnregister(const PrincipalInfo& aPrincipalInfo,
const nsString& aScope)
{
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
// Basic validation.
if (aScope.IsEmpty() ||
aPrincipalInfo.type() == PrincipalInfo::TNullPrincipalInfo ||
aPrincipalInfo.type() == PrincipalInfo::TSystemPrincipalInfo) {
return false;
}
nsRefPtr<UnregisterServiceWorkerCallback> callback =
new UnregisterServiceWorkerCallback(aPrincipalInfo, aScope);
nsRefPtr<ContentParent> parent =
BackgroundParent::GetContentParent(Manager());
// If the ContentParent is null we are dealing with a same-process actor.
if (!parent) {
callback->Run();
return true;
}
nsRefPtr<CheckPrincipalWithCallbackRunnable> runnable =
new CheckPrincipalWithCallbackRunnable(parent.forget(), aPrincipalInfo,
callback);
nsresult rv = NS_DispatchToMainThread(runnable);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv));
return true;
}
示例2: principalInfo
// static
nsresult
IDBFactory::CreateForWorker(JSContext* aCx,
JS::Handle<JSObject*> aOwningObject,
const PrincipalInfo& aPrincipalInfo,
uint64_t aInnerWindowID,
IDBFactory** aFactory)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::T__None);
nsAutoPtr<PrincipalInfo> principalInfo(new PrincipalInfo(aPrincipalInfo));
nsresult rv =
CreateForJSInternal(aCx,
aOwningObject,
principalInfo,
aInnerWindowID,
aFactory);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
MOZ_ASSERT(!principalInfo);
return NS_OK;
}
示例3: CheckPrincipalRunnable
bool
BackgroundParentImpl::RecvPBroadcastChannelConstructor(
PBroadcastChannelParent* actor,
const PrincipalInfo& aPrincipalInfo,
const nsString& aOrigin,
const nsString& aChannel,
const bool& aPrivateBrowsing)
{
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
nsRefPtr<ContentParent> parent = BackgroundParent::GetContentParent(this);
// If the ContentParent is null we are dealing with a same-process actor.
if (!parent) {
MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::TNullPrincipalInfo);
return true;
}
nsRefPtr<CheckPrincipalRunnable> runnable =
new CheckPrincipalRunnable(parent.forget(), aPrincipalInfo, aOrigin);
nsresult rv = NS_DispatchToMainThread(runnable);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv));
return true;
}
示例4: PrincipalInfoToPrincipal
nsresult
ParentRunnable::InitOnMainThread()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mState == eInitial);
MOZ_ASSERT(mPrincipalInfo.type() != PrincipalInfo::TNullPrincipalInfo);
nsresult rv;
nsCOMPtr<nsIPrincipal> principal =
PrincipalInfoToPrincipal(mPrincipalInfo, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup,
&mOrigin);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例5: CheckedPrincipalToPrincipalInfo
nsresult CheckedPrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
PrincipalInfo& aPrincipalInfo) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
nsresult rv = PrincipalToPrincipalInfo(aPrincipal, &aPrincipalInfo);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(aPrincipalInfo))) {
return NS_ERROR_FAILURE;
}
if (aPrincipalInfo.type() != PrincipalInfo::TContentPrincipalInfo &&
aPrincipalInfo.type() != PrincipalInfo::TSystemPrincipalInfo) {
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
示例6: mService
BroadcastChannelParent::BroadcastChannelParent(
const PrincipalInfo& aPrincipalInfo,
const nsACString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing)
: mService(BroadcastChannelService::GetOrCreate())
, mOrigin(aOrigin)
, mChannel(aChannel)
, mAppId(nsIScriptSecurityManager::UNKNOWN_APP_ID)
, mIsInBrowserElement(false)
, mPrivateBrowsing(aPrivateBrowsing)
{
AssertIsOnBackgroundThread();
mService->RegisterActor(this);
if (aPrincipalInfo.type() ==PrincipalInfo::TContentPrincipalInfo) {
const ContentPrincipalInfo& info =
aPrincipalInfo.get_ContentPrincipalInfo();
mAppId = info.appId();
mIsInBrowserElement = info.isInBrowserElement();
}
}
示例7: switch
already_AddRefed<nsIPrincipal>
PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo,
nsresult* aOptionalResult)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::T__None);
nsresult stackResult;
nsresult& rv = aOptionalResult ? *aOptionalResult : stackResult;
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
nsCOMPtr<nsIPrincipal> principal;
switch (aPrincipalInfo.type()) {
case PrincipalInfo::TSystemPrincipalInfo: {
rv = secMan->GetSystemPrincipal(getter_AddRefs(principal));
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
return principal.forget();
}
case PrincipalInfo::TNullPrincipalInfo: {
const NullPrincipalInfo& info =
aPrincipalInfo.get_NullPrincipalInfo();
principal = nsNullPrincipal::Create(info.attrs());
return principal.forget();
}
case PrincipalInfo::TContentPrincipalInfo: {
const ContentPrincipalInfo& info =
aPrincipalInfo.get_ContentPrincipalInfo();
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), info.spec());
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
PrincipalOriginAttributes attrs;
if (info.attrs().mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
attrs = info.attrs();
}
principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
rv = principal ? NS_OK : NS_ERROR_FAILURE;
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
return principal.forget();
}
case PrincipalInfo::TExpandedPrincipalInfo: {
const ExpandedPrincipalInfo& info = aPrincipalInfo.get_ExpandedPrincipalInfo();
nsTArray<nsCOMPtr<nsIPrincipal>> whitelist;
nsCOMPtr<nsIPrincipal> wlPrincipal;
for (uint32_t i = 0; i < info.whitelist().Length(); i++) {
wlPrincipal = PrincipalInfoToPrincipal(info.whitelist()[i], &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
// append that principal to the whitelist
whitelist.AppendElement(wlPrincipal);
}
RefPtr<nsExpandedPrincipal> expandedPrincipal = new nsExpandedPrincipal(whitelist, info.attrs());
if (!expandedPrincipal) {
NS_WARNING("could not instantiate expanded principal");
return nullptr;
}
principal = expandedPrincipal;
return principal.forget();
}
default:
MOZ_CRASH("Unknown PrincipalInfo type!");
}
MOZ_CRASH("Should never get here!");
}