Commit 4eab1d36 authored by andersca@apple.com's avatar andersca@apple.com

2009-01-06 Anders Carlsson <andersca@apple.com>

        Reviewed by Sam Weinig.

        Add a way for application to provide custom, full frame, views for certain MIME types.
        
        * Interfaces/IWebEmbeddedView.idl:
        Add loading related methods.
        
        * Interfaces/IWebViewPrivate.idl:
        Add new registerEmbeddedViewMIMEType method.
        
        * WebCoreSupport/EmbeddedWidget.cpp:
        (EmbeddedWidget::didReceiveResponse):
        (EmbeddedWidget::didReceiveData):
        (EmbeddedWidget::didFinishLoading):
        (EmbeddedWidget::didFail):
        Implement these and call the IEmbeddedView methods.
        
        * WebCoreSupport/EmbeddedWidget.h:
        Inherit from PluginManualLoader.
        
        * WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebFrameLoaderClient::redirectDataToPlugin):
        Handle the case where the widget is an EnbeddedWidget.
        
        (WebFrameLoaderClient::shouldUsePluginDocument):
        Have this call WebView::shouldUseEmbeddedView.
        
        * WebView.cpp:
        (WebView::canShowMIMEType):
        Have this call WebView::shouldUseEmbeddedView.
        
        (WebView::registerEmbeddedViewMIMEType):
        Add the MIME type to the set.
        
        (WebView::shouldUseEmbeddedView):
        Given a MIME type, returns whether an embedded view should be used or not.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 641fef90
