本文整理汇总了C++中COMPtr::URL方法的典型用法代码示例。如果您正苦于以下问题:C++ COMPtr::URL方法的具体用法?C++ COMPtr::URL怎么用?C++ COMPtr::URL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COMPtr
的用法示例。
在下文中一共展示了COMPtr::URL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: queueLoad
void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
{
COMPtr<IWebDataSource> dataSource;
if (FAILED(frame->dataSource(&dataSource)))
return;
COMPtr<IWebURLResponse> response;
if (FAILED(dataSource->response(&response)) || !response)
return;
BSTR responseURLBSTR;
if (FAILED(response->URL(&responseURLBSTR)))
return;
wstring responseURL(responseURLBSTR, SysStringLen(responseURLBSTR));
SysFreeString(responseURLBSTR);
// FIXME: We should do real relative URL resolution here.
int lastSlash = responseURL.rfind('/');
if (lastSlash != -1)
responseURL = responseURL.substr(0, lastSlash);
wstring wURL = jsStringRefToWString(url);
wstring wAbsoluteURL = responseURL + TEXT("/") + wURL;
JSRetainPtr<JSStringRef> jsAbsoluteURL(Adopt, JSStringCreateWithCharacters(wAbsoluteURL.data(), wAbsoluteURL.length()));
WorkQueue::shared()->queue(new LoadItem(jsAbsoluteURL.get(), target));
}
示例2: urlSuitableForTestResult
wstring urlSuitableForTestResult(const wstring& urlString)
{
RetainPtr<CFURLRef> url = adoptCF(CFURLCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(urlString.c_str()), urlString.length() * sizeof(wstring::value_type), kCFStringEncodingUTF16, 0));
RetainPtr<CFStringRef> scheme = adoptCF(CFURLCopyScheme(url.get()));
if (scheme && CFStringCompare(scheme.get(), CFSTR("file"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)
return urlString;
COMPtr<IWebDataSource> dataSource;
if (FAILED(frame->dataSource(&dataSource))) {
if (FAILED(frame->provisionalDataSource(&dataSource)))
return lastPathComponentAsWString(url.get());
}
COMPtr<IWebMutableURLRequest> request;
if (FAILED(dataSource->request(&request)))
return lastPathComponentAsWString(url.get());
_bstr_t requestURLString;
if (FAILED(request->URL(requestURLString.GetAddress())))
return lastPathComponentAsWString(url.get());
RetainPtr<CFURLRef> requestURL = adoptCF(CFURLCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(requestURLString.GetBSTR()), requestURLString.length() * sizeof(OLECHAR), kCFStringEncodingUTF16, 0));
RetainPtr<CFURLRef> baseURL = adoptCF(CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, requestURL.get()));
RetainPtr<CFStringRef> basePath = adoptCF(CFURLCopyPath(baseURL.get()));
RetainPtr<CFStringRef> path = adoptCF(CFURLCopyPath(url.get()));
if (basePath.get() && CFStringHasPrefix(path.get(), basePath.get()))
return cfStringRefToWString(substringFromIndex(path.get(), CFStringGetLength(basePath.get())).get());
return lastPathComponentAsWString(url.get());
}