diff --git a/dom/messages/SystemMessagePermissionsChecker.jsm b/dom/messages/SystemMessagePermissionsChecker.jsm index 80f76d78e4d..ee6b98ad58f 100644 --- a/dom/messages/SystemMessagePermissionsChecker.jsm +++ b/dom/messages/SystemMessagePermissionsChecker.jsm @@ -110,7 +110,6 @@ this.SystemMessagePermissionsTable = { "nfc-powerlevel-change": { "settings": ["read", "write"] }, - "rtsp-open-video": {}, }; this.SystemMessagePermissionsChecker = { diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 1a3d22d30c4..5965d633312 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -121,7 +121,8 @@ #endif #ifdef NECKO_PROTOCOL_rtsp -#include "nsISystemMessagesInternal.h" +#include "nsIScriptSecurityManager.h" +#include "nsIMessageManager.h" #endif using namespace mozilla; @@ -605,41 +606,29 @@ private: } // anonymous namespace /** - * This function broadcasts a system message in order to launch video app for - * rtsp scheme. This is Gonk-specific behavior. + * This function sends a message. This 'content-handler' message is handled in + * b2g/chrome/content/shell.js where it starts an activity request that will + * open the video app. */ void nsExternalHelperAppService::LaunchVideoAppForRtsp(nsIURI* aURI) { - NS_NAMED_LITERAL_STRING(msgType, "rtsp-open-video"); + bool rv; - // Make the url is rtsp. - bool isRTSP = false; - aURI->SchemeIs("rtsp", &isRTSP); - NS_ASSERTION(isRTSP, "Not rtsp protocol! Something goes wrong here"); + // Get a system principal. + nsCOMPtr securityManager = + do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID); + NS_ENSURE_TRUE_VOID(securityManager); - // Construct jsval for system message. + nsCOMPtr principal; + securityManager->GetSystemPrincipal(getter_AddRefs(principal)); + NS_ENSURE_TRUE_VOID(principal); + + // Construct the message in jsVal format. AutoSafeJSContext cx; AutoClearPendingException helper(cx); JS::Rooted msgObj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr)); NS_ENSURE_TRUE_VOID(msgObj); JS::Rooted jsVal(cx); - bool rv; - - // Set the "url" and "title" properties of the message. - // In the case of RTSP streaming, the title is the same as the url. - { - nsAutoCString spec; - aURI->GetAsciiSpec(spec); - JSString *urlStr = JS_NewStringCopyN(cx, spec.get(), spec.Length()); - NS_ENSURE_TRUE_VOID(urlStr); - jsVal.setString(urlStr); - - rv = JS_SetProperty(cx, msgObj, "url", jsVal); - NS_ENSURE_TRUE_VOID(rv); - - rv = JS_SetProperty(cx, msgObj, "title", jsVal); - NS_ENSURE_TRUE_VOID(rv); - } // Set the "type" property of the message. This is a fake MIME type. { @@ -647,18 +636,29 @@ void nsExternalHelperAppService::LaunchVideoAppForRtsp(nsIURI* aURI) JSString *typeStr = JS_NewStringCopyN(cx, mimeType.get(), mimeType.Length()); NS_ENSURE_TRUE_VOID(typeStr); jsVal.setString(typeStr); + rv = JS_SetProperty(cx, msgObj, "type", jsVal); + NS_ENSURE_TRUE_VOID(rv); + } + // Set the "url" and "title" properties of the message. + // They are the same in the case of RTSP streaming. + { + nsAutoCString spec; + aURI->GetSpec(spec); + JSString *urlStr = JS_NewStringCopyN(cx, spec.get(), spec.Length()); + NS_ENSURE_TRUE_VOID(urlStr); + jsVal.setString(urlStr); + rv = JS_SetProperty(cx, msgObj, "url", jsVal); + NS_ENSURE_TRUE_VOID(rv); + rv = JS_SetProperty(cx, msgObj, "title", jsVal); } - rv = JS_SetProperty(cx, msgObj, "type", jsVal); - NS_ENSURE_TRUE_VOID(rv); - - // Broadcast system message. - nsCOMPtr systemMessenger = - do_GetService("@mozilla.org/system-message-internal;1"); - NS_ENSURE_TRUE_VOID(systemMessenger); jsVal.setObject(*msgObj); - systemMessenger->BroadcastMessage(msgType, jsVal, JS::UndefinedValue()); - return; + // Send the message. + nsCOMPtr cpmm = + do_GetService("@mozilla.org/childprocessmessagemanager;1"); + NS_ENSURE_TRUE_VOID(cpmm); + cpmm->SendAsyncMessage(NS_LITERAL_STRING("content-handler"), + jsVal, JSVAL_NULL, principal, cx, 2); } #endif