Skip to content
Snippets Groups Projects
Commit 1ada415f authored by rods%netscape.com's avatar rods%netscape.com
Browse files

Added some experienmental methods BrowserAppCore

for example: newWindow, exit, close, printPreview
parent f7516c37
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,12 @@ interface BrowserAppCore : BaseAppCore
void setContentWindow(in Window win);
void setWebShellWindow(in Window win);
void newWindow();
void printPreview();
void close();
void exit();
void setDisableCallback(in wstring script);
void setEnableCallback(in wstring script);
......
......@@ -47,6 +47,14 @@ public:
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin)=0;
NS_IMETHOD NewWindow()=0;
NS_IMETHOD PrintPreview()=0;
NS_IMETHOD Close()=0;
NS_IMETHOD Exit()=0;
NS_IMETHOD SetDisableCallback(const nsString& aScript)=0;
NS_IMETHOD SetEnableCallback(const nsString& aScript)=0;
......@@ -60,6 +68,10 @@ public:
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin); \
NS_IMETHOD NewWindow(); \
NS_IMETHOD PrintPreview(); \
NS_IMETHOD Close(); \
NS_IMETHOD Exit(); \
NS_IMETHOD SetDisableCallback(const nsString& aScript); \
NS_IMETHOD SetEnableCallback(const nsString& aScript); \
......@@ -72,6 +84,10 @@ public:
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin) { return _to##SetToolbarWindow(aWin); } \
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin) { return _to##SetContentWindow(aWin); } \
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin) { return _to##SetWebShellWindow(aWin); } \
NS_IMETHOD NewWindow() { return _to##NewWindow(); } \
NS_IMETHOD PrintPreview() { return _to##PrintPreview(); } \
NS_IMETHOD Close() { return _to##Close(); } \
NS_IMETHOD Exit() { return _to##Exit(); } \
NS_IMETHOD SetDisableCallback(const nsString& aScript) { return _to##SetDisableCallback(aScript); } \
NS_IMETHOD SetEnableCallback(const nsString& aScript) { return _to##SetEnableCallback(aScript); } \
......
......@@ -271,6 +271,99 @@ nsBrowserAppCore::SetWebShellWindow(nsIDOMWindow* aWin)
return NS_OK;
}
NS_IMETHODIMP
nsBrowserAppCore::NewWindow()
{
nsresult rv;
nsString controllerCID;
char * urlstr=nsnull;
char * progname = nsnull;
char * width=nsnull, *height=nsnull;
char * iconic_state=nsnull;
nsIAppShellService* appShell = nsnull;
// Default URL if one was not provided in the cmdline
if (nsnull == urlstr)
urlstr = "resource:/res/samples/appshell.html";
else
fprintf(stderr, "URL to load is %s\n", urlstr);
/*
* Create the Application Shell instance...
*/
rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (!NS_SUCCEEDED(rv)) {
goto done;
}
/*
* Post an event to the shell instance to load the AppShell
* initialization routines...
*
* This allows the application to enter its event loop before having to
* deal with GUI initialization...
*/
///write me...
nsIURL* url;
nsIWidget* newWindow;
rv = NS_NewURL(&url, urlstr);
if (NS_FAILED(rv)) {
goto done;
}
/*
* XXX: Currently, the CID for the "controller" is passed in as an argument
* to CreateTopLevelWindow(...). Once XUL supports "controller"
* components this will be specified in the XUL description...
*/
controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081";
appShell->CreateTopLevelWindow(url, controllerCID, newWindow, nsnull);
NS_RELEASE(url);
done:
/* Release the shell... */
if (nsnull != appShell) {
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
return NS_OK;
}
NS_IMETHODIMP
nsBrowserAppCore::PrintPreview()
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserAppCore::Close()
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserAppCore::Exit()
{
nsIAppShellService* appShell = nsnull;
/*
* Create the Application Shell instance...
*/
nsresult rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_SUCCEEDED(rv)) {
appShell->Shutdown();
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
return NS_OK;
}
NS_IMETHODIMP
nsBrowserAppCore::ExecuteScript(nsIScriptContext * aContext, const nsString& aScript)
......
......@@ -64,6 +64,11 @@ class nsBrowserAppCore : public nsBaseAppCore,
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin);
NS_IMETHOD SetDisableCallback(const nsString& aScript);
NS_IMETHOD SetEnableCallback(const nsString& aScript);
NS_IMETHOD NewWindow();
NS_IMETHOD PrintPreview();
NS_IMETHOD Close();
NS_IMETHOD Exit();
// nsIStreamObserver
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
......
......@@ -358,6 +358,138 @@ BrowserAppCoreSetWebShellWindow(JSContext *cx, JSObject *obj, uintN argc, jsval
}
//
// Native method NewWindow
//
PR_STATIC_CALLBACK(JSBool)
BrowserAppCoreNewWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->NewWindow()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function newWindow requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method PrintPreview
//
PR_STATIC_CALLBACK(JSBool)
BrowserAppCorePrintPreview(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->PrintPreview()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function printPreview requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Close
//
PR_STATIC_CALLBACK(JSBool)
BrowserAppCoreClose(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->Close()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function close requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Exit
//
PR_STATIC_CALLBACK(JSBool)
BrowserAppCoreExit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->Exit()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function exit requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetDisableCallback
//
......@@ -468,6 +600,10 @@ static JSFunctionSpec BrowserAppCoreMethods[] =
{"setToolbarWindow", BrowserAppCoreSetToolbarWindow, 1},
{"setContentWindow", BrowserAppCoreSetContentWindow, 1},
{"setWebShellWindow", BrowserAppCoreSetWebShellWindow, 1},
{"newWindow", BrowserAppCoreNewWindow, 0},
{"printPreview", BrowserAppCorePrintPreview, 0},
{"close", BrowserAppCoreClose, 0},
{"exit", BrowserAppCoreExit, 0},
{"setDisableCallback", BrowserAppCoreSetDisableCallback, 1},
{"setEnableCallback", BrowserAppCoreSetEnableCallback, 1},
{0}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment