Bug 1023695 - Part 4: Implementation of .webidl change. r=vyang, r=smaug, a=2.0+
authorBevis Tseng <btseng@mozilla.com>
Fri, 27 Jun 2014 13:25:37 +0800
changeset 208923 bf117b204a28b71fca3d02563fcc7347061ea96d
parent 208922 d6752789d7104c04e65643c8a08a932a825ce47b
child 208924 775ba85429bc47f991db632694ecd9731de7103c
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvyang, smaug, 2
bugs1023695
milestone32.0a2
Bug 1023695 - Part 4: Implementation of .webidl change. r=vyang, r=smaug, a=2.0+
content/base/src/nsGkAtomList.h
dom/events/test/test_all_synthetic_events.html
dom/mobilemessage/src/MobileMessageManager.cpp
dom/mobilemessage/src/MobileMessageManager.h
dom/tests/mochitest/general/test_interfaces.html
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -696,16 +696,17 @@ GK_ATOM(onconnect, "onconnect")
 GK_ATOM(onconnected, "onconnected")
 GK_ATOM(onconnecting, "onconnecting")
 GK_ATOM(oncontextmenu, "oncontextmenu")
 GK_ATOM(oncopy, "oncopy")
 GK_ATOM(oncut, "oncut")
 GK_ATOM(ondatachange, "ondatachange")
 GK_ATOM(ondataerror, "ondataerror")
 GK_ATOM(ondblclick, "ondblclick")
+GK_ATOM(ondeleted, "ondeleted")
 GK_ATOM(ondeliverysuccess, "ondeliverysuccess")
 GK_ATOM(ondeliveryerror, "ondeliveryerror")
 GK_ATOM(ondevicefound, "ondevicefound")
 GK_ATOM(ondialing, "ondialing")
 GK_ATOM(ondisabled, "ondisabled")
 GK_ATOM(ondischargingtimechange, "ondischargingtimechange")
 GK_ATOM(ondisconnected, "ondisconnected")
 GK_ATOM(ondisconnecting, "ondisconnecting")
--- a/dom/events/test/test_all_synthetic_events.html
+++ b/dom/events/test/test_all_synthetic_events.html
@@ -248,16 +248,20 @@ const kEventConstructors = {
   MozContactChangeEvent:                     { create: function (aName, aProps) {
                                                          return new MozContactChangeEvent(aName, aProps);
                                                        },
                                              },
   MozEmergencyCbModeEvent:                   { create: function (aName, aProps) {
                                                           return new MozEmergencyCbModeEvent(aName, aProps);
                                                        },
                                              },
+  MozMessageDeletedEvent:                    { create: function (aName, aProps) {
+                                                         return new MozMessageDeletedEvent(aName, aProps);
+                                                       },
+                                             },
   MozMmsEvent:                               { create: function (aName, aProps) {
                                                          return new MozMmsEvent(aName, aProps);
                                                        },
                                              },
   MozOtaStatusEvent:                         { create: function (aName, aProps) {
                                                           return new MozOtaStatusEvent(aName, aProps);
                                                        },
                                              },
--- a/dom/mobilemessage/src/MobileMessageManager.cpp
+++ b/dom/mobilemessage/src/MobileMessageManager.cpp
@@ -8,16 +8,17 @@
 #include "nsIDOMClassInfo.h"
 #include "nsISmsService.h"
 #include "nsIMmsService.h"
 #include "nsIObserverService.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
 #include "mozilla/dom/MobileMessageManagerBinding.h"
+#include "mozilla/dom/MozMessageDeletedEvent.h"
 #include "mozilla/dom/MozMmsMessageBinding.h"
 #include "nsIDOMMozSmsEvent.h"
 #include "nsIDOMMozMmsEvent.h"
 #include "nsIDOMMozSmsMessage.h"
 #include "nsIDOMMozMmsMessage.h"
 #include "nsJSUtils.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
@@ -25,26 +26,28 @@
 #include "nsIXPConnect.h"
 #include "nsIPermissionManager.h"
 #include "GeneratedEvents.h"
 #include "DOMRequest.h"
 #include "nsIMobileMessageCallback.h"
 #include "MobileMessageCallback.h"
 #include "MobileMessageCursorCallback.h"
 #include "DOMCursor.h"
+#include "DeletedMessageInfo.h"
 
 #define RECEIVED_EVENT_NAME         NS_LITERAL_STRING("received")
 #define RETRIEVING_EVENT_NAME       NS_LITERAL_STRING("retrieving")
 #define SENDING_EVENT_NAME          NS_LITERAL_STRING("sending")
 #define SENT_EVENT_NAME             NS_LITERAL_STRING("sent")
 #define FAILED_EVENT_NAME           NS_LITERAL_STRING("failed")
 #define DELIVERY_SUCCESS_EVENT_NAME NS_LITERAL_STRING("deliverysuccess")
 #define DELIVERY_ERROR_EVENT_NAME   NS_LITERAL_STRING("deliveryerror")
 #define READ_SUCCESS_EVENT_NAME     NS_LITERAL_STRING("readsuccess")
 #define READ_ERROR_EVENT_NAME       NS_LITERAL_STRING("readerror")
+#define DELETED_EVENT_NAME          NS_LITERAL_STRING("deleted")
 
 using namespace mozilla::dom::mobilemessage;
 
 DOMCI_DATA(MozMobileMessageManager, mozilla::dom::MobileMessageManager)
 
 namespace mozilla {
 namespace dom {
 
@@ -61,16 +64,17 @@ NS_IMPL_EVENT_HANDLER(MobileMessageManag
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, retrieving)
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, sending)
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, sent)
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, failed)
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, deliverysuccess)
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, deliveryerror)
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, readsuccess)
 NS_IMPL_EVENT_HANDLER(MobileMessageManager, readerror)
