mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 947132 - [RTSP] Replace system message by activity for rtsp loading. r=fabrice
This commit is contained in:
parent
434cbb1f01
commit
2bec3604db
@ -110,7 +110,6 @@ this.SystemMessagePermissionsTable = {
|
||||
"nfc-powerlevel-change": {
|
||||
"settings": ["read", "write"]
|
||||
},
|
||||
"rtsp-open-video": {},
|
||||
};
|
||||
|
||||
this.SystemMessagePermissionsChecker = {
|
||||
|
@ -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<nsIScriptSecurityManager> securityManager =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(securityManager);
|
||||
|
||||
// Construct jsval for system message.
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
securityManager->GetSystemPrincipal(getter_AddRefs(principal));
|
||||
NS_ENSURE_TRUE_VOID(principal);
|
||||
|
||||
// Construct the message in jsVal format.
|
||||
AutoSafeJSContext cx;
|
||||
AutoClearPendingException helper(cx);
|
||||
JS::Rooted<JSObject*> msgObj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
|
||||
NS_ENSURE_TRUE_VOID(msgObj);
|
||||
JS::Rooted<JS::Value> 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<nsISystemMessagesInternal> 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<nsIMessageSender> 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user