1/*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef EmbeddedWidget_h
27#define EmbeddedWidget_h
28
29#include "WebKit.h"
30#include <WebCore/COMPtr.h>
31#include <WebCore/IntRect.h>
32#include <WebCore/PluginView.h>
33
34namespace WebCore {
35class HTMLPlugInElement;
36class IntSize;
37}
38
39interface IWebEmbeddedView;
40
41class EmbeddedWidget : public WebCore::Widget, public WebCore::PluginManualLoader {
42public:
43    static PassRefPtr<EmbeddedWidget> create(IWebEmbeddedView*, WebCore::HTMLPlugInElement*, HWND parentWindow, const WebCore::IntSize&);
44    ~EmbeddedWidget();
45
46private:
47    EmbeddedWidget(IWebEmbeddedView* view, WebCore::HTMLPlugInElement* element)
48        : m_view(view)
49        , m_element(element)
50        , m_window(0)
51        , m_isVisible(false)
52        , m_attachedToWindow(false)
53    {
54    }
55
56    bool createWindow(HWND parentWindow, const WebCore::IntSize& size);
57
58    virtual void didReceiveResponse(const WebCore::ResourceResponse&);
59    virtual void didReceiveData(const char*, int);
60    virtual void didFinishLoading();
61    virtual void didFail(const WebCore::ResourceError&);
62
63    virtual void invalidateRect(const WebCore::IntRect&);
64    virtual void setFrameRect(const WebCore::IntRect&);
65    virtual void frameRectsChanged();
66    virtual void setFocus(bool);
67    virtual void show();
68    virtual void hide();
69    virtual WebCore::IntRect windowClipRect() const;
70    virtual void setParent(WebCore::ScrollView*);
71
72    virtual void attachToWindow();
73    virtual void detachFromWindow();
74
75    COMPtr<IWebEmbeddedView> m_view;
76    WebCore::HTMLPlugInElement* m_element;
77    HWND m_window;
78
79    bool m_isVisible;
80    bool m_attachedToWindow;
81
82    WebCore::IntRect m_clipRect; // The clip rect to apply to an embedded view.
83    WebCore::IntRect m_windowRect; // Our window rect.
84};
85
86#endif // EmbeddedWidget_h
87