Removing gtkEmbed (obsolete, bug 90526). r=adamlock, sr=blizzard

This commit is contained in:
mcafee%netscape.com 2001-10-19 01:51:09 +00:00
Родитель f19aed43b1
Коммит 5aad6b9804
9 изменённых файлов: 0 добавлений и 1279 удалений

Просмотреть файл

@ -1,79 +0,0 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Mozilla browser.
#
# The Initial Developer of the Original Code is Christopher
# Blizzard. Portions created by Christopher Blizzard are
# Copyright (C) 1999, Mozilla. All Rights Reserved.
#
# Contributor(s):
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
REQUIRES = xpcom \
string \
webbrwsr \
widget \
necko \
docshell \
gfx \
layout \
webshell \
dom \
uriloader \
embed_base \
windowwatcher \
pref \
mpfilelocprovider \
$(NULL)
CPPSRCS = \
WebBrowserChrome.cpp \
WindowCreator.cpp \
PromptService.cpp \
main.cpp \
$(NULL)
PROGRAM = gtkEmbed
LIBS= \
$(DIST)/lib/libembed_base_s.$(LIB_SUFFIX) \
$(DIST)/lib/libmpfilelocprovider_s.$(LIB_SUFFIX) \
$(MOZ_COMPONENT_LIBS) \
$(XPCOM_LIBS) \
-lgtksuperwin \
$(PROFILE_LIBS) \
$(NULL)
LIBS += $(TK_LIBS)
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_GTK_CFLAGS)
ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES += -D_TIME_H=1
endif
endif

Просмотреть файл

@ -1,143 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "PromptService.h"
#include "nsCOMPtr.h"
#include "nsXPComFactory.h"
#include "nsIPromptService.h"
class PromptServiceImpl : public nsIPromptService
{
public:
PromptServiceImpl();
NS_DECL_ISUPPORTS
NS_DECL_NSIPROMPTSERVICE
protected:
virtual ~PromptServiceImpl();
};
NS_IMPL_ISUPPORTS1(PromptServiceImpl, nsIPromptService)
PromptServiceImpl::PromptServiceImpl()
{
NS_INIT_REFCNT();
}
PromptServiceImpl::~PromptServiceImpl()
{
}
/* void alert (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text); */
NS_IMETHODIMP PromptServiceImpl::Alert(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text)
{
printf("PromptServce::Alert(%s)\n", text);
return NS_OK;
}
/* void alertCheck (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP PromptServiceImpl::AlertCheck(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue)
{
printf("PromptServce::AlertCheck(%s)\n", text);
return NS_OK;
}
/* boolean confirm (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text); */
NS_IMETHODIMP PromptServiceImpl::Confirm(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval)
{
printf("PromptServce::Confirm(%s)\n", text);
return NS_OK;
}
/* boolean confirmCheck (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP PromptServiceImpl::ConfirmCheck(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
printf("PromptServce::ConfirmCheck(%s)\n", text);
return NS_OK;
}
/* void confirmEx (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, in unsigned long buttonFlags, in wstring button0Title, in wstring button1Title, in wstring button2Title, in wstring checkMsg, inout boolean checkValue, out PRInt32 buttonPressed); */
NS_IMETHODIMP PromptServiceImpl::ConfirmEx(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 buttonFlags, const PRUnichar *button0Title, const PRUnichar *button1Title, const PRUnichar *button2Title, const PRUnichar *checkMsg, PRBool *checkValue, PRInt32 *buttonPressed)
{
printf("PromptServce::ConfirmEx(%s)\n", text);
return NS_OK;
}
/* boolean prompt (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, inout wstring value, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP PromptServiceImpl::Prompt(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **value, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
printf("PromptServce::ConfirmText(%s)\n", text);
return NS_OK;
}
/* boolean promptUsernameAndPassword (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, inout wstring username, inout wstring password, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP PromptServiceImpl::PromptUsernameAndPassword(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **username, PRUnichar **password, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
return NS_OK;
}
/* boolean promptPassword (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, inout wstring password, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP PromptServiceImpl::PromptPassword(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **password, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
return NS_OK;
}
/* boolean select (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, in PRUint32 count, [array, size_is (count)] in wstring selectList, out long outSelection); */
NS_IMETHODIMP PromptServiceImpl::Select(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 count, const PRUnichar **selectList, PRInt32 *outSelection, PRBool *_retval)
{
return NS_OK;
}
////////////////////////////////////////////
NS_DEF_FACTORY(PromptService, PromptServiceImpl);
nsresult NS_NewPromptServiceFactory(nsIFactory **aResult)
{
nsresult rv = NS_OK;
nsIFactory *inst = new nsPromptServiceFactory;
if (inst == nsnull)
rv = NS_ERROR_OUT_OF_MEMORY;
else
NS_ADDREF(inst);
*aResult = inst;
return rv;
}

