зеркало из https://github.com/mozilla/gecko-dev.git
184257 - Updating pref callers. r=timeless sr=bzbarsky
This commit is contained in:
Родитель
2a4628f37d
Коммит
6d92f9bd32
|
@ -44,8 +44,6 @@
|
|||
struct JSPrincipals;
|
||||
%}
|
||||
|
||||
interface nsIPref;
|
||||
|
||||
[ptr] native JSPrincipals(JSPrincipals);
|
||||
|
||||
[uuid(ff9313d0-25e1-11d2-8160-006008119d7a)]
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
//////////////////////////
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
#include "nsIURL.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCRT.h"
|
||||
|
@ -111,13 +112,12 @@ nsCodebasePrincipal::CanEnableCapability(const char *capability,
|
|||
if (!mTrusted)
|
||||
{
|
||||
static char pref[] = "signed.applets.codebase_principal_support";
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
PRBool enabled;
|
||||
if (NS_FAILED(prefs->GetBoolPref(pref, &enabled)) || !enabled)
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (!prefBranch)
|
||||
return NS_ERROR_FAILURE;
|
||||
PRBool enabled;
|
||||
if (NS_FAILED(prefBranch->GetBoolPref(pref, &enabled)) || !enabled)
|
||||
{
|
||||
// Deny unless subject is executing from file: or resource:
|
||||
PRBool isFile = PR_FALSE;
|
||||
PRBool isRes = PR_FALSE;
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsString.h"
|
||||
|
@ -222,11 +223,11 @@ NS_IMETHODIMP nsAccessProxy::OnStateChange(nsIWebProgress *aWebProgress,
|
|||
if ((aStateFlags & (STATE_STOP|STATE_START)) && (aStateFlags & STATE_IS_DOCUMENT)) {
|
||||
// Test for built in text to speech or braille display usage preference
|
||||
// If so, attach event handlers to window. If not, don't.
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
nsXPIDLCString textToSpeechEngine, brailleDisplayEngine;
|
||||
if (prefs) {
|
||||
prefs->CopyCharPref("accessibility.usetexttospeech", getter_Copies(textToSpeechEngine));
|
||||
prefs->CopyCharPref("accessibility.usebrailledisplay", getter_Copies(brailleDisplayEngine));
|
||||
if (prefBranch) {
|
||||
prefBranch->GetCharPref("accessibility.usetexttospeech", getter_Copies(textToSpeechEngine));
|
||||
prefBranch->GetCharPref("accessibility.usebrailledisplay", getter_Copies(brailleDisplayEngine));
|
||||
}
|
||||
|
||||
if ((textToSpeechEngine && *textToSpeechEngine) || (brailleDisplayEngine && *brailleDisplayEngine)) {
|
||||
|
|
|
@ -42,9 +42,12 @@
|
|||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// This file implements the nsScriptablePeer object
|
||||
// The naive methods of this class are supposed to
|
||||
// The native methods of this class are supposed to
|
||||
// be callable from JavaScript
|
||||
//
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
|
@ -306,11 +309,11 @@ char* URLName;
|
|||
NS_IMETHODIMP nsScriptablePeer::SetBoolPref(const PRUnichar *aPrefName, PRBool aVal)
|
||||
{
|
||||
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefs) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch) {
|
||||
nsCString prefName;
|
||||
prefName.AssignWithConversion(aPrefName);
|
||||
prefs->SetBoolPref(prefName.get(), aVal);
|
||||
prefBranch->SetBoolPref(prefName.get(), aVal);
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#include "nsMemory.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
|
||||
class nsPluginInstance;
|
||||
|
@ -107,4 +106,4 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "nsMemory.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
// service manager which will give the access to all public browser services
|
||||
// we will use memory service as an illustration
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#include "nsLayoutCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDebugObject, nsIDebugObject)
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#include "nsLayoutCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDebugObject, nsIDebugObject)
|
||||
|
||||
|
|
|
@ -28,13 +28,15 @@
|
|||
#include "nscore.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "prlog.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
|
@ -47,7 +49,6 @@
|
|||
#define MAXCOL 4096 // Maximum columns in line buffer
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
static NS_DEFINE_IID(kILineTermIID, MOZILINETERM_IID);
|
||||
static NS_DEFINE_IID(kILineTermAuxIID, MOZILINETERMAUX_IID);
|
||||
|
@ -139,15 +140,13 @@ NS_IMETHODIMP mozLineTerm::ArePrefsSecure(PRBool *_retval)
|
|||
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
nsIPref* prefService;
|
||||
nsServiceManager::GetService(kPrefServiceCID, NS_GET_IID(nsIPref),
|
||||
(nsISupports**) &prefService);
|
||||
if (!prefService)
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefBranch)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Check if Components JS object is secure
|
||||
PRBool checkXPC;
|
||||
result = prefService->GetBoolPref("security.checkxpconnect", &checkXPC);
|
||||
result = prefBranch->GetBoolPref("security.checkxpconnect", &checkXPC);
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -163,33 +162,30 @@ NS_IMETHODIMP mozLineTerm::ArePrefsSecure(PRBool *_retval)
|
|||
|
||||
nsCAutoString secString ("security.policy.");
|
||||
/* Get global policy name. */
|
||||
char *policyStr;
|
||||
nsXPIDLCString policyStr;
|
||||
|
||||
result = prefService->CopyCharPref("javascript.security_policy", &policyStr);
|
||||
if (NS_SUCCEEDED(result) && policyStr) {
|
||||
result = prefBranch->GetCharPref("javascript.security_policy",
|
||||
getter_Copies(policyStr));
|
||||
if (NS_SUCCEEDED(result) && !policyStr.IsEmpty()) {
|
||||
secString.Append(policyStr);
|
||||
nsMemory::Free(policyStr);
|
||||
} else {
|
||||
secString.Append("default");
|
||||
}
|
||||
|
||||
secString.Append(".htmldocument.cookie");
|
||||
|
||||
char* prefStr = ToNewCString(secString);
|
||||
XMLT_LOG(mozLineTerm::ArePrefsSecure,32, ("prefStr=%s\n", prefStr));
|
||||
XMLT_LOG(mozLineTerm::ArePrefsSecure,32, ("prefStr=%s\n", secString.get()));
|
||||
|
||||
char *secLevelString;
|
||||
result = prefService->CopyCharPref(prefStr, &secLevelString);
|
||||
nsMemory::Free(prefStr);
|
||||
nsXPIDLCString secLevelString;
|
||||
result = prefBranch->GetCharPref(secString.get(), getter_Copies(secLevelString));
|
||||
|
||||
if (NS_FAILED(result) || !secLevelString)
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
XMLT_LOG(mozLineTerm::ArePrefsSecure,32,
|
||||
("secLevelString=%s\n", secLevelString));
|
||||
("secLevelString=%s\n", secLevelString.get()));
|
||||
|
||||
*_retval = (PL_strcmp(secLevelString, "sameOrigin") == 0);
|
||||
nsMemory::Free(secLevelString);
|
||||
*_retval = secLevelString.Equals(NS_LITERAL_CSTRING("sameOrigin"));
|
||||
|
||||
if (!(*_retval)) {
|
||||
XMLT_ERROR("mozLineTerm::ArePrefsSecure: Error - Please add the line\n"
|
||||
|
|
|
@ -79,7 +79,8 @@
|
|||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
#include "COtherDTD.h"
|
||||
|
@ -344,14 +345,14 @@ CViewSourceHTML::CViewSourceHTML() : mFilename(), mTags(), mErrors() {
|
|||
mPopupTag = VIEW_SOURCE_POPUP;
|
||||
mSyntaxHighlight = PR_FALSE;
|
||||
mWrapLongLines = PR_FALSE;
|
||||
nsCOMPtr<nsIPref> thePrefsService(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (thePrefsService) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch) {
|
||||
PRBool temp;
|
||||
nsresult rv;
|
||||
rv = thePrefsService->GetBoolPref("view_source.syntax_highlight", &temp);
|
||||
rv = prefBranch->GetBoolPref("view_source.syntax_highlight", &temp);
|
||||
mSyntaxHighlight = NS_SUCCEEDED(rv) ? temp : PR_TRUE;
|
||||
|
||||
rv = thePrefsService->GetBoolPref("view_source.wrap_long_lines", &temp);
|
||||
rv = prefBranch->GetBoolPref("view_source.wrap_long_lines", &temp);
|
||||
mWrapLongLines = NS_SUCCEEDED(rv) ? temp : PR_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "nsIOS2Locale.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFileSpec.h" /* for nsAutoString */
|
||||
#include "nsIPref.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCollationOS2, nsICollation)
|
||||
|
|
|
@ -47,7 +47,9 @@
|
|||
#include "nsIPlatformCharset.h"
|
||||
#include "nsIPosixLocale.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCRT.h"
|
||||
//#define DEBUG_UNIX_COLLATION
|
||||
|
@ -90,15 +92,18 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale)
|
|||
|
||||
nsresult res;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (prefs) {
|
||||
PRUnichar *prefValue;
|
||||
res = prefs->GetLocalizedUnicharPref("intl.collationOption", &prefValue);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefLocalizedString> prefLocalString;
|
||||
res = prefBranch->GetComplexValue("intl.collationOption",
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(prefLocalString));
|
||||
if (NS_SUCCEEDED(res) && prefLocalString) {
|
||||
nsXPIDLString prefValue;
|
||||
prefLocalString->GetData(getter_Copies(prefValue));
|
||||
mUseCodePointOrder =
|
||||
nsDependentString(prefValue).Equals(NS_LITERAL_STRING("useCodePointOrder"),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
nsMemory::Free(prefValue);
|
||||
prefValue.Equals(NS_LITERAL_STRING("useCodePointOrder"),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
|
||||
#include "nsUCSupport.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "japanese.map"
|
||||
|
||||
|
@ -57,10 +58,10 @@ void nsJapaneseToUnicode::setMapMode()
|
|||
|
||||
mMapIndex = gIndex;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (!prefs) return;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefBranch) return;
|
||||
nsXPIDLCString prefMap;
|
||||
res = prefs->GetCharPref("intl.jis0208.map", getter_Copies(prefMap));
|
||||
res = prefBranch->GetCharPref("intl.jis0208.map", getter_Copies(prefMap));
|
||||
if (!NS_SUCCEEDED(res)) return;
|
||||
nsCaseInsensitiveCStringComparator comparator;
|
||||
if ( prefMap.Equals(NS_LITERAL_CSTRING("cp932"), comparator) ) {
|
||||
|
|
|
@ -79,7 +79,8 @@
|
|||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
#include "COtherDTD.h"
|
||||
|
@ -344,14 +345,14 @@ CViewSourceHTML::CViewSourceHTML() : mFilename(), mTags(), mErrors() {
|
|||
mPopupTag = VIEW_SOURCE_POPUP;
|
||||
mSyntaxHighlight = PR_FALSE;
|
||||
mWrapLongLines = PR_FALSE;
|
||||
nsCOMPtr<nsIPref> thePrefsService(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (thePrefsService) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch) {
|
||||
PRBool temp;
|
||||
nsresult rv;
|
||||
rv = thePrefsService->GetBoolPref("view_source.syntax_highlight", &temp);
|
||||
rv = prefBranch->GetBoolPref("view_source.syntax_highlight", &temp);
|
||||
mSyntaxHighlight = NS_SUCCEEDED(rv) ? temp : PR_TRUE;
|
||||
|
||||
rv = thePrefsService->GetBoolPref("view_source.wrap_long_lines", &temp);
|
||||
rv = prefBranch->GetBoolPref("view_source.wrap_long_lines", &temp);
|
||||
mWrapLongLines = NS_SUCCEEDED(rv) ? temp : PR_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "nsScrollPortView.h"
|
||||
|
||||
#include "nsIModule.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsViewManager.h"
|
||||
|
||||
|
|
|
@ -54,7 +54,8 @@
|
|||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsInt64.h"
|
||||
|
||||
|
@ -612,10 +613,10 @@ PRBool DoDoubleBuffering(void)
|
|||
static PRBool doDoublebuffering = PR_TRUE; /* Double-buffering is ON by default */
|
||||
|
||||
if (!gotDoublebufferPrefs) {
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (prefs) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
PRBool val;
|
||||
if (NS_SUCCEEDED(prefs->GetBoolPref("viewmanager.do_doublebuffering", &val))) {
|
||||
if (NS_SUCCEEDED(prefBranch->GetBoolPref("viewmanager.do_doublebuffering", &val))) {
|
||||
doDoublebuffering = val;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,6 @@ extern nsresult NS_NewXPBaseWindowFactory(nsIFactory** aFactory);
|
|||
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_IID(kAppShellCID, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_IID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
|
||||
|
@ -210,9 +209,7 @@ nsViewerApp::Destroy()
|
|||
NS_RELEASE(mCrawler);
|
||||
}
|
||||
|
||||
if (nsnull != mPrefs) {
|
||||
NS_RELEASE(mPrefs);
|
||||
}
|
||||
NS_IF_RELEASE(mPrefService);
|
||||
}
|
||||
|
||||
class nsTestFormProcessor : public nsIFormProcessor {
|
||||
|
@ -326,12 +323,11 @@ nsViewerApp::Initialize(int argc, char** argv)
|
|||
mAppShell->SetDispatchListener((nsDispatchListener*) this);
|
||||
|
||||
// Load preferences
|
||||
rv = nsComponentManager::CreateInstance(kPrefCID, NULL, kIPrefIID,
|
||||
(void **) &mPrefs);
|
||||
rv = CallGetService(NS_PREFSERVICE_CONTRACTID, &mPrefService);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
mPrefs->ReadUserPrefs(nsnull);
|
||||
mPrefService->ReadUserPrefs(nsnull);
|
||||
|
||||
// Finally process our arguments
|
||||
rv = ProcessArguments(argc, argv);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsWebCrawler.h"
|
||||
|
||||
class nsIEventQueueService;
|
||||
class nsIPref;
|
||||
class nsIPrefService;
|
||||
class nsBrowserWindow;
|
||||
|
||||
class nsViewerApp : public nsISupports, public nsDispatchListener
|
||||
|
@ -84,7 +84,7 @@ protected:
|
|||
void Destroy();
|
||||
|
||||
nsIAppShell* mAppShell;
|
||||
nsIPref* mPrefs;
|
||||
nsIPrefService* mPrefService;
|
||||
nsString mStartURL;
|
||||
PRBool mDoPurify;
|
||||
PRBool mLoadTestFromFile;
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
|
||||
class nsViewerApp;
|
||||
class nsIPresShell;
|
||||
class nsIPref;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
#include "nsDirectoryService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
|
@ -2403,43 +2404,22 @@ nsInstall::GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName
|
|||
}
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID);
|
||||
|
||||
void
|
||||
nsInstall::CurrentUserNode(nsString& userRegNode)
|
||||
{
|
||||
char *profname;
|
||||
nsIPref * prefs;
|
||||
nsXPIDLCString profname;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kPrefsCID,
|
||||
kPrefsIID,
|
||||
(nsISupports**) &prefs);
|
||||
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
if ( prefBranch )
|
||||
{
|
||||
rv = prefs->CopyCharPref("profile.name", &profname);
|
||||
|
||||
if ( NS_FAILED(rv) )
|
||||
{
|
||||
PR_FREEIF(profname); // Allocated by PREF_CopyCharPref
|
||||
profname = NULL;
|
||||
}
|
||||
|
||||
NS_RELEASE(prefs);
|
||||
}
|
||||
else
|
||||
{
|
||||
profname = NULL;
|
||||
prefBranch->GetCharPref("profile.name", getter_Copies(profname));
|
||||
}
|
||||
|
||||
userRegNode.Assign(NS_LITERAL_STRING("/Netscape/Users/"));
|
||||
if (profname != nsnull)
|
||||
if ( !profname.IsEmpty() )
|
||||
{
|
||||
userRegNode.AppendWithConversion(profname);
|
||||
userRegNode.Append(NS_LITERAL_STRING("/"));
|
||||
PR_FREEIF(profname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptGlobalObjectOwner.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -66,9 +67,6 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
|||
static NS_DEFINE_IID(kIInstallTrigger_IID, NS_IDOMINSTALLTRIGGERGLOBAL_IID);
|
||||
static NS_DEFINE_IID(kIInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
|
||||
|
||||
static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID);
|
||||
|
||||
nsInstallTrigger::nsInstallTrigger()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
|
@ -172,23 +170,16 @@ nsInstallTrigger::HandleContent(const char * aContentType,
|
|||
NS_IMETHODIMP
|
||||
nsInstallTrigger::UpdateEnabled(PRBool* aReturn)
|
||||
{
|
||||
nsIPref * prefs;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kPrefsCID,
|
||||
kPrefsIID,
|
||||
(nsISupports**) &prefs);
|
||||
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
if ( prefBranch )
|
||||
{
|
||||
rv = prefs->GetBoolPref( (const char*) XPINSTALL_ENABLE_PREF, aReturn);
|
||||
nsresult rv = prefBranch->GetBoolPref( (const char*) XPINSTALL_ENABLE_PREF, aReturn);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_RELEASE(prefs);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFXMLSink.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsISoftwareUpdate.h"
|
||||
|
||||
#define NC_RDF_NAME "http://home.netscape.com/NC-rdf#name"
|
||||
|
@ -57,9 +58,6 @@
|
|||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID);
|
||||
|
||||
|
||||
nsIRDFResource* nsXPINotifierImpl::kXPI_NotifierSources = nsnull;
|
||||
nsIRDFResource* nsXPINotifierImpl::kXPI_NotifierPackages = nsnull;
|
||||
|
@ -122,19 +120,13 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn)
|
|||
{
|
||||
*aReturn = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
|
||||
nsIPref * prefs;
|
||||
nsresult rv = nsServiceManager::GetService(kPrefsCID,
|
||||
kPrefsIID,
|
||||
(nsISupports**) &prefs);
|
||||
|
||||
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
if ( prefBranch )
|
||||
{
|
||||
PRBool value;
|
||||
// check to see if we are on.
|
||||
rv = prefs->GetBoolPref( (const char*) XPINSTALL_NOTIFICATIONS_ENABLE, &value);
|
||||
nsresult rv = prefBranch->GetBoolPref( (const char*) XPINSTALL_NOTIFICATIONS_ENABLE, &value);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && value)
|
||||
{
|
||||
|
@ -149,15 +141,15 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn)
|
|||
|
||||
PRInt32 lastTime = 0;
|
||||
|
||||
rv = prefs->GetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, &intervalHours);
|
||||
rv = prefBranch->GetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, &intervalHours);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
intervalHours = 7*24; // default at once a week
|
||||
rv = prefs->SetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, intervalHours);
|
||||
rv = prefBranch->SetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, intervalHours);
|
||||
}
|
||||
|
||||
rv = prefs->GetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, &lastTime);
|
||||
rv = prefBranch->GetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, &lastTime);
|
||||
|
||||
now = PR_Now();
|
||||
|
||||
|
@ -166,7 +158,7 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn)
|
|||
|
||||
if (NS_FAILED(rv) || lastTime == 0)
|
||||
{
|
||||
rv = prefs->SetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, nowSec);
|
||||
rv = prefBranch->SetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, nowSec);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -174,8 +166,6 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn)
|
|||
{
|
||||
*aReturn = PR_TRUE;
|
||||
}
|
||||
|
||||
NS_RELEASE(prefs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче