Bug 1448914 - remove nsISound::playSystemSound; r=masayuki
authorNathan Froyd <froydnj@mozilla.com>
Tue, 27 Mar 2018 10:41:40 -0400
changeset 410238 b858515d31112e6b6322495413fa5451e3f944d9
parent 410237 617a25dfb30dcf0d64014ca92c987aa5bd3f6a4c
child 410239 bf1a120681d07e4fa166ac22ed0767176a4e7022
push id33723
push userebalazs@mozilla.com
push dateTue, 27 Mar 2018 21:48:41 +0000
treeherdermozilla-central@56d6db4ad38c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1448914
milestone61.0a1
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 1448914 - remove nsISound::playSystemSound; r=masayuki This API is deprecated (callers are supposed to be using nsISound::playEventSound instead) and there are no callers remaining in mozilla-central, or references to the strings for the API. Let's remove dead code.
widget/cocoa/nsSound.mm
widget/gtk/nsSound.cpp
widget/headless/HeadlessSound.cpp
widget/nsISound.idl
widget/nsSoundProxy.cpp
widget/windows/nsSound.cpp
--- a/widget/cocoa/nsSound.mm
+++ b/widget/cocoa/nsSound.mm
@@ -72,37 +72,13 @@ nsSound::Play(nsIURL *aURL)
 
 NS_IMETHODIMP
 nsSound::Init()
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSound::PlaySystemSound(const nsAString &aSoundAlias)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
-  if (NS_IsMozAliasSound(aSoundAlias)) {
-    NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
-    // Mac doesn't have system sound settings for each user actions.
-    return NS_OK;
-  }
-
-  NSString *name = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(aSoundAlias.BeginReading())
-                                           length:aSoundAlias.Length()];
-  NSSound *sound = [NSSound soundNamed:name];
-  if (sound) {
-    [sound stop];
-    [sound play];
-  }
-
-  return NS_OK;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
-}
-
-NS_IMETHODIMP
 nsSound::PlayEventSound(uint32_t aEventId)
 {
   // Mac doesn't have system sound settings for each user actions.
   return NS_OK;
 }
--- a/widget/gtk/nsSound.cpp
+++ b/widget/gtk/nsSound.cpp
@@ -412,48 +412,8 @@ NS_IMETHODIMP nsSound::PlayEventSound(ui
             ca_context_play(ctx, 0, "event.id", "menu-click", nullptr);
             break;
         case EVENT_MENU_POPUP:
             ca_context_play(ctx, 0, "event.id", "menu-popup", nullptr);
             break;
     }
     return NS_OK;
 }
-
-NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
-{
-    if (NS_IsMozAliasSound(aSoundAlias)) {
-        NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
-        uint32_t eventId;
-        if (aSoundAlias.Equals(NS_SYSSOUND_ALERT_DIALOG))
-            eventId = EVENT_ALERT_DIALOG_OPEN;
-        else if (aSoundAlias.Equals(NS_SYSSOUND_CONFIRM_DIALOG))
-            eventId = EVENT_CONFIRM_DIALOG_OPEN;
-        else if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
-            eventId = EVENT_NEW_MAIL_RECEIVED;
-        else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_EXECUTE))
-            eventId = EVENT_MENU_EXECUTE;
-        else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_POPUP))
-            eventId = EVENT_MENU_POPUP;
-        else
-            return NS_OK;
-        return PlayEventSound(eventId);
-    }
-
-    nsresult rv;
-    nsCOMPtr <nsIURI> fileURI;
-
-    // create a nsIFile and then a nsIFileURL from that
-    nsCOMPtr <nsIFile> soundFile;
-    rv = NS_NewLocalFile(aSoundAlias, true,
-                         getter_AddRefs(soundFile));
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    rv = NS_NewFileURI(getter_AddRefs(fileURI), soundFile);
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(fileURI,&rv);
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    rv = Play(fileURL);
-
-    return rv;
-}
--- a/widget/headless/HeadlessSound.cpp
+++ b/widget/headless/HeadlessSound.cpp
@@ -44,15 +44,10 @@ NS_IMETHODIMP HeadlessSound::Play(nsIURL
   return NS_OK;
 }
 
 NS_IMETHODIMP HeadlessSound::PlayEventSound(uint32_t aEventId)
 {
   return NS_OK;
 }
 
-NS_IMETHODIMP HeadlessSound::PlaySystemSound(const nsAString &aSoundAlias)
-{
-  return NS_OK;
-}
-
 } // namespace widget
 } // namespace mozilla