Просмотреть файл

@ -1,49 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef PROMPTSERVICE_H
#define PROMPTSERVICE_H
#include "nsIFactory.h"
extern nsresult NS_NewPromptServiceFactory(nsIFactory **aResult);
#define NS_PROMPTSERVICE_CID \
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
#endif

Просмотреть файл

@ -1,323 +0,0 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
*/
// Local Includes
#include "nsIGenericFactory.h"
#include "nsIComponentManager.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIURI.h"
#include "nsIWebProgress.h"
#include "nsIDocShellTreeItem.h"
#include "nsIRequest.h"
#include "nsIChannel.h"
#include "nsIDOMWindow.h"
#include "nsCWebBrowser.h"
#include "nsWidgetsCID.h"
#include "nsIWebBrowserSetup.h"
#include "gtkEmbed.h"
#include "WebBrowserChrome.h"
WebBrowserChrome::WebBrowserChrome()
{
NS_INIT_REFCNT();
mNativeWindow = nsnull;
}
WebBrowserChrome::~WebBrowserChrome()
{
}
//*****************************************************************************
// WebBrowserChrome::nsISupports
//*****************************************************************************
NS_IMPL_ADDREF(WebBrowserChrome)
NS_IMPL_RELEASE(WebBrowserChrome)
NS_INTERFACE_MAP_BEGIN(WebBrowserChrome)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) //optional
// NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_END
//*****************************************************************************
// WebBrowserChrome::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
*aInstancePtr = 0;
if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
if (mWebBrowser)
return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, aInstancePtr);
}
//*****************************************************************************
// WebBrowserChrome::nsIWebBrowserChrome
//*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
NS_ENSURE_TRUE(mWebBrowser, NS_ERROR_NOT_INITIALIZED);
*aWebBrowser = mWebBrowser;
NS_IF_ADDREF(*aWebBrowser);
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser)
{
NS_ENSURE_ARG(aWebBrowser); // Passing nsnull is NOT OK
NS_ENSURE_TRUE(mWebBrowser, NS_ERROR_NOT_INITIALIZED);
NS_ERROR("Who be calling me");
mWebBrowser = aWebBrowser;
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::GetChromeFlags(PRUint32* aChromeMask)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowserChrome::SetChromeFlags(PRUint32 aChromeMask)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowserChrome::CreateBrowser(PRInt32 aX, PRInt32 aY,
PRInt32 aCX, PRInt32 aCY,
nsIWebBrowser **aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = nsnull;
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
if (!mWebBrowser)
return NS_ERROR_FAILURE;
mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this));
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser);
dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
mBaseWindow = do_QueryInterface(mWebBrowser);
mNativeWindow = ::CreateNativeWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this));
if (!mNativeWindow)
return NS_ERROR_FAILURE;
mBaseWindow->InitWindow( mNativeWindow,
nsnull,
0, 0, 450, 450);
mBaseWindow->Create();
// Configure what the web browser can and cannot do
nsCOMPtr<nsIWebBrowserSetup> webBrowserAsSetup(do_QueryInterface(mWebBrowser));
webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS, PR_FALSE);
// Disable global history since we don't have profile-relative file locations
webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_USE_GLOBAL_HISTORY, PR_FALSE);
*aWebBrowser = mWebBrowser;
NS_ADDREF(*aWebBrowser);
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::CreateBrowserWindow(PRUint32 chromeMask,
PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nsIWebBrowser **aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = nsnull;
nsresult rv;
nsCOMPtr<nsIWebBrowserChrome> parent;
nsCOMPtr<nsIWebBrowserChrome> newChrome;
if (chromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT)
parent = dont_QueryInterface(NS_STATIC_CAST(nsIWebBrowserChrome*, this));
rv = ::CreateBrowserWindow(chromeMask, parent, getter_AddRefs(newChrome));
if (NS_SUCCEEDED(rv) && newChrome)
newChrome->GetWebBrowser(aWebBrowser);
return rv;
}
NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::ShowAsModal(void)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::IsWindowModal(PRBool *_retval)
{
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::ExitModalEventLoop(nsresult aStatus)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//*****************************************************************************
// WebBrowserChrome::nsIWebBrowserChromeFocus
//*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::FocusNextElement()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::FocusPrevElement()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//*****************************************************************************
// WebBrowserChrome::nsIWebProgressListener
//*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::OnProgressChange(nsIWebProgress *progress, nsIRequest *request,
PRInt32 curSelfProgress, PRInt32 maxSelfProgress,
PRInt32 curTotalProgress, PRInt32 maxTotalProgress)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIRequest *request,
PRInt32 progressStateFlags, PRUint32 status)
{
if ((progressStateFlags & STATE_STOP) && (progressStateFlags & STATE_IS_REQUEST))
{
}
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *location)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
WebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsresult aStatus,
const PRUnichar* aMessage)
{
return NS_OK;
}
NS_IMETHODIMP
WebBrowserChrome::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 state)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//*****************************************************************************
// WebBrowserChrome::nsIEmbeddingSiteWindow
//*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SetFocus()
{
return mBaseWindow->SetFocus();
}
NS_IMETHODIMP WebBrowserChrome::GetVisibility(PRBool *aVisibility)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SetVisibility(PRBool aVisibility)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::GetTitle(PRUnichar** aTitle)
{
NS_ENSURE_ARG_POINTER(aTitle);
*aTitle = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SetTitle(const PRUnichar* aTitle)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::GetSiteWindow(void ** aSiteWindow)
{
NS_ENSURE_ARG_POINTER(aSiteWindow);
*aSiteWindow = mNativeWindow;
return NS_OK;
}

Просмотреть файл

@ -1,77 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
*/
#ifndef __WebBrowserChrome__
#define __WebBrowserChrome__
#include "nsCOMPtr.h"
#include "nsIGenericFactory.h"
#include "nsString.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebBrowserChromeFocus.h"
#include "nsIDocShell.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerFile.h"
#include "nsIBaseWindow.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWebProgressListener.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPrompt.h"
#include "nsIWebBrowser.h"
#include "nsVoidArray.h"
class WebBrowserChrome : public nsIWebBrowserChrome,
public nsIWebBrowserChromeFocus,
public nsIWebProgressListener,
public nsIEmbeddingSiteWindow,
// public nsIPrompt,
public nsIInterfaceRequestor
{
public:
WebBrowserChrome();
virtual ~WebBrowserChrome();
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIEMBEDDINGSITEWINDOW
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
// NS_DECL_NSIPROMPT
NS_DECL_NSIINTERFACEREQUESTOR
nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY,
nsIWebBrowser **aBrowser);
protected:
nativeWindow mNativeWindow;
nsCOMPtr<nsIWebBrowser> mWebBrowser;
nsCOMPtr<nsIBaseWindow> mBaseWindow;
nsCOMPtr<nsIWebBrowserChrome> mTopWindow;
};
#endif /* __WebBrowserChrome__ */