+NS_IMPL_EVENT_HANDLER(MobileMessageManager, deleted)
 
 void
 MobileMessageManager::Init(nsPIDOMWindow *aWindow)
 {
   BindToOwner(aWindow);
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   // GetObserverService() can return null is some situations like shutdown.
@@ -82,16 +86,17 @@ MobileMessageManager::Init(nsPIDOMWindow
   obs->AddObserver(this, kSmsRetrievingObserverTopic, false);
   obs->AddObserver(this, kSmsSendingObserverTopic, false);
   obs->AddObserver(this, kSmsSentObserverTopic, false);
   obs->AddObserver(this, kSmsFailedObserverTopic, false);
   obs->AddObserver(this, kSmsDeliverySuccessObserverTopic, false);
   obs->AddObserver(this, kSmsDeliveryErrorObserverTopic, false);
   obs->AddObserver(this, kSmsReadSuccessObserverTopic, false);
   obs->AddObserver(this, kSmsReadErrorObserverTopic, false);
+  obs->AddObserver(this, kSmsDeletedObserverTopic, false);
 }
 
 void
 MobileMessageManager::Shutdown()
 {
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   // GetObserverService() can return null is some situations like shutdown.
   if (!obs) {
@@ -102,16 +107,17 @@ MobileMessageManager::Shutdown()
   obs->RemoveObserver(this, kSmsRetrievingObserverTopic);
   obs->RemoveObserver(this, kSmsSendingObserverTopic);
   obs->RemoveObserver(this, kSmsSentObserverTopic);
   obs->RemoveObserver(this, kSmsFailedObserverTopic);
   obs->RemoveObserver(this, kSmsDeliverySuccessObserverTopic);
   obs->RemoveObserver(this, kSmsDeliveryErrorObserverTopic);
   obs->RemoveObserver(this, kSmsReadSuccessObserverTopic);
   obs->RemoveObserver(this, kSmsReadErrorObserverTopic);
+  obs->RemoveObserver(this, kSmsDeletedObserverTopic);
 }
 
 NS_IMETHODIMP
 MobileMessageManager::GetSegmentInfoForText(const nsAString& aText,
                                             nsIDOMDOMRequest** aRequest)
 {
   nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
   NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
@@ -503,16 +509,37 @@ MobileMessageManager::DispatchTrustedSms
   nsAutoCString errorMsg;
   errorMsg.AssignLiteral("Got a '");
   errorMsg.Append(aTopic);
   errorMsg.AppendLiteral("' topic without a valid message!");
   NS_ERROR(errorMsg.get());
   return NS_OK;
 }
 
+nsresult
+MobileMessageManager::DispatchTrustedDeletedEventToSelf(nsISupports* aDeletedInfo)
+{
+  nsCOMPtr<nsIDeletedMessageInfo> deletedInfo = do_QueryInterface(aDeletedInfo);
+  if (deletedInfo) {
+    MozMessageDeletedEventInit init;
+    init.mBubbles = false;
+    init.mCancelable = false;
+    deletedInfo->GetDeletedMessageIds(getter_AddRefs(init.mDeletedMessageIds));
+    deletedInfo->GetDeletedThreadIds(getter_AddRefs(init.mDeletedThreadIds));
+
+    nsRefPtr<MozMessageDeletedEvent> event =
+      MozMessageDeletedEvent::Constructor(this, DELETED_EVENT_NAME, init);
+    return DispatchTrustedEvent(event);
+  }
+
+  NS_ERROR("Got a 'deleted' topic without a valid message!");
+
+  return NS_OK;
+}
+
 NS_IMETHODIMP
 MobileMessageManager::Observe(nsISupports* aSubject, const char* aTopic,
                               const char16_t* aData)
 {
   if (!strcmp(aTopic, kSmsReceivedObserverTopic)) {
     return DispatchTrustedSmsEventToSelf(aTopic, RECEIVED_EVENT_NAME, aSubject);
   }
 
@@ -543,16 +570,20 @@ MobileMessageManager::Observe(nsISupport
   if (!strcmp(aTopic, kSmsReadSuccessObserverTopic)) {
     return DispatchTrustedSmsEventToSelf(aTopic, READ_SUCCESS_EVENT_NAME, aSubject);
   }
 
   if (!strcmp(aTopic, kSmsReadErrorObserverTopic)) {
     return DispatchTrustedSmsEventToSelf(aTopic, READ_ERROR_EVENT_NAME, aSubject);
   }
 
+  if (!strcmp(aTopic, kSmsDeletedObserverTopic)) {
+    return DispatchTrustedDeletedEventToSelf(aSubject);
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MobileMessageManager::GetSmscAddress(uint32_t aServiceId, uint8_t aArgc,
                                      nsIDOMDOMRequest** aRequest)
 {
   nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
--- a/dom/mobilemessage/src/MobileMessageManager.h
+++ b/dom/mobilemessage/src/MobileMessageManager.h
@@ -39,16 +39,18 @@ private:
                 JS::Handle<JSString*> aNumber,
                 const nsAString& aMessage,
                 JS::MutableHandle<JS::Value> aRequest);
 
   nsresult DispatchTrustedSmsEventToSelf(const char* aTopic,
                                          const nsAString& aEventName,
                                          nsISupports* aMsg);
 
+  nsresult DispatchTrustedDeletedEventToSelf(nsISupports* aDeletedInfo);
+
   /**
    * Helper to get message ID from SMS/MMS Message object
    */
   nsresult GetMessageId(JSContext* aCx, const JS::Value& aMessage,
                         int32_t* aId);
 };
 
 } // namespace dom
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -646,16 +646,18 @@ var interfaceNamesInGlobalScope =
     {name: "MozIcc", b2g: true, pref: "dom.icc.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozIccManager", b2g: true, pref: "dom.icc.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozInputContext", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozInputMethodManager", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
+    {name: "MozMessageDeletedEvent", b2g: true, pref: "dom.sms.enabled"},
+// IMPORTANT: Do not change this list without review from a DOM peer!
     "MozMmsEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozMmsMessage",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozMobileCellInfo", b2g: true, pref: "dom.mobileconnection.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozMobileConnection", b2g: true, pref: "dom.mobileconnection.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!