Bug 721004 - Revert changes to dom/telephony/nsTelephony.cpp [a=backout]
authorVivien Nicolas <21@vingtetun.org>
Wed, 01 Feb 2012 19:13:33 -0800
changeset 86021 2aab3e84a1ee8f212806e7d3999e1701ae8651a0
parent 86020 74e015a95ff664750802f739c5fbeb8030ff33ae
child 86022 001c7832f12e51bb2d7cfb1e1eb7699ec922cd96
push idunknown
push userunknown
push dateunknown
reviewersbackout
bugs721004
milestone13.0a1
Bug 721004 - Revert changes to dom/telephony/nsTelephony.cpp [a=backout]
dom/telephony/Telephony.cpp
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -52,17 +52,17 @@
 #include "SystemWorkerManager.h"
 
 #include "CallEvent.h"
 #include "TelephonyCall.h"
 
 USING_TELEPHONY_NAMESPACE
 using mozilla::Preferences;
 
-#define DOM_TELEPHONY_WHITELIST "dom.telephony.whitelist"
+#define DOM_TELEPHONY_APP_PHONE_URL_PREF "dom.telephony.app.phone.url"
 
 namespace {
 
 template <class T>
 inline nsresult
 nsTArrayToJSArray(JSContext* aCx, JSObject* aGlobal,
                   const nsTArray<nsRefPtr<T> >& aSourceArray,
                   JSObject** aResultArray)
@@ -490,19 +490,23 @@ NS_NewTelephony(nsPIDOMWindow* aWindow, 
     nsresult rv =
       document->NodePrincipal()->GetURI(getter_AddRefs(documentURI));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCString documentURL;
     rv = documentURI->GetSpec(documentURL);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // Fail if the node principal isn't trusted.
-    if (!nsContentUtils::URIIsChromeOrInPref(documentURI,
-                                             DOM_TELEPHONY_WHITELIST)) {
+    // The pref may not exist but in that case we deny access just as we do if
+    // the url doesn't match.
+    nsCString phoneAppURL;
+    if (NS_FAILED(Preferences::GetCString(DOM_TELEPHONY_APP_PHONE_URL_PREF,
+                                          &phoneAppURL)) ||
+        !phoneAppURL.Equals(documentURL,
+                            nsCaseInsensitiveCStringComparator())) {
       *aTelephony = nsnull;
       return NS_OK;
     }
   }
 
   // Security checks passed, make a telephony object.
   nsIInterfaceRequestor* ireq = SystemWorkerManager::GetInterfaceRequestor();
   NS_ENSURE_TRUE(ireq, NS_ERROR_UNEXPECTED);