1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2003
20 * the Initial Developer. All Rights Reserved.
23 * Roy Yokoyama <yokoyama@netscape.com> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 #include "DotNETEmbed.h"
42 #include "WebChrome.h"
44 #define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
48 //*****************************************************************************
49 // WebBrowserChrome::nsISupports
50 //*****************************************************************************
52 NS_IMPL_ADDREF(WebBrowserChrome
)
53 NS_IMPL_RELEASE(WebBrowserChrome
)
55 NS_INTERFACE_MAP_BEGIN(WebBrowserChrome
)
56 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports
, nsIWebBrowserChrome
)
57 NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome
)
58 NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow
)
62 WebBrowserChrome::WebBrowserChrome()
64 mNativeWindow
= nsnull
;
67 WebBrowserChrome::~WebBrowserChrome()
71 /* attribute nativeSiteWindow siteWindow */
72 NS_IMETHODIMP
WebBrowserChrome::GetSiteWindow(void * *aSiteWindow
)
74 *aSiteWindow
= mNativeWindow
;
78 NS_IMETHODIMP
WebBrowserChrome::GetTitle(PRUnichar
* *aTitle
)
80 NS_ENSURE_ARG_POINTER(aTitle
);
84 return NS_ERROR_NOT_IMPLEMENTED
;
86 NS_IMETHODIMP
WebBrowserChrome::SetTitle(const PRUnichar
* aTitle
)
88 return NS_ERROR_NOT_IMPLEMENTED
;
91 /* attribute boolean visibility; */
92 NS_IMETHODIMP
WebBrowserChrome::GetVisibility(PRBool
* aVisibility
)
94 NS_ENSURE_ARG_POINTER(aVisibility
);
95 *aVisibility
= PR_TRUE
;
100 NS_IMETHODIMP
WebBrowserChrome::SetVisibility(PRBool aVisibility
)
105 /* void setFocus (); */
106 NS_IMETHODIMP
WebBrowserChrome::SetFocus()
111 NS_IMETHODIMP
WebBrowserChrome::SetDimensions(PRUint32 aFlags
, PRInt32 x
, PRInt32 y
, PRInt32 cx
, PRInt32 cy
)
116 NS_IMETHODIMP
WebBrowserChrome::GetDimensions(PRUint32 aFlags
, PRInt32
*x
, PRInt32
*y
, PRInt32
*cx
, PRInt32
*cy
)
118 if (aFlags
& nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION
)
123 if (aFlags
& nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER
||
124 aFlags
& nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER
)
132 NS_IMETHODIMP
WebBrowserChrome::ExitModalEventLoop(nsresult aStatus
)
137 NS_IMETHODIMP
WebBrowserChrome::ShowAsModal(void)
142 NS_IMETHODIMP
WebBrowserChrome::IsWindowModal(PRBool
*_retval
)
145 return NS_ERROR_NOT_IMPLEMENTED
;
149 NS_IMETHODIMP
WebBrowserChrome::SetStatus(PRUint32 aType
, const PRUnichar
* aStatus
)
154 NS_IMETHODIMP
WebBrowserChrome::GetWebBrowser(nsIWebBrowser
** aWebBrowser
)
156 NS_ENSURE_ARG_POINTER(aWebBrowser
);
157 *aWebBrowser
= mWebBrowser
;
158 NS_IF_ADDREF(*aWebBrowser
);
162 NS_IMETHODIMP
WebBrowserChrome::SetWebBrowser(nsIWebBrowser
* aWebBrowser
)
164 mWebBrowser
= aWebBrowser
;
168 NS_IMETHODIMP
WebBrowserChrome::GetChromeFlags(PRUint32
* aChromeMask
)
170 *aChromeMask
= mChromeFlags
;
174 NS_IMETHODIMP
WebBrowserChrome::SetChromeFlags(PRUint32 aChromeMask
)
176 mChromeFlags
= aChromeMask
;
180 NS_IMETHODIMP
WebBrowserChrome::DestroyBrowserWindow(void)
186 NS_IMETHODIMP
WebBrowserChrome::SizeBrowserTo(PRInt32 aWidth
, PRInt32 aHeight
)
188 ::MoveWindow((HWND
)mNativeWindow
, 0, 0, aWidth
, aHeight
, TRUE
);
192 nsresult
WebBrowserChrome::CreateBrowser(HWND hWnd
, PRInt32 aX
, PRInt32 aY
,
193 PRInt32 aCX
, PRInt32 aCY
,
194 nsIWebBrowser
**aBrowser
)
196 NS_ENSURE_ARG_POINTER(aBrowser
);
199 mWebBrowser
= do_CreateInstance(NS_WEBBROWSER_CONTRACTID
);
202 return NS_ERROR_FAILURE
;
204 (void)mWebBrowser
->SetContainerWindow(static_cast<nsIWebBrowserChrome
*>(this));
206 nsCOMPtr
<nsIDocShellTreeItem
> dsti
= do_QueryInterface(mWebBrowser
);
207 dsti
->SetItemType(nsIDocShellTreeItem::typeContentWrapper
);
209 nsCOMPtr
<nsIBaseWindow
> browserBaseWindow
= do_QueryInterface(mWebBrowser
);
211 mNativeWindow
= hWnd
;
214 return NS_ERROR_FAILURE
;
216 browserBaseWindow
->InitWindow( mNativeWindow
,
219 browserBaseWindow
->Create();
224 *aBrowser
= mWebBrowser
;
225 NS_ADDREF(*aBrowser
);
228 return NS_ERROR_FAILURE
;