--- a/widget/nsISound.idl
+++ b/widget/nsISound.idl
@@ -7,23 +7,16 @@
 #include "nsISupports.idl"
 
 interface nsIURL;
 
 [scriptable, uuid(C3C28D92-A17F-43DF-976D-4EEAE6F995FC)]
 interface nsISound : nsISupports
 {
   void play(in nsIURL aURL);
-  /**
-   * for playing system sounds
-   *
-   * NS_SYSSOUND_* params are obsolete. The new events will not be supported by
-   * this method.  You should use playEventSound method instaed.
-   */
-  void playSystemSound(in AString soundAlias);  
   void beep();
 
   /**
     * Not strictly necessary, but avoids delay before first sound.
     * The various methods on nsISound call Init() if they need to.
 	*/
   void init(); 
 
@@ -40,28 +33,8 @@ interface nsISound : nsISupports
   const unsigned long EVENT_CONFIRM_DIALOG_OPEN         = 2;
   const unsigned long EVENT_PROMPT_DIALOG_OPEN          = 3;
   const unsigned long EVENT_SELECT_DIALOG_OPEN          = 4;
   const unsigned long EVENT_MENU_EXECUTE                = 5;
   const unsigned long EVENT_MENU_POPUP                  = 6;
   const unsigned long EVENT_EDITOR_MAX_LEN              = 7;
   void playEventSound(in unsigned long aEventId);
 };
-
-%{C++
-
-/**
- * NS_SYSSOUND_* can be used for playSystemSound but they are obsolete.
- * Use nsISound::playEventSound instead.
- */
-#define NS_SYSSOUND_PREFIX          NS_LITERAL_STRING("_moz_")
-#define NS_SYSSOUND_MAIL_BEEP       NS_LITERAL_STRING("_moz_mailbeep")
-#define NS_SYSSOUND_ALERT_DIALOG    NS_LITERAL_STRING("_moz_alertdialog")
-#define NS_SYSSOUND_CONFIRM_DIALOG  NS_LITERAL_STRING("_moz_confirmdialog")
-#define NS_SYSSOUND_PROMPT_DIALOG   NS_LITERAL_STRING("_moz_promptdialog")
-#define NS_SYSSOUND_SELECT_DIALOG   NS_LITERAL_STRING("_moz_selectdialog")
-#define NS_SYSSOUND_MENU_EXECUTE    NS_LITERAL_STRING("_moz_menucommand")
-#define NS_SYSSOUND_MENU_POPUP      NS_LITERAL_STRING("_moz_menupopup")
-
-#define NS_IsMozAliasSound(aSoundAlias) \
-          StringBeginsWith(aSoundAlias, NS_SYSSOUND_PREFIX)
-
-%}
--- a/widget/nsSoundProxy.cpp
+++ b/widget/nsSoundProxy.cpp
@@ -27,24 +27,16 @@ nsSoundProxy::Play(nsIURL *aURL)
 
   mozilla::ipc::URIParams soundParams;
   mozilla::ipc::SerializeURI(soundURI, soundParams);
   ContentChild::GetSingleton()->SendPlaySound(soundParams);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSoundProxy::PlaySystemSound(const nsAString &aSoundAlias)
-{
-  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
-  MOZ_ASSERT(false, "PlaySystemSound is unimplemented.");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
 nsSoundProxy::Beep()
 {
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
 
   ContentChild::GetSingleton()->SendBeep();
   return NS_OK;
 }
 
--- a/widget/windows/nsSound.cpp
+++ b/widget/windows/nsSound.cpp
@@ -269,52 +269,16 @@ NS_IMETHODIMP nsSound::Init()
     ::PlaySound(nullptr, nullptr, SND_PURGE);
   }), NS_DISPATCH_NORMAL);
 
   mInited = true;
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
-{
-  MOZ_ASSERT(mPlayerThread, "player thread should not be null ");
-  PurgeLastSound();
-
-  if (!NS_IsMozAliasSound(aSoundAlias)) {
-    if (aSoundAlias.IsEmpty())
-      return NS_OK;
-    nsCOMPtr<nsIRunnable> player = new nsSoundPlayer(aSoundAlias);
-    MOZ_ASSERT(player, "Could not create player");
-    nsresult rv = mPlayerThread->Dispatch(player, NS_DISPATCH_NORMAL);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-    return NS_OK;
-  }
-
-  NS_WARNING("nsISound::playSystemSound is called with \"_moz_\" events, they are obsolete, use nsISound::playEventSound instead");
-
-  uint32_t eventId;
-  if (aSoundAlias.Equals(NS_SYSSOUND_MAIL_BEEP))
-    eventId = EVENT_NEW_MAIL_RECEIVED;
-  else if (aSoundAlias.Equals(NS_SYSSOUND_CONFIRM_DIALOG))
-    eventId = EVENT_CONFIRM_DIALOG_OPEN;
-  else if (aSoundAlias.Equals(NS_SYSSOUND_ALERT_DIALOG))
-    eventId = EVENT_ALERT_DIALOG_OPEN;
-  else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_EXECUTE))
-    eventId = EVENT_MENU_EXECUTE;
-  else if (aSoundAlias.Equals(NS_SYSSOUND_MENU_POPUP))
-    eventId = EVENT_MENU_POPUP;
-  else
-    return NS_OK;
-
-  return PlayEventSound(eventId);
-}
-
 NS_IMETHODIMP nsSound::PlayEventSound(uint32_t aEventId)
 {
   MOZ_ASSERT(mPlayerThread, "player thread should not be null ");
   PurgeLastSound();
 
   const wchar_t *sound = nullptr;
   switch (aEventId) {
     case EVENT_NEW_MAIL_RECEIVED: