Bug 73951 - Enable global history by default for embedding apps. r=valeski/sr=rpotts
git-svn-id: svn://10.0.0.236/trunk@95547 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
275058c8c5
commit
ae35e88c15
@ -36,8 +36,6 @@
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIDocShellHistory.h"
|
||||
#include "nsIGlobalHistory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIClipboardCommands.h"
|
||||
#include "nsIWalletService.h"
|
||||
@ -160,22 +158,11 @@ void CBrowserShell::FinishCreateSelf()
|
||||
mWebBrowser->SetContainerWindow(ourChrome);
|
||||
mWebBrowserAsBaseWin->InitWindow(aWidget->GetNativeData(NS_NATIVE_WIDGET), nsnull, r.x, r.y, r.width, r.height);
|
||||
mWebBrowserAsBaseWin->Create();
|
||||
|
||||
|
||||
nsWeakPtr weakling(dont_AddRef(NS_GetWeakReference(ourChrome)));
|
||||
rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Call to AddWebBrowserListener failed");
|
||||
|
||||
// Set the global history
|
||||
nsCOMPtr<nsIDocShell> docShell(do_GetInterface(mWebBrowser));
|
||||
ThrowIfNil_(docShell);
|
||||
nsCOMPtr<nsIDocShellHistory> dsHistory(do_QueryInterface(docShell));
|
||||
if (dsHistory)
|
||||
{
|
||||
NS_WITH_SERVICE(nsIGlobalHistory, history, NS_GLOBALHISTORY_CONTRACTID, &rv);
|
||||
if (history)
|
||||
dsHistory->SetGlobalHistory(history);
|
||||
}
|
||||
|
||||
|
||||
AdjustFrame();
|
||||
StartRepeating();
|
||||
StartListening();
|
||||
|
||||
@ -26,7 +26,7 @@ VPATH = @srcdir@
|
||||
MODULE = webbrwsr
|
||||
XPIDL_MODULE = webBrowser_core
|
||||
LIBRARY_NAME = nsWebBrowser_s
|
||||
REQUIRES = xpcom string docshell widget layout dom js locale necko uriloader shistory webshell mimetype exthandler timer windowwatcher txtsvc gfx2 wallet windowwatcher
|
||||
REQUIRES = xpcom string docshell widget layout dom js locale necko uriloader shistory webshell mimetype exthandler timer windowwatcher txtsvc gfx2 wallet appcomps
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ interface nsIWebBrowserSetup : nsISupports
|
||||
const unsigned long SETUP_ALLOW_META_REDIRECTS = 3;
|
||||
const unsigned long SETUP_ALLOW_SUBFRAMES = 4;
|
||||
|
||||
|
||||
const unsigned long SETUP_USE_GLOBAL_HISTORY = 256;
|
||||
|
||||
void setProperty(in unsigned long aId, in unsigned long aValue);
|
||||
};
|
||||
@ -44,6 +44,8 @@
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIWebBrowserFocus.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIGlobalHistory.h"
|
||||
#include "nsIDocShellHistory.h"
|
||||
|
||||
// for painting the background window
|
||||
#include "nsIDeviceContext.h"
|
||||
@ -275,6 +277,25 @@ NS_IMETHODIMP nsWebBrowser::UnBindListener(nsISupports *aListener, const nsIID&
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::EnableGlobalHistory(PRBool aEnable)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
nsCOMPtr<nsIDocShellHistory> dsHistory(do_QueryInterface(mDocShell, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aEnable) {
|
||||
NS_WITH_SERVICE(nsIGlobalHistory, history, NS_GLOBALHISTORY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = dsHistory->SetGlobalHistory(history);
|
||||
}
|
||||
else
|
||||
rv = dsHistory->SetGlobalHistory(nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::GetContainerWindow(nsIWebBrowserChrome** aTopWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTopWindow);
|
||||
@ -603,6 +624,8 @@ NS_IMETHODIMP nsWebBrowser::GetDocument(nsIDOMDocument** aDocument)
|
||||
/* void setProperty (in unsigned long aId, in unsigned long aValue); */
|
||||
NS_IMETHODIMP nsWebBrowser::SetProperty(PRUint32 aId, PRUint32 aValue)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
switch (aId)
|
||||
{
|
||||
case nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS:
|
||||
@ -633,11 +656,18 @@ NS_IMETHODIMP nsWebBrowser::SetProperty(PRUint32 aId, PRUint32 aValue)
|
||||
mDocShell->SetAllowSubframes(aValue);
|
||||
}
|
||||
break;
|
||||
case nsIWebBrowserSetup::SETUP_USE_GLOBAL_HISTORY:
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
NS_ENSURE_TRUE((aValue == PR_TRUE || aValue == PR_FALSE), NS_ERROR_INVALID_ARG);
|
||||
rv = EnableGlobalHistory(aValue);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
rv = NS_ERROR_INVALID_ARG;
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
@ -830,6 +860,10 @@ NS_IMETHODIMP nsWebBrowser::Create()
|
||||
mInitInfo->sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mInitInfo->sessionHistory, NS_ERROR_FAILURE);
|
||||
mDocShellAsNav->SetSessionHistory(mInitInfo->sessionHistory);
|
||||
|
||||
// Hook up global history. Do not fail if we can't - just assert.
|
||||
nsresult rv = EnableGlobalHistory(PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "EnableGlobalHistory() failed");
|
||||
|
||||
NS_ENSURE_SUCCESS(mDocShellAsWin->Create(), NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
@ -52,7 +52,6 @@
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
|
||||
class nsWebBrowserFindImpl;
|
||||
|
||||
class nsWebBrowserInitInfo
|
||||
{
|
||||
@ -118,6 +117,7 @@ protected:
|
||||
NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindowInternal **aDomWindow);
|
||||
NS_IMETHOD BindListener(nsISupports *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD UnBindListener(nsISupports *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD EnableGlobalHistory(PRBool aEnable);
|
||||
|
||||
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
||||
|
||||
|
||||
@ -153,6 +153,8 @@ NS_IMETHODIMP WebBrowserChrome::CreateBrowser(PRInt32 aX, PRInt32 aY,
|
||||
// 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);
|
||||
|
||||
@ -76,6 +76,7 @@
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWebBrowserSetup.h"
|
||||
|
||||
#include "nsCWebBrowser.h"
|
||||
|
||||
@ -1398,6 +1399,12 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
|
||||
mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
|
||||
|
||||
webBrowserWin->Create();
|
||||
|
||||
// Disable global history because we don't have profile-relative file locations
|
||||
nsCOMPtr<nsIWebBrowserSetup> setup(do_QueryInterface(mWebBrowser));
|
||||
if (setup)
|
||||
setup->SetProperty(nsIWebBrowserSetup::SETUP_USE_GLOBAL_HISTORY, PR_FALSE);
|
||||
|
||||
mDocShell = do_GetInterface(mWebBrowser);
|
||||
mDocShell->SetAllowPlugins(aAllowPlugins);
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user