fixes bug 106940 "ActiveX browser should use the newer nsIPrefService APIs instead of nsIPref" patch by gerlofs@us.ibm.com, r=mkaply, sr=darin

This commit is contained in:
darin%meer.net 2004-07-20 18:31:57 +00:00
Родитель 540caa8b2a
Коммит 494fe3ed49
6 изменённых файлов: 45 добавлений и 40 удалений

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

@ -42,7 +42,8 @@
#include <mshtml.h>
#include "nsIWebNavigation.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefLocalizedString.h"
#include "nsIDOMWindow.h"
#include "nsIBaseWindow.h"
#include "nsIWindowWatcher.h"
@ -92,8 +93,8 @@ public:
virtual nsresult GetWebNavigation(nsIWebNavigation **aWebNav) = 0;
// Return the nsIDOMWindow object
virtual nsresult GetDOMWindow(nsIDOMWindow **aDOMWindow) = 0;
// Return the nsIPref object
virtual nsresult GetPrefs(nsIPref **aPrefs) = 0;
// Return the nsIPrefBranch object
virtual nsresult GetPrefs(nsIPrefBranch **aPrefBranch) = 0;
// Return the valid state of the browser
virtual PRBool BrowserIsValid() = 0;
@ -173,15 +174,22 @@ public:
CComBSTR bstrUrl(L"http://home.netscape.com/");
// Find the home page stored in prefs
nsCOMPtr<nsIPref> prefs;
if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefs))))
nsCOMPtr<nsIPrefBranch> prefBranch;
if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefBranch))))
{
nsXPIDLString homePage;
nsresult rv;
rv = prefs->GetLocalizedUnicharPref("browser.startup.homepage", getter_Copies(homePage));
if (rv == NS_OK)
nsCOMPtr<nsIPrefLocalizedString> homePage;
prefBranch->GetComplexValue("browser.startup.homepage",
NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(homePage));
if (homePage)
{
bstrUrl = homePage.get();;
nsXPIDLString homePageString;
nsresult rv = homePage->ToString(getter_Copies(homePageString));
if (NS_SUCCEEDED(rv))
{
bstrUrl = homePageString.get();
}
}
}
@ -197,14 +205,16 @@ public:
CComBSTR bstrUrl(L"http://search.netscape.com/");
//NOTE: This code has not been implemented yet
#if 0
// Find the home page stored in prefs
nsCOMPtr<nsIPref> prefs;
if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefs))))
nsCOMPtr<nsIPrefBranch> prefBranch;
if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefBranch))))
{
// TODO find and navigate to the search page stored in prefs
// and not this hard coded address
}
#endif
// Navigate to the search page
Navigate(bstrUrl, NULL, NULL, NULL, NULL);

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

