本文整理汇总了C++中WebView::resourceLoadDelegate方法的典型用法代码示例。如果您正苦于以下问题:C++ WebView::resourceLoadDelegate方法的具体用法?C++ WebView::resourceLoadDelegate怎么用?C++ WebView::resourceLoadDelegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebView
的用法示例。
在下文中一共展示了WebView::resourceLoadDelegate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assignIdentifierToInitialRequest
void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return;
COMPtr<WebMutableURLRequest> webURLRequest(AdoptCOM, WebMutableURLRequest::createInstance(request));
resourceLoadDelegate->identifierForInitialRequest(webView, webURLRequest.get(), getWebDataSource(loader), identifier);
}
示例2: dispatchDidFailLoading
void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return;
COMPtr<WebError> webError(AdoptCOM, WebError::createInstance(error));
resourceLoadDelegate->didFailLoadingWithError(webView, identifier, webError.get(), getWebDataSource(loader));
}
示例3: dispatchDidReceiveResponse
void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& response)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return;
COMPtr<WebURLResponse> webURLResponse(AdoptCOM, WebURLResponse::createInstance(response));
resourceLoadDelegate->didReceiveResponse(webView, identifier, webURLResponse.get(), getWebDataSource(loader));
}
示例4: dispatchDidCancelAuthenticationChallenge
void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge& challenge)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return;
COMPtr<WebURLAuthenticationChallenge> webChallenge(AdoptCOM, WebURLAuthenticationChallenge::createInstance(challenge));
resourceLoadDelegate->didCancelAuthenticationChallenge(webView, identifier, webChallenge.get(), getWebDataSource(loader));
}
示例5: dispatchDidFailToStartPlugin
void WebFrameLoaderClient::dispatchDidFailToStartPlugin(const PluginView* pluginView) const
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return;
RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
Frame* frame = core(m_webFrame);
ASSERT(frame == pluginView->parentFrame());
if (!pluginView->pluginsPage().isNull()) {
KURL pluginPageURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(pluginView->pluginsPage()));
if (pluginPageURL.protocolIsInHTTPFamily()) {
static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInPageURLStringKey);
CFDictionarySetValue(userInfo.get(), key, pluginPageURL.string().createCFString().get());
}
}
if (!pluginView->mimeType().isNull()) {
static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorMIMETypeKey);
CFDictionarySetValue(userInfo.get(), key, pluginView->mimeType().createCFString().get());
}
if (pluginView->plugin()) {
String pluginName = pluginView->plugin()->name();
if (!pluginName.isNull()) {
static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInNameKey);
CFDictionarySetValue(userInfo.get(), key, pluginName.createCFString().get());
}
}
COMPtr<CFDictionaryPropertyBag> userInfoBag = CFDictionaryPropertyBag::createInstance();
userInfoBag->setDictionary(userInfo.get());
int errorCode = 0;
switch (pluginView->status()) {
case PluginStatusCanNotFindPlugin:
errorCode = WebKitErrorCannotFindPlugIn;
break;
case PluginStatusCanNotLoadPlugin:
errorCode = WebKitErrorCannotLoadPlugIn;
break;
default:
ASSERT_NOT_REACHED();
}
ResourceError resourceError(String(WebKitErrorDomain), errorCode, pluginView->url().string(), String());
COMPtr<IWebError> error(AdoptCOM, WebError::createInstance(resourceError, userInfoBag.get()));
resourceLoadDelegate->plugInFailedWithError(webView, error.get(), getWebDataSource(frame->loader()->documentLoader()));
}
示例6: dispatchDidReceiveAuthenticationChallenge
void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge& challenge)
{
ASSERT(challenge.authenticationClient());
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (SUCCEEDED(webView->resourceLoadDelegate(&resourceLoadDelegate))) {
COMPtr<WebURLAuthenticationChallenge> webChallenge(AdoptCOM, WebURLAuthenticationChallenge::createInstance(challenge));
if (SUCCEEDED(resourceLoadDelegate->didReceiveAuthenticationChallenge(webView, identifier, webChallenge.get(), getWebDataSource(loader))))
return;
}
// If the ResourceLoadDelegate doesn't exist or fails to handle the call, we tell the ResourceHandle
// to continue without credential - this is the best approximation of Mac behavior
challenge.authenticationClient()->receivedRequestToContinueWithoutCredential(challenge);
}
示例7: shouldUseCredentialStorage
bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader* loader, unsigned long identifier)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return true;
COMPtr<IWebResourceLoadDelegatePrivate2> resourceLoadDelegatePrivate;
if (FAILED(resourceLoadDelegate->QueryInterface(IID_IWebResourceLoadDelegatePrivate2, reinterpret_cast<void**>(&resourceLoadDelegatePrivate))))
return true;
BOOL shouldUse;
if (SUCCEEDED(resourceLoadDelegatePrivate->shouldUseCredentialStorage(webView, identifier, getWebDataSource(loader), &shouldUse)))
return shouldUse;
return true;
}
示例8: transferLoadingResourceFromPage
void WebFrameLoaderClient::transferLoadingResourceFromPage(ResourceLoader* loader, const ResourceRequest& request, Page* oldPage)
{
assignIdentifierToInitialRequest(loader->identifier(), loader->documentLoader(), request);
WebView* oldWebView = kit(oldPage);
if (!oldWebView)
return;
COMPtr<IWebResourceLoadDelegate> oldResourceLoadDelegate;
if (FAILED(oldWebView->resourceLoadDelegate(&oldResourceLoadDelegate)))
return;
COMPtr<IWebResourceLoadDelegatePrivate2> oldResourceLoadDelegatePrivate2(Query, oldResourceLoadDelegate);
if (!oldResourceLoadDelegatePrivate2)
return;
oldResourceLoadDelegatePrivate2->removeIdentifierForRequest(oldWebView, loader->identifier());
}
示例9: shouldCacheResponse
bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& response, const unsigned char* data, const unsigned long long length)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return true;
COMPtr<IWebResourceLoadDelegatePrivate> resourceLoadDelegatePrivate(Query, resourceLoadDelegate);
if (!resourceLoadDelegatePrivate)
return true;
COMPtr<IWebURLResponse> urlResponse(AdoptCOM, WebURLResponse::createInstance(response));
BOOL shouldCache;
if (SUCCEEDED(resourceLoadDelegatePrivate->shouldCacheResponse(webView, identifier, urlResponse.get(), data, length, getWebDataSource(loader), &shouldCache)))
return shouldCache;
return true;
}
示例10: dispatchWillSendRequest
void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return;
COMPtr<WebMutableURLRequest> webURLRequest(AdoptCOM, WebMutableURLRequest::createInstance(request));
COMPtr<WebURLResponse> webURLRedirectResponse(AdoptCOM, WebURLResponse::createInstance(redirectResponse));
COMPtr<IWebURLRequest> newWebURLRequest;
if (FAILED(resourceLoadDelegate->willSendRequest(webView, identifier, webURLRequest.get(), webURLRedirectResponse.get(), getWebDataSource(loader), &newWebURLRequest)))
return;
if (webURLRequest == newWebURLRequest)
return;
COMPtr<WebMutableURLRequest> newWebURLRequestImpl(Query, newWebURLRequest);
if (!newWebURLRequestImpl)
return;
request = newWebURLRequestImpl->resourceRequest();
}
示例11: createPlugin
Widget* WebFrameLoaderClient::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
{
WebView* webView = m_webFrame->webView();
COMPtr<IWebUIDelegate> ui;
if (SUCCEEDED(webView->uiDelegate(&ui)) && ui) {
COMPtr<IWebUIDelegatePrivate4> uiPrivate(Query, ui);
if (uiPrivate) {
// Assemble the view arguments in a property bag.
HashMap<String, String> viewArguments;
for (unsigned i = 0; i < paramNames.size(); i++)
viewArguments.set(paramNames[i], paramValues[i]);
COMPtr<IPropertyBag> viewArgumentsBag(AdoptCOM, COMPropertyBag<String>::adopt(viewArguments));
COMPtr<IDOMElement> containingElement(AdoptCOM, DOMElement::createInstance(element));
HashMap<String, COMVariant> arguments;
arguments.set(WebEmbeddedViewAttributesKey, viewArgumentsBag);
arguments.set(WebEmbeddedViewBaseURLKey, url.string());
arguments.set(WebEmbeddedViewContainingElementKey, containingElement);
arguments.set(WebEmbeddedViewMIMETypeKey, mimeType);
COMPtr<IPropertyBag> argumentsBag(AdoptCOM, COMPropertyBag<COMVariant>::adopt(arguments));
COMPtr<IWebEmbeddedView> view;
HRESULT result = uiPrivate->embeddedViewWithArguments(webView, m_webFrame, argumentsBag.get(), &view);
if (SUCCEEDED(result)) {
HWND parentWindow;
HRESULT hr = webView->viewWindow((OLE_HANDLE*)&parentWindow);
ASSERT(SUCCEEDED(hr));
return EmbeddedWidget::create(view.get(), element, parentWindow, pluginSize);
}
}
}
Frame* frame = core(m_webFrame);
PluginView* pluginView = PluginView::create(frame, pluginSize, element, url, paramNames, paramValues, mimeType, loadManually);
if (pluginView->status() == PluginStatusLoadedSuccessfully)
return pluginView;
COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
if (FAILED(webView->resourceLoadDelegate(&resourceLoadDelegate)))
return pluginView;
RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
unsigned count = (unsigned)paramNames.size();
for (unsigned i = 0; i < count; i++) {
if (paramNames[i] == "pluginspage") {
static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInPageURLStringKey);
RetainPtr<CFStringRef> str(AdoptCF, paramValues[i].createCFString());
CFDictionarySetValue(userInfo.get(), key, str.get());
break;
}
}
if (!mimeType.isNull()) {
static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorMIMETypeKey);
RetainPtr<CFStringRef> str(AdoptCF, mimeType.createCFString());
CFDictionarySetValue(userInfo.get(), key, str.get());
}
String pluginName;
if (pluginView->plugin())
pluginName = pluginView->plugin()->name();
if (!pluginName.isNull()) {
static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInNameKey);
RetainPtr<CFStringRef> str(AdoptCF, pluginName.createCFString());
CFDictionarySetValue(userInfo.get(), key, str.get());
}
COMPtr<CFDictionaryPropertyBag> userInfoBag(AdoptCOM, CFDictionaryPropertyBag::createInstance());
userInfoBag->setDictionary(userInfo.get());
int errorCode = 0;
switch (pluginView->status()) {
case PluginStatusCanNotFindPlugin:
errorCode = WebKitErrorCannotFindPlugIn;
break;
case PluginStatusCanNotLoadPlugin:
errorCode = WebKitErrorCannotLoadPlugIn;
break;
default:
ASSERT_NOT_REACHED();
}
ResourceError resourceError(String(WebKitErrorDomain), errorCode, url.string(), String());
COMPtr<IWebError> error(AdoptCOM, WebError::createInstance(resourceError, userInfoBag.get()));
resourceLoadDelegate->plugInFailedWithError(webView, error.get(), getWebDataSource(frame->loader()->documentLoader()));
return pluginView;
}