Hookup reload button to session History

This commit is contained in:
radha%netscape.com 1999-06-24 20:18:28 +00:00
parent 5d5f1d59f3
commit d849323c55
3 changed files with 81 additions and 9 deletions

View File

@ -329,10 +329,12 @@ nsBrowserAppCore::Back()
}
NS_IMETHODIMP
nsBrowserAppCore::Reload(nsURLReloadType aType)
nsBrowserAppCore::Reload(PRInt32 aType)
{
printf("fix me!\n");
NS_ASSERTION(0,"fix me!");
#ifndef NECKO
if (mContentAreaWebShell)
Reload(mContentAreaWebShell, (nsURLReloadType) aType);
#endif /* NECKO */
return NS_OK;
}
@ -1171,6 +1173,8 @@ end:
//Disable the Stop button
setAttribute( mWebShell, "canStop", "disabled", "true" );
//Enable the reload button
setAttribute(mWebShell, "canReload", "disabled", "");
return NS_OK;
}
@ -1268,6 +1272,16 @@ nsBrowserAppCore::GoForward(nsIWebShell * aPrev)
return NS_OK;
}
#ifndef NECKO
NS_IMETHODIMP
nsBrowserAppCore::Reload(nsIWebShell * aPrev, nsURLReloadType aType)
{
if (mSHistory)
mSHistory->Reload(aPrev, aType);
return NS_OK;
}
#endif /* NECKO */
NS_IMETHODIMP
nsBrowserAppCore::add(nsIWebShell * aWebShell)
@ -1279,11 +1293,11 @@ nsBrowserAppCore::add(nsIWebShell * aWebShell)
}
NS_IMETHODIMP
nsBrowserAppCore::Goto(PRInt32 aGotoIndex, nsIWebShell * aPrev)
nsBrowserAppCore::Goto(PRInt32 aGotoIndex, nsIWebShell * aPrev, PRBool aIsReloading)
{
nsresult rv;
if (mSHistory)
rv = mSHistory->Goto(aGotoIndex, aPrev);
rv = mSHistory->Goto(aGotoIndex, aPrev, PR_FALSE);
return rv;
}

View File

@ -67,7 +67,7 @@ class nsBrowserAppCore : public nsBaseAppCore,
NS_IMETHOD Back();
NS_IMETHOD Forward();
NS_IMETHOD Reload(nsURLReloadType aType);
NS_IMETHOD Reload(PRInt32 aType);
NS_IMETHOD Stop();
NS_IMETHOD WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm);
@ -133,9 +133,12 @@ class nsBrowserAppCore : public nsBaseAppCore,
// nsISessionHistory methods
NS_IMETHOD GoForward(nsIWebShell * prev);
NS_IMETHOD GoForward(nsIWebShell * aPrev);
NS_IMETHOD GoBack(nsIWebShell * prev);
NS_IMETHOD GoBack(nsIWebShell * aPrev);
#ifndef NECKO
NS_IMETHOD Reload(nsIWebShell * aPrev, nsURLReloadType aType);
#endif /* NECKO */
NS_IMETHOD canForward(PRBool &aResult);
@ -143,7 +146,7 @@ class nsBrowserAppCore : public nsBaseAppCore,
NS_IMETHOD add(nsIWebShell * aWebShell);
NS_IMETHOD Goto(PRInt32 aHistoryIndex, nsIWebShell * prev);
NS_IMETHOD Goto(PRInt32 aHistoryIndex, nsIWebShell * aPrev, PRBool aIsReloading);
NS_IMETHOD getHistoryLength(PRInt32 & aResult);

View File

@ -242,6 +242,60 @@ BrowserAppCoreForward(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
}
//
// Native method Reload
//
PR_STATIC_CALLBACK(JSBool)
BrowserAppCoreReload(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)nsJSUtils::nsGetNativeThis(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 b0;
*rval = JSVAL_NULL;
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
nsIScriptSecurityManager *secMan;
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.reload", &ok);
if (!ok) {
//Need to throw error here
return JS_FALSE;
}
NS_RELEASE(secMan);
}
else {
return JS_FALSE;
}
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (NS_OK != nativeThis->Reload(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function reload requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Stop
//
@ -1416,6 +1470,7 @@ static JSFunctionSpec BrowserAppCoreMethods[] =
{
{"back", BrowserAppCoreBack, 0},
{"forward", BrowserAppCoreForward, 0},
{"reload", BrowserAppCoreReload, 1},
{"stop", BrowserAppCoreStop, 0},
{"loadUrl", BrowserAppCoreLoadUrl, 1},
{"loadInitialPage", BrowserAppCoreLoadInitialPage, 0},