1/*
2 * Copyright (C) 2006 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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#pragma once
27
28#include "resource.h"
29#include <WebKit/WebKit.h>
30
31class WinLauncherWebHost : public IWebFrameLoadDelegate
32{
33public:
34    WinLauncherWebHost() : m_refCount(1) {}
35
36    // IUnknown
37    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
38    virtual ULONG STDMETHODCALLTYPE AddRef(void);
39    virtual ULONG STDMETHODCALLTYPE Release(void);
40
41    // IWebFrameLoadDelegate
42    virtual HRESULT STDMETHODCALLTYPE didStartProvisionalLoadForFrame(
43        /* [in] */ IWebView* webView,
44        /* [in] */ IWebFrame* /*frame*/) { return S_OK; }
45
46    virtual HRESULT STDMETHODCALLTYPE didReceiveServerRedirectForProvisionalLoadForFrame(
47        /* [in] */ IWebView *webView,
48        /* [in] */ IWebFrame *frame) { return S_OK; }
49
50    virtual HRESULT STDMETHODCALLTYPE didFailProvisionalLoadWithError(
51        /* [in] */ IWebView *webView,
52        /* [in] */ IWebError *error,
53        /* [in] */ IWebFrame *frame) { return S_OK; }
54
55    virtual HRESULT STDMETHODCALLTYPE didCommitLoadForFrame(
56        /* [in] */ IWebView *webView,
57        /* [in] */ IWebFrame *frame) { return updateAddressBar(webView); }
58
59    virtual HRESULT STDMETHODCALLTYPE didReceiveTitle(
60        /* [in] */ IWebView *webView,
61        /* [in] */ BSTR title,
62        /* [in] */ IWebFrame *frame) { return S_OK; }
63
64    virtual HRESULT STDMETHODCALLTYPE didReceiveIcon(
65        /* [in] */ IWebView *webView,
66        /* [in] */ OLE_HANDLE hBitmap,
67        /* [in] */ IWebFrame *frame) { return S_OK; }
68
69    virtual HRESULT STDMETHODCALLTYPE didFinishLoadForFrame(
70        /* [in] */ IWebView* webView,
71        /* [in] */ IWebFrame* /*frame*/) { return S_OK; }
72
73    virtual HRESULT STDMETHODCALLTYPE didFailLoadWithError(
74        /* [in] */ IWebView *webView,
75        /* [in] */ IWebError *error,
76        /* [in] */ IWebFrame *forFrame) { return S_OK; }
77
78    virtual HRESULT STDMETHODCALLTYPE didChangeLocationWithinPageForFrame(
79        /* [in] */ IWebView *webView,
80        /* [in] */ IWebFrame *frame) { return S_OK; }
81
82    virtual HRESULT STDMETHODCALLTYPE willPerformClientRedirectToURL(
83        /* [in] */ IWebView *webView,
84        /* [in] */ BSTR url,
85        /* [in] */ double delaySeconds,
86        /* [in] */ DATE fireDate,
87        /* [in] */ IWebFrame *frame) { return S_OK; }
88
89    virtual HRESULT STDMETHODCALLTYPE didCancelClientRedirectForFrame(
90        /* [in] */ IWebView *webView,
91        /* [in] */ IWebFrame *frame) { return S_OK; }
92
93    virtual HRESULT STDMETHODCALLTYPE willCloseFrame(
94        /* [in] */ IWebView *webView,
95        /* [in] */ IWebFrame *frame) { return S_OK; }
96
97    virtual /* [local] */ HRESULT STDMETHODCALLTYPE windowScriptObjectAvailable(
98        /* [in] */ IWebView *webView,
99        /* [in] */ JSContextRef context,
100        /* [in] */ JSObjectRef windowScriptObject)  { return S_OK; }
101
102    virtual /* [local] */ HRESULT STDMETHODCALLTYPE didClearWindowObject(
103        /* [in] */ IWebView *webView,
104        /* [in] */ JSContextRef context,
105        /* [in] */ JSObjectRef windowScriptObject,
106        /* [in] */ IWebFrame *frame) { return S_OK; }
107
108    // WinLauncherWebHost
109
110protected:
111    HRESULT updateAddressBar(IWebView* webView);
112
113protected:
114    ULONG                   m_refCount;
115};
116