2009-01-06 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
Add a way for application to provide custom, full frame, views for certain MIME types.
* Interfaces/IWebEmbeddedView.idl:
Add loading related methods.
* Interfaces/IWebViewPrivate.idl:
Add new registerEmbeddedViewMIMEType method.
* WebCoreSupport/EmbeddedWidget.cpp:
(EmbeddedWidget::didReceiveResponse):
(EmbeddedWidget::didReceiveData):
(EmbeddedWidget::didFinishLoading):
(EmbeddedWidget::didFail):
Implement these and call the IEmbeddedView methods.
* WebCoreSupport/EmbeddedWidget.h:
Inherit from PluginManualLoader.
* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::redirectDataToPlugin):
Handle the case where the widget is an EnbeddedWidget.
(WebFrameLoaderClient::shouldUsePluginDocument):
Have this call WebView::shouldUseEmbeddedView.
* WebView.cpp:
(WebView::canShowMIMEType):
Have this call WebView::shouldUseEmbeddedView.
(WebView::registerEmbeddedViewMIMEType):
Add the MIME type to the set.
(WebView::shouldUseEmbeddedView):
Given a MIME type, returns whether an embedded view should be used or not.
2009-01-06 David Kilzer <ddkilzer@apple.com>
BUILD FIX (r39641): Try to fix WebIconDatabase build errors #4
......
......@@ -38,4 +38,9 @@ import "ocidl.idl";
interface IWebEmbeddedView : IUnknown
{
HRESULT createViewWindow([in] OLE_HANDLE parentWindow, [in] LPSIZE pluginSize, [out, retval] OLE_HANDLE* window);
HRESULT didReceiveResponse([in] IWebURLResponse* response);
HRESULT didReceiveData([in] IStream* data);
HRESULT didFinishLoading();
HRESULT didFail([in] IWebError* error);
}
......@@ -153,4 +153,6 @@ interface IWebViewPrivate : IUnknown
HRESULT clearMainFrameName();
HRESULT globalHistoryItem([out, retval] IWebHistoryItem**);
HRESULT registerEmbeddedViewMIMEType([in] BSTR mimeType);
}
......@@ -31,6 +31,10 @@
#include <WebCore/FrameView.h>
#include <WebCore/RenderObject.h>
#include "MemoryStream.h"
#include "WebError.h"
#include "WebURLResponse.h"
using namespace WebCore;
EmbeddedWidget* EmbeddedWidget::create(IWebEmbeddedView* view, Element* element, HWND parentWindow, const IntSize& size)
......@@ -207,3 +211,30 @@ void EmbeddedWidget::detachFromWindow()
ShowWindow(m_window, SW_HIDE);
m_attachedToWindow = false;
}
void EmbeddedWidget::didReceiveResponse(const ResourceResponse& response)
{
ASSERT(m_view);
COMPtr<IWebURLResponse> urlResponse(AdoptCOM, WebURLResponse::createInstance(response));
m_view->didReceiveResponse(urlResponse.get());
}
void EmbeddedWidget::didReceiveData(const char* data, int length)
{
RefPtr<SharedBuffer> buffer(SharedBuffer::create(data, length));
COMPtr<IStream> stream(AdoptCOM, MemoryStream::createInstance(buffer.release()));
m_view->didReceiveData(stream.get());
}
void EmbeddedWidget::didFinishLoading()
{
m_view->didFinishLoading();
}
void EmbeddedWidget::didFail(const ResourceError& error)
{
COMPtr<IWebError> webError(AdoptCOM, WebError::createInstance(error));
m_view->didFail(webError.get());
}
......@@ -28,7 +28,7 @@
#include <WebCore/COMPtr.h>
#include <WebCore/IntRect.h>
#include <WebCore/Widget.h>
#include <WebCore/PluginView.h>
namespace WebCore {
class Element;
......@@ -37,7 +37,7 @@ namespace WebCore {
interface IWebEmbeddedView;
class EmbeddedWidget : public WebCore::Widget {
class EmbeddedWidget : public WebCore::Widget, public WebCore::PluginManualLoader {
public:
static EmbeddedWidget* create(IWebEmbeddedView*, WebCore::Element* element, HWND parentWindow, const WebCore::IntSize&);
~EmbeddedWidget();
......@@ -54,6 +54,11 @@ private:
bool createWindow(HWND parentWindow, const WebCore::IntSize& size);
virtual void didReceiveResponse(const WebCore::ResourceResponse&);
virtual void didReceiveData(const char*, int);
virtual void didFinishLoading();
virtual void didFail(const WebCore::ResourceError&);
virtual void invalidateRect(const WebCore::IntRect&);
virtual void setFrameRect(const WebCore::IntRect&);
virtual void frameRectsChanged();
......
......@@ -701,6 +701,8 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
if (pluginWidget->isPluginView())
m_manualLoader = static_cast<PluginView*>(pluginWidget);
else
m_manualLoader = static_cast<EmbeddedWidget*>(pluginWidget);
}
WebHistory* WebFrameLoaderClient::webHistory() const
......@@ -710,3 +712,12 @@ WebHistory* WebFrameLoaderClient::webHistory() const
return WebHistory::sharedHistory();
}
bool WebFrameLoaderClient::shouldUsePluginDocument(const String& mimeType) const
{
WebView* webView = m_webFrame->webView();
if (!webView)
return false;
return webView->shouldUseEmbeddedView(mimeType);
}
......@@ -101,6 +101,8 @@ public:
virtual WebCore::Widget* createPlugin(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL&, const Vector<WebCore::String>&, const Vector<WebCore::String>&, const WebCore::String&, bool loadManually);
virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
virtual bool shouldUsePluginDocument(const WebCore::String& mimeType) const;
protected:
WebFrameLoaderClient(WebFrame*);
~WebFrameLoaderClient();
......
......@@ -2080,7 +2080,8 @@ HRESULT STDMETHODCALLTYPE WebView::canShowMIMEType(
*canShow = MIMETypeRegistry::isSupportedImageMIMEType(mimeTypeStr) ||
MIMETypeRegistry::isSupportedNonImageMIMEType(mimeTypeStr) ||
PluginInfoStore::supportsMIMEType(mimeTypeStr);
PluginInfoStore::supportsMIMEType(mimeTypeStr) ||
shouldUseEmbeddedView(mimeTypeStr);
return S_OK;
}
......@@ -5088,6 +5089,26 @@ HRESULT STDMETHODCALLTYPE WebView::alwaysUsesComplexTextCodePath(BOOL* complex)
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebView::registerEmbeddedViewMIMEType(BSTR mimeType)
{
if (!mimeType)
return E_POINTER;
if (!m_embeddedViewMIMETypes)
m_embeddedViewMIMETypes.set(new HashSet<String>);
m_embeddedViewMIMETypes->add(String(mimeType, ::SysStringLen(mimeType)));
return S_OK;
}
bool WebView::shouldUseEmbeddedView(const WebCore::String& mimeType) const
{
if (!m_embeddedViewMIMETypes)
return false;
return m_embeddedViewMIMETypes->contains(mimeType);
}
bool WebView::onGetObject(WPARAM wParam, LPARAM lParam, LRESULT& lResult) const
{
lResult = 0;
......
......@@ -34,6 +34,7 @@
#include <WebCore/IntRect.h>
#include <WebCore/Timer.h>
#include <WebCore/WindowMessageListener.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
class WebFrame;
......@@ -717,7 +718,12 @@ public:
virtual HRESULT STDMETHODCALLTYPE mediaVolume(
/* [out, retval] */ float* volume);
virtual HRESULT STDMETHODCALLTYPE registerEmbeddedViewMIMEType(
/* [in] */ BSTR mimeType);
// WebView
bool shouldUseEmbeddedView(const WebCore::String& mimeType) const;
WebCore::Page* page();
bool handleMouseEvent(UINT, WPARAM, LPARAM);
void setMouseActivated(bool flag) { m_mouseActivated = flag; }
......@@ -892,6 +898,8 @@ protected:
OwnPtr<TRACKMOUSEEVENT> m_mouseOutTracker;
HWND m_topLevelParent;
OwnPtr<HashSet<WebCore::String> > m_embeddedViewMIMETypes;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment