Bug 873919 - Remove old system messages for Bluetooth pairing requests, r=echou
authorGina Yeh <gyeh@mozilla.com>
Thu, 20 Jun 2013 12:14:09 +0800
changeset 135775 f2e3f99ec1d0e980fa6491a18d82ae6f43714cef
parent 135774 72fd56a50fe835bda9083197a04e41f395064c49
child 135776 ac7663828c8823ccadc73614671309eb7e9f9d06
child 135778 9c4b4179c91d3597e436bdd56c1227d74c60f220
push idunknown
push userunknown
push dateunknown
reviewersechou
bugs873919
milestone24.0a1
Bug 873919 - Remove old system messages for Bluetooth pairing requests, r=echou
dom/bluetooth/BluetoothService.cpp
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -747,54 +747,38 @@ BluetoothService::Observe(nsISupports* a
 
   MOZ_ASSERT(false, "BluetoothService got unexpected topic!");
   return NS_ERROR_UNEXPECTED;
 }
 
 void
 BluetoothService::Notify(const BluetoothSignal& aData)
 {
-  /**
-   * We'd like to keep old mechanisms for now and remove them after Bug 873917
-   * is fixed. Basically, three system messages are going to be merged into one
-   * with an extra property named 'method' for distinguishing pairing method.
-   * Please see Bug 853235 for more details.
-   */
   nsString type = NS_LITERAL_STRING("bluetooth-pairing-request");
-  nsAutoString oldType;
 
   AutoSafeJSContext cx;
-  NS_ASSERTION(!::JS_IsExceptionPending(cx),
-               "Shouldn't get here when an exception is pending!");
-
-  JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
-  if (!obj) {
-    NS_WARNING("Failed to new JSObject for system message!");
-    return;
-  }
+  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
+  NS_ENSURE_TRUE_VOID(obj);
 
   if (!SetJsObject(cx, aData.value(), obj)) {
     NS_WARNING("Failed to set properties of system message!");
     return;
   }
 
   BT_LOG("[S] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
 
   if (aData.name().EqualsLiteral("RequestConfirmation")) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 4,
       "RequestConfirmation: Wrong length of parameters");
-    oldType.AssignLiteral("bluetooth-requestconfirmation");
   } else if (aData.name().EqualsLiteral("RequestPinCode")) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 3,
       "RequestPinCode: Wrong length of parameters");
-    oldType.AssignLiteral("bluetooth-requestpincode");
   } else if (aData.name().EqualsLiteral("RequestPasskey")) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 3,
       "RequestPinCode: Wrong length of parameters");
-    oldType.AssignLiteral("bluetooth-requestpasskey");
   } else if (aData.name().EqualsLiteral("Authorize")) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 2,
       "Authorize: Wrong length of parameters");
     type.AssignLiteral("bluetooth-authorize");
   } else if (aData.name().EqualsLiteral("Cancel")) {
     MOZ_ASSERT(aData.value().get_ArrayOfBluetoothNamedValue().Length() == 0,
       "Cancel: Wrong length of parameters");
     type.AssignLiteral("bluetooth-cancel");
@@ -810,20 +794,16 @@ BluetoothService::Notify(const Bluetooth
     return;
   }
 
   nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
     do_GetService("@mozilla.org/system-message-internal;1");
   NS_ENSURE_TRUE_VOID(systemMessenger);
 
   systemMessenger->BroadcastMessage(type, OBJECT_TO_JSVAL(obj));
-
-  if (!oldType.IsEmpty()) {
-    systemMessenger->BroadcastMessage(oldType, OBJECT_TO_JSVAL(obj));
-  }
 }
 
 void
 BluetoothService::DispatchToCommandThread(nsRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aRunnable);
   MOZ_ASSERT(mBluetoothCommandThread);