Bug 568059 - Remove navigator.preference. r=sicking, sr=jst
authorDan Witte <dwitte@mozilla.com>
Tue, 08 Jun 2010 16:43:55 -0700
changeset 43346 d2b01fbc54803d76eb4772bba59b1bcdfc321658
parent 43345 2f382be70ce763b6375647ab67db1ef3fae24c44
child 43347 d4e6501718f7b6816e0b5e52142a19805b2a6f47
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, jst
bugs568059
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 568059 - Remove navigator.preference. r=sicking, sr=jst
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/interfaces/base/nsIDOMNavigator.idl
js/src/xpconnect/src/dom_quickstubs.qsconf
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -2103,17 +2103,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSNavigator)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPlugin)
   DOM_CLASSINFO_MAP_END
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -9764,31 +9764,29 @@ NS_NewScriptGlobalObject(PRBool aIsChrom
 
 nsNavigator::nsNavigator(nsIDocShell *aDocShell)
   : mDocShell(aDocShell)
 {
 }
 
 nsNavigator::~nsNavigator()
 {
-  sPrefInternal_id = JSVAL_VOID;
 }
 
 //*****************************************************************************
 //    nsNavigator::nsISupports
 //*****************************************************************************
 
 
 DOMCI_DATA(Navigator, nsNavigator)
 
 // QueryInterface implementation for nsNavigator
 NS_INTERFACE_MAP_BEGIN(nsNavigator)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNavigator)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMJSNavigator)
   NS_INTERFACE_MAP_ENTRY(nsIDOMClientInformation)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocation)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
 NS_INTERFACE_MAP_END
 
 
 NS_IMPL_ADDREF(nsNavigator)
 NS_IMPL_RELEASE(nsNavigator)
@@ -10191,158 +10189,16 @@ nsNavigator::JavaEnabled(PRBool *aReturn
 
 NS_IMETHODIMP
 nsNavigator::TaintEnabled(PRBool *aReturn)
 {
   *aReturn = PR_FALSE;
   return NS_OK;
 }
 
-jsval
-nsNavigator::sPrefInternal_id = JSVAL_VOID;
-
-NS_IMETHODIMP
-nsNavigator::Preference()
-{
-  // XXXjst: We could get rid of this GetCurrentNativeCallContext()
-  // call if this method returned a variant...
-  nsAXPCNativeCallContext *ncc = nsnull;
-  nsresult rv = nsContentUtils::XPConnect()->
-    GetCurrentNativeCallContext(&ncc);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!ncc)
-    return NS_ERROR_NOT_AVAILABLE;
-
-  PRUint32 argc;
-
-  ncc->GetArgc(&argc);
-
-  if (argc == 0) {
-    // No arguments means there's nothing to be done here.
-
-    return NS_OK;
-  }
-
-  jsval *argv = nsnull;
-
-  ncc->GetArgvPtr(&argv);
-  NS_ENSURE_TRUE(argv, NS_ERROR_UNEXPECTED);
-
-  JSContext *cx = nsnull;
-
-  rv = ncc->GetJSContext(&cx);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  JSAutoRequest ar(cx);
-
-  //--Check to see if the caller is allowed to access prefs
-  if (sPrefInternal_id == JSVAL_VOID) {
-    sPrefInternal_id =
-      STRING_TO_JSVAL(::JS_InternString(cx, "preferenceinternal"));
-  }
-
-  PRUint32 action;
-  if (argc == 1) {
-    action = nsIXPCSecurityManager::ACCESS_GET_PROPERTY;
-  } else {
-    action = nsIXPCSecurityManager::ACCESS_SET_PROPERTY;
-  }
-
-  rv = nsContentUtils::GetSecurityManager()->
-    CheckPropertyAccess(cx, nsnull, "Navigator", sPrefInternal_id, action);
-  if (NS_FAILED(rv)) {
-    return NS_OK;
-  }
-
-  nsIPrefBranch *prefBranch = nsContentUtils::GetPrefBranch();
-  NS_ENSURE_STATE(prefBranch);
-
-  JSString *str = ::JS_ValueToString(cx, argv[0]);
-  NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
-
-  jsval *retval = nsnull;
-
-  rv = ncc->GetRetValPtr(&retval);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  char *prefStr = ::JS_GetStringBytes(str);
-  if (argc == 1) {
-    PRInt32 prefType;
-
-    prefBranch->GetPrefType(prefStr, &prefType);
-
-    switch (prefType) {
-    case nsIPrefBranch::PREF_STRING:
-      {
-        nsXPIDLCString prefCharVal;
-        rv = prefBranch->GetCharPref(prefStr, getter_Copies(prefCharVal));
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        JSString *retStr = ::JS_NewStringCopyZ(cx, prefCharVal);
-        NS_ENSURE_TRUE(retStr, NS_ERROR_OUT_OF_MEMORY);
-
-        *retval = STRING_TO_JSVAL(retStr);
-
-        break;
-      }
-
-    case nsIPrefBranch::PREF_INT:
-      {
-        PRInt32 prefIntVal;
-        rv = prefBranch->GetIntPref(prefStr, &prefIntVal);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        *retval = INT_TO_JSVAL(prefIntVal);
-
-        break;
-      }
-
-    case nsIPrefBranch::PREF_BOOL:
-      {
-        PRBool prefBoolVal;
-
-        rv = prefBranch->GetBoolPref(prefStr, &prefBoolVal);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        *retval = BOOLEAN_TO_JSVAL(prefBoolVal);
-
-        break;
-      }
-    default:
-      {
-        // Nothing we can do here...
-
-        return ncc->SetReturnValueWasSet(PR_FALSE);
-      }
-    }
-
-    ncc->SetReturnValueWasSet(PR_TRUE);
-  } else {
-    if (JSVAL_IS_STRING(argv[1])) {
-      JSString *valueJSStr = ::JS_ValueToString(cx, argv[1]);
-      NS_ENSURE_TRUE(valueJSStr, NS_ERROR_OUT_OF_MEMORY);
-
-      rv = prefBranch->SetCharPref(prefStr, ::JS_GetStringBytes(valueJSStr));
-    } else if (JSVAL_IS_INT(argv[1])) {
-      jsint valueInt = JSVAL_TO_INT(argv[1]);
-
-      rv = prefBranch->SetIntPref(prefStr, (PRInt32)valueInt);
-    } else if (JSVAL_IS_BOOLEAN(argv[1])) {
-      JSBool valueBool = JSVAL_TO_BOOLEAN(argv[1]);
-
-      rv = prefBranch->SetBoolPref(prefStr, (PRBool)valueBool);
-    } else if (JSVAL_IS_NULL(argv[1])) {
-      rv = prefBranch->DeleteBranch(prefStr);
-    }
-  }
-
-  return rv;
-}
-
 void
 nsNavigator::LoadingNewDocument()
 {
   // Release these so that they will be recreated for the
   // new document (if requested).  The plugins or mime types
   // arrays may have changed.  See bug 150087.
   mMimeTypes = nsnull;
   mPlugins = nsnull;
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -892,27 +892,25 @@ protected:
 };
 
 
 //*****************************************************************************
 // nsNavigator: Script "navigator" object
 //*****************************************************************************
 
 class nsNavigator : public nsIDOMNavigator,
-                    public nsIDOMJSNavigator,
                     public nsIDOMClientInformation,
                     public nsIDOMNavigatorGeolocation
 {
 public:
   nsNavigator(nsIDocShell *aDocShell);
   virtual ~nsNavigator();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMNAVIGATOR
-  NS_DECL_NSIDOMJSNAVIGATOR
   NS_DECL_NSIDOMCLIENTINFORMATION
   NS_DECL_NSIDOMNAVIGATORGEOLOCATION
   
   void SetDocShell(nsIDocShell *aDocShell);
   nsIDocShell *GetDocShell()
   {
     return mDocShell;
   }
@@ -920,18 +918,16 @@ public:
   void LoadingNewDocument();
   nsresult RefreshMIMEArray();
 
 protected:
   nsRefPtr<nsMimeTypeArray> mMimeTypes;
   nsRefPtr<nsPluginArray> mPlugins;
   nsRefPtr<nsGeolocation> mGeolocation;
   nsIDocShell* mDocShell; // weak reference
-
-  static jsval       sPrefInternal_id;
 };
 
 class nsIURI;
 
 //*****************************************************************************
 // nsLocation: Script "location" object
 //*****************************************************************************
 
--- a/dom/interfaces/base/nsIDOMNavigator.idl
+++ b/dom/interfaces/base/nsIDOMNavigator.idl
@@ -57,24 +57,10 @@ interface nsIDOMNavigator : nsISupports
   readonly attribute DOMString           securityPolicy;
   readonly attribute DOMString           userAgent;
   readonly attribute boolean             cookieEnabled;
   readonly attribute boolean             onLine;
   readonly attribute DOMString           buildID;
 
   boolean                   javaEnabled();
   boolean                   taintEnabled();
-
-  // XXX This one's tough, would nsISupports preference(in DOMString
-  // pref /*, ... */); work?
-
-  // jsval      preference(/* ... */);
 };
 
-
-[scriptable, uuid(4b4f8316-1dd2-11b2-b265-9a857376d159)]
-interface nsIDOMJSNavigator : nsISupports
-{
-  // Nothing about this method (except its name :-) is describeable
-  // in XPIDL, argument handling and the return value needs to be
-  // dealt with in the implementation of this method.
-  void                      preference();
-};
--- a/js/src/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/src/xpconnect/src/dom_quickstubs.qsconf
@@ -50,17 +50,16 @@ name = 'DOM'
 members = [ 
     # dom/interfaces/base
     #
     # Note that many implementations of interfaces in this directory
     # use GetCurrentNativeCallContext, notably:
     #   - nsIDOMCrypto.{generateCRMFRequest,signText}
     #   - nsIDOMLocation.reload
     #   - nsIDOMNSHistory.go
-    #   - nsIDOMJSNavigator.preference
     #   - nsIDOMJSPluginArray.refresh
     #   - nsIDOMWindowInternal.postMessage
     #   - nsIDOMJSWindow.{prompt,setTimeout,setInterval,open,openDialog}
     #
     # (And nsIDOMModalContentWindow.returnValue is an attribute of type
     # nsIVariant, which qsgen.py can't handle.)
     #
     'nsIDOMWindow.name',