本文整理汇总了C++中nsCOMPtr::GetHost方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::GetHost方法的具体用法?C++ nsCOMPtr::GetHost怎么用?C++ nsCOMPtr::GetHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::GetHost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
SocketTransportShim::GetHost(nsACString & aHost)
{
return mWrapped->GetHost(aHost);
}
示例2: Canonify
nsresult nsChromeRegistry::Canonify(nsCOMPtr<nsIURI>& aChromeURL) {
NS_NAMED_LITERAL_CSTRING(kSlash, "/");
nsresult rv;
nsAutoCString provider, path;
rv = GetProviderAndPath(aChromeURL, provider, path);
NS_ENSURE_SUCCESS(rv, rv);
if (path.IsEmpty()) {
nsAutoCString package;
rv = aChromeURL->GetHost(package);
NS_ENSURE_SUCCESS(rv, rv);
// we re-use the "path" local string to build a new URL path
path.Assign(kSlash + provider + kSlash + package);
if (provider.EqualsLiteral("content")) {
path.AppendLiteral(".xul");
} else if (provider.EqualsLiteral("locale")) {
path.AppendLiteral(".dtd");
} else if (provider.EqualsLiteral("skin")) {
path.AppendLiteral(".css");
} else {
return NS_ERROR_INVALID_ARG;
}
return NS_MutateURI(aChromeURL).SetPathQueryRef(path).Finalize(aChromeURL);
} else {
// prevent directory traversals ("..")
// path is already unescaped once, but uris can get unescaped twice
const char* pos = path.BeginReading();
const char* end = path.EndReading();
// Must start with [a-zA-Z0-9].
if (!('a' <= *pos && *pos <= 'z') && !('A' <= *pos && *pos <= 'Z') &&
!('0' <= *pos && *pos <= '9')) {
return NS_ERROR_DOM_BAD_URI;
}
while (pos < end) {
switch (*pos) {
case ':':
return NS_ERROR_DOM_BAD_URI;
case '.':
if (pos[1] == '.') return NS_ERROR_DOM_BAD_URI;
break;
case '%':
// chrome: URIs with double-escapes are trying to trick us.
// watch for %2e, and %25 in case someone triple unescapes
if (pos[1] == '2' &&
(pos[2] == 'e' || pos[2] == 'E' || pos[2] == '5'))
return NS_ERROR_DOM_BAD_URI;
break;
case '?':
case '#':
pos = end;
continue;
}
++pos;
}
}
return NS_OK;
}