Просмотреть файл

@ -1,60 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIWebBrowserChrome.h"
#include "WindowCreator.h"
#include "gtkEmbed.h"
WindowCreator::WindowCreator() {
NS_INIT_REFCNT();
}
WindowCreator::~WindowCreator() {
}
NS_IMPL_ISUPPORTS1(WindowCreator, nsIWindowCreator)
NS_IMETHODIMP
WindowCreator::CreateChromeWindow(nsIWebBrowserChrome *parent,
PRUint32 chromeFlags,
nsIWebBrowserChrome **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
::CreateBrowserWindow(PRInt32(chromeFlags), parent, _retval);
return *_retval ? NS_OK : NS_ERROR_FAILURE;
}

Просмотреть файл

@ -1,56 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __WindowCreator_h_
#define __WindowCreator_h_
#include "nsIWindowCreator.h"
class WindowCreator :
public nsIWindowCreator
{
public:
WindowCreator();
virtual ~WindowCreator();
NS_DECL_ISUPPORTS
NS_DECL_NSIWINDOWCREATOR
};
#endif

Просмотреть файл

@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "prtypes.h"
#include "nsIBaseWindow.h"
// just a couple of global functions shared between main.cpp
// and WebBrowserChrome.cpp
class nsIWebBrowserChrome;
// a little ooky, but new windows gotta come from somewhere
nsresult CreateBrowserWindow(PRUint32 aChromeFlags,
nsIWebBrowserChrome *aParent, nsIWebBrowserChrome **aNewWindow);
nativeWindow CreateNativeWindow(nsIWebBrowserChrome* chrome);

Просмотреть файл

@ -1,440 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//
// What follows is a hacked version the the sample hello
// world gtk app found: http://www.gtk.org/tutorial/gtk_tut-2.html
//
#include <gtk/gtk.h>
#include "gtkEmbed.h"
#include "nsCOMPtr.h"
#include "nsISimpleEnumerator.h"
#include "nsEmbedAPI.h"
#include "WebBrowserChrome.h"
#include "WindowCreator.h"
#include "PromptService.h"
#include <nsIEventQueueService.h>
#include <nsIServiceManager.h>
#include <nsIWindowWatcher.h>
#include <nsIPref.h>
// For getenv()
#include "prenv.h"
// for profiles
#include <nsMPFileLocProvider.h>
#ifdef NS_TRACE_MALLOC
#include "nsTraceMalloc.h"
#endif
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
static gint io_identifier = 0;
static char *sWatcherContractID = "@mozilla.org/embedcomp/window-watcher;1";
static nsIPref *sPrefs = nsnull;
typedef struct
{
GtkWidget *window;
GtkWidget *urlEntry;
GtkWidget *box;
GtkWidget *view;
GtkWidget *memUsageDumpBtn;
nsIWebBrowserChrome *chrome;
} MyBrowser;
void destroy( GtkWidget *widget, MyBrowser* data )
{
PRBool dontQuit;
printf("Destroying created widgets\n");
gtk_widget_destroy( data->window );
gtk_widget_destroy( data->urlEntry );
gtk_widget_destroy( data->box );
gtk_widget_destroy( data->memUsageDumpBtn );
// gtk_widget_destroy( data->view );
free (data);
dontQuit = PR_FALSE;
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(sWatcherContractID));
if (wwatch) {
nsCOMPtr<nsISimpleEnumerator> list;
wwatch->GetWindowEnumerator(getter_AddRefs(list));
if (list)
list->HasMoreElements(&dontQuit);
}
if (!dontQuit)
gtk_main_quit();
}
gint delete_event( GtkWidget *widget, GdkEvent *event, MyBrowser* data )
{
printf("Releasing chrome...");
NS_RELEASE(data->chrome);
printf("done.\n");
return(FALSE);
}
void
dump_mem_clicked_cb(GtkButton *button, nsIWebBrowserChrome *browser)
{
g_print("dumping memory usage:\n");
system("ps -eo \"%c %z\" | grep gtkEmbed");
#ifdef NS_TRACE_MALLOC
// dump detailed information, too
NS_TraceMallocDumpAllocations("allocations.log");
#endif
}
void
url_activate_cb( GtkEditable *widget, nsIWebBrowserChrome *browser)
{
gchar *text = gtk_editable_get_chars(widget, 0, -1);
g_print("loading url %s\n", text);
if (browser)
{
nsCOMPtr<nsIWebBrowser> webBrowser;
browser->GetWebBrowser(getter_AddRefs(webBrowser));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(webBrowser));
if (webNav)
webNav->LoadURI(NS_ConvertASCIItoUCS2(text).get(), nsIWebNavigation::LOAD_FLAGS_NONE);
}
g_free(text);
}
static void
handle_event_queue(gpointer data, gint source, GdkInputCondition condition)
{
nsIEventQueue *eventQueue = (nsIEventQueue *)data;
eventQueue->ProcessPendingEvents();
}
/* InitializeWindowCreator creates and hands off an object with a callback
to a window creation function. This will be used by Gecko C++ code
(never JS) to create new windows when no previous window is handy
to begin with. This is done in a few exceptional cases, like PSM code.
Failure to set this callback will only disable the ability to create
new windows under these circumstances. */
nsresult InitializeWindowCreator()
{
// create an nsWindowCreator and give it to the WindowWatcher service
WindowCreator *creatorCallback = new WindowCreator();
if (creatorCallback) {
nsCOMPtr<nsIWindowCreator> windowCreator(dont_QueryInterface(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)));
if (windowCreator) {
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(sWatcherContractID));
if (wwatch) {
wwatch->SetWindowCreator(windowCreator);
return NS_OK;
}
}
}
return NS_ERROR_FAILURE;
}
nsresult CreateBrowserWindow(PRUint32 aChromeFlags,
nsIWebBrowserChrome *aParent,
nsIWebBrowserChrome **aNewWindow)
{
WebBrowserChrome * chrome = new WebBrowserChrome();
if (!chrome)
return NS_ERROR_FAILURE;
CallQueryInterface(NS_STATIC_CAST(nsIWebBrowserChrome *, chrome), aNewWindow);
// chrome->SetChromeFlags(aChromeFlags);
nsCOMPtr<nsIWebBrowser> newBrowser;
chrome->CreateBrowser(-1, -1, -1, -1, getter_AddRefs(newBrowser));
if (!newBrowser)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(newBrowser);
baseWindow->SetPositionAndSize(0,
0,
430,
430,
PR_TRUE);
baseWindow->SetVisibility(PR_TRUE);
GtkWidget *widget;
baseWindow->GetParentNativeWindow((void**)&widget);
gtk_widget_show (widget); // should this function do this?
return NS_OK;
}
nsresult OpenWebPage(char* url)
{
nsresult rv;
nsCOMPtr<nsIWebBrowserChrome> chrome;
rv = CreateBrowserWindow(nsIWebBrowserChrome::CHROME_ALL, nsnull,
getter_AddRefs(chrome));
if (NS_SUCCEEDED(rv)) {
// Start loading a page
nsCOMPtr<nsIWebBrowser> newBrowser;
chrome->GetWebBrowser(getter_AddRefs(newBrowser));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(newBrowser));
return webNav->LoadURI(NS_ConvertASCIItoUCS2(url).get(), nsIWebNavigation::LOAD_FLAGS_NONE);
}
return rv;
}
nativeWindow CreateNativeWindow(nsIWebBrowserChrome* chrome)
{
MyBrowser* browser = (MyBrowser*) malloc (sizeof(MyBrowser) );
if (!browser)
return nsnull;
browser->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
browser->urlEntry = gtk_entry_new();
browser->box = gtk_vbox_new(FALSE, 0);
browser->view = gtk_event_box_new();
browser->memUsageDumpBtn = gtk_button_new_with_label("Dump Memory Usage");
browser->chrome = chrome; // take ownership!
NS_ADDREF(chrome); // no, really take it! (released in delete_event)
if (!browser->window || !browser->urlEntry || !browser->box ||
!browser->view || !browser->memUsageDumpBtn)
return nsnull;
/* Put the box into the main window. */
gtk_container_add (GTK_CONTAINER (browser->window),browser->box);
gtk_box_pack_start(GTK_BOX(browser->box), browser->urlEntry, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(browser->box), browser->view, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(browser->box), browser->memUsageDumpBtn, FALSE, FALSE, 5);
gtk_signal_connect (GTK_OBJECT (browser->window),
"destroy",
GTK_SIGNAL_FUNC (destroy),
browser);
gtk_signal_connect (GTK_OBJECT (browser->window),
"delete_event",
GTK_SIGNAL_FUNC (delete_event),
browser);
gtk_signal_connect(GTK_OBJECT(browser->urlEntry),
"activate",
GTK_SIGNAL_FUNC(url_activate_cb),
chrome);
gtk_signal_connect(GTK_OBJECT(browser->memUsageDumpBtn),
"clicked",
GTK_SIGNAL_FUNC(dump_mem_clicked_cb),
chrome);
gtk_widget_set_usize(browser->view, 430, 430);
gtk_window_set_title (GTK_WINDOW (browser->window), "Embedding is Fun!");
gtk_window_set_default_size (GTK_WINDOW(browser->window), 450, 450);
gtk_container_set_border_width (GTK_CONTAINER (browser->window), 10);
gtk_widget_realize (browser->window);
gtk_widget_show (browser->memUsageDumpBtn);
gtk_widget_show (browser->urlEntry);
gtk_widget_show (browser->box);
gtk_widget_show (browser->view);
gtk_widget_show (browser->window);
return browser->view;
}
// Initialize profiles, need this for SSL to work.
// Borrowed from TestGtkEmbed.cpp, EmbedPrivate.cpp.
nsresult InitProfile()
{
nsresult rv;
char *home_path = home_path = PR_GetEnv("HOME");
char *sProfileDir = g_strdup_printf("%s/%s", home_path, ".gtkEmbed");
char *sProfileName = g_strdup_printf("%s", "gtkEmbed");
// initialize profiles
nsCOMPtr<nsILocalFile> profileDir;
PRBool exists = PR_FALSE;
PRBool isDir = PR_FALSE;
profileDir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
rv = profileDir->InitWithPath(sProfileDir);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
profileDir->Exists(&exists);
profileDir->IsDirectory(&isDir);
// if it exists and it isn't a directory then give up now.
if (!exists) {
rv = profileDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
if NS_FAILED(rv) {
return NS_ERROR_FAILURE;
}
}
else if (exists && !isDir) {
return NS_ERROR_FAILURE;
}
// actually create the loc provider and initialize prefs.
nsMPFileLocProvider *locProvider;
// Set up the loc provider. This has a really strange ownership
// model. When I initialize it it will register itself with the
// directory service. The directory service becomes the owning
// reference. So, when that service is shut down this object will
// be destroyed. It's not leaking here.
locProvider = new nsMPFileLocProvider;
rv = locProvider->Initialize(profileDir, sProfileName);
// get prefs
nsCOMPtr<nsIPref> pref;
pref = do_GetService(NS_PREF_CONTRACTID);
if (!pref)
return NS_ERROR_FAILURE;
sPrefs = pref.get();
NS_ADDREF(sPrefs);
sPrefs->ResetPrefs();
sPrefs->ReadUserPrefs(nsnull);
return NS_OK;
}
nsresult InitPromptService()
{
nsresult rv;
nsCOMPtr<nsIFactory> promptFactory;
rv = NS_NewPromptServiceFactory(getter_AddRefs(promptFactory));
if (NS_SUCCEEDED(rv))
{
nsComponentManager::RegisterFactory(kPromptServiceCID,
"Prompt Service",
"@mozilla.org/embedcomp/prompt-service;1",
promptFactory,
PR_TRUE); // replace existing
}
return NS_OK;
}
int main( int argc, char *argv[] )
{
#ifdef NS_TRACE_MALLOC
argc = NS_TraceMallocStartupArgs(argc, argv);
#endif
// Get startup URL.
char *loadURLStr;
if (argc > 1)
loadURLStr = argv[1];
else
loadURLStr = "http://www.mozilla.org/projects/embedding";
// Initialize Embedding APIs.
NS_InitEmbedding(nsnull, nsnull);
// Initialize profile, we need this for SSL to work.
nsresult rv = InitProfile();
if (NS_FAILED(rv))
NS_WARNING("Warning: Failed to start up profiles.\n");
// Initialise the prompt service
rv = InitPromptService();
if (NS_FAILED(rv))
NS_WARNING("Warning: Failed to register prompt service.\n");
InitializeWindowCreator();
// set up the thread event queue
nsCOMPtr<nsIEventQueueService> eventQService = do_GetService(kEventQueueServiceCID);
if (!eventQService) return (-1);
nsCOMPtr< nsIEventQueue> eventQueue;
eventQService->GetThreadEventQueue( NS_CURRENT_THREAD, getter_AddRefs(eventQueue));
if (!eventQueue) return (-1);
io_identifier = gdk_input_add( eventQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
handle_event_queue,
eventQueue);
/* This is called in all GTK applications. Arguments are parsed
* from the command line and are returned to the application. */
gtk_set_locale();
gtk_init(&argc, &argv);
if ( NS_FAILED( OpenWebPage(loadURLStr) ))
return (-1);
/* All GTK applications must have a gtk_main(). Control ends here
* and waits for an event to occur (like a key press or
* mouse event). */
gtk_main ();
gtk_input_remove(io_identifier);
printf("Cleaning up embedding\n");
NS_TermEmbedding();
#ifdef NS_TRACE_MALLOC
NS_TraceMallocShutdown();
#endif
return(0);
}