@ -86,7 +86,6 @@ static HANDLE s_hHackedNonReentrancy = NULL;
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
static NS_DEFINE_CID(kHelperAppLauncherDialogCID, NS_HELPERAPPLAUNCHERDIALOG_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
class PrintListener : public nsIWebProgressListener
{
@ -1032,7 +1031,7 @@ HRESULT CMozillaBrowser::Initialize()
rv = NS_InitEmbedding(binDir, directoryProvider);
// Load preferences service
mPrefs = do_GetService(kPrefCID, &rv);
mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
{
NG_ASSERT(0);
@ -1122,7 +1121,7 @@ HRESULT CMozillaBrowser::Terminate()
{
#endif
mPrefs = nsnull;
mPrefBranch = nsnull;
NS_TermEmbedding();
#ifdef HACK_NON_REENTRANCY
@ -1501,8 +1500,8 @@ HRESULT CMozillaBrowser::PrintDocument(BOOL promptUser)
// Disable print progress dialog (XUL)
PRBool oldShowPrintProgress = FALSE;
const char *kShowPrintProgressPref = "print.show_print_progress";
mPrefs->GetBoolPref(kShowPrintProgressPref, &oldShowPrintProgress);
mPrefs->SetBoolPref(kShowPrintProgressPref, PR_FALSE);
mPrefBranch->GetBoolPref(kShowPrintProgressPref, &oldShowPrintProgress);
mPrefBranch->SetBoolPref(kShowPrintProgressPref, PR_FALSE);
// Print
PrintListener *listener = new PrintListener;
@ -1518,7 +1517,7 @@ HRESULT CMozillaBrowser::PrintDocument(BOOL promptUser)
{
printSettings->SetPrintSilent(oldPrintSilent);
}
mPrefs->SetBoolPref(kShowPrintProgressPref, oldShowPrintProgress);
mPrefBranch->SetBoolPref(kShowPrintProgressPref, oldShowPrintProgress);
return S_OK;
}
@ -1727,12 +1726,12 @@ nsresult CMozillaBrowser::GetDOMWindow(nsIDOMWindow **aDOMWindow)
return mWebBrowser->GetContentDOMWindow(aDOMWindow);
}
nsresult CMozillaBrowser::GetPrefs(nsIPref **aPrefs)
nsresult CMozillaBrowser::GetPrefs(nsIPrefBranch **aPrefBranch)
{
if (mPrefs)
*aPrefs = mPrefs;
NS_IF_ADDREF(*aPrefs);
return (*aPrefs) ? NS_OK : NS_ERROR_FAILURE;
if (mPrefBranch)
*aPrefBranch = mPrefBranch;
NS_IF_ADDREF(*aPrefBranch);
return (*aPrefBranch) ? NS_OK : NS_ERROR_FAILURE;
}
PRBool CMozillaBrowser::BrowserIsValid()

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

@ -376,7 +376,7 @@ protected:
nsCOMPtr<nsIDOMNode> mContextNode;
// Prefs service
nsCOMPtr<nsIPref> mPrefs;
nsCOMPtr<nsIPrefBranch> mPrefBranch;
// Flag to indicate if browser is created or not
BOOL mValidBrowserFlag;
@ -423,7 +423,7 @@ public:
// IWebBrowserImpl overrides
virtual nsresult GetWebNavigation(nsIWebNavigation **aWebNav);
virtual nsresult GetDOMWindow(nsIDOMWindow **aDOMWindow);
virtual nsresult GetPrefs(nsIPref **aPref);
virtual nsresult GetPrefs(nsIPrefBranch **aPrefBranch);
virtual PRBool BrowserIsValid();
// IWebBrowser
virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch __RPC_FAR *__RPC_FAR *ppDisp);

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

@ -73,7 +73,8 @@
#include "nsIHTTPChannel.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIURL.h"
#include "nsIBaseWindow.h"
#include "nsIWebBrowser.h"

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

@ -44,12 +44,12 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIServiceManagerUtils.h"
#include "nsString.h"
#include "nsIPref.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "XPCBrowser.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
IEBrowser::IEBrowser()
{
@ -90,15 +90,10 @@ nsresult IEBrowser::GetDOMWindow(nsIDOMWindow **aDOMWindow)
return (*aDOMWindow) ? NS_OK : NS_ERROR_FAILURE;
}
// Return the nsIPref object
nsresult IEBrowser::GetPrefs(nsIPref **aPrefs)
// Return the nsIPrefBranch object
nsresult IEBrowser::GetPrefs(nsIPrefBranch **aPrefBranch)
{
NS_ENSURE_ARG_POINTER(aPrefs);
nsresult rv;
nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv);
*aPrefs = prefs;
NS_IF_ADDREF(*aPrefs);
return rv;
return CallGetService(NS_PREFSERVICE_CONTRACTID, aPrefBranch);
}
// Return the valid state of the browser

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

@ -76,8 +76,8 @@ public:
virtual nsresult GetWebNavigation(nsIWebNavigation **aWebNav);
// Return the nsIDOMWindow object
virtual nsresult GetDOMWindow(nsIDOMWindow **aDOMWindow);
// Return the nsIPref object
virtual nsresult GetPrefs(nsIPref **aPrefs);
// Return the nsIPrefBranch object
virtual nsresult GetPrefs(nsIPrefBranch **aPrefBranch);
// Return the valid state of the browser
virtual PRBool BrowserIsValid();
};