mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 884702 - Support Rtsp protocol in url bar. r=bz
This commit is contained in:
parent
f766021cdd
commit
1734f172a9
@ -42,6 +42,12 @@ pref("network.protocol-handler.warn-external.tel", false);
|
||||
pref("network.protocol-handler.warn-external.mailto", false);
|
||||
pref("network.protocol-handler.warn-external.vnd.youtube", false);
|
||||
|
||||
/* protocol expose prefs */
|
||||
// By default, all protocol handlers are exposed. This means that the browser
|
||||
// will response to openURL commands for all URL types. It will also try to open
|
||||
// link clicks inside the browser before failing over to the system handlers.
|
||||
pref("network.protocol-handler.expose.rtsp", false);
|
||||
|
||||
/* http prefs */
|
||||
pref("network.http.pipelining", true);
|
||||
pref("network.http.pipelining.ssl", true);
|
||||
|
@ -103,7 +103,8 @@ this.SystemMessagePermissionsTable = {
|
||||
},
|
||||
"nfc-powerlevel-change": {
|
||||
"settings": ["read", "write"]
|
||||
}
|
||||
},
|
||||
"rtsp-open-video": {},
|
||||
};
|
||||
|
||||
this.SystemMessagePermissionsChecker = {
|
||||
|
@ -120,6 +120,10 @@
|
||||
#include "nsDeviceStorage.h"
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_rtsp
|
||||
#include "nsISystemMessagesInternal.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
@ -582,6 +586,82 @@ nsExternalHelperAppService::~nsExternalHelperAppService()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef NECKO_PROTOCOL_rtsp
|
||||
namespace {
|
||||
/**
|
||||
* A stack helper to clear the currently pending exception in a JS context.
|
||||
*/
|
||||
class AutoClearPendingException {
|
||||
public:
|
||||
AutoClearPendingException(JSContext* aCx) :
|
||||
mCx(aCx) {
|
||||
}
|
||||
~AutoClearPendingException() {
|
||||
JS_ClearPendingException(mCx);
|
||||
}
|
||||
private:
|
||||
JSContext *mCx;
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
/**
|
||||
* This function broadcasts a system message in order to launch video app for
|
||||
* rtsp scheme. This is Gonk-specific behavior.
|
||||
*/
|
||||
void nsExternalHelperAppService::LaunchVideoAppForRtsp(nsIURI* aURI)
|
||||
{
|
||||
NS_NAMED_LITERAL_STRING(msgType, "rtsp-open-video");
|
||||
|
||||
// Make the url is rtsp.
|
||||
bool isRTSP = false;
|
||||
aURI->SchemeIs("rtsp", &isRTSP);
|
||||
NS_ASSERTION(isRTSP, "Not rtsp protocol! Something goes wrong here");
|
||||
|
||||
// Construct jsval for system message.
|
||||
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.
|
||||
{
|
||||
NS_NAMED_LITERAL_CSTRING(mimeType, "video/rtsp");
|
||||
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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeContentType,
|
||||
nsIRequest *aRequest,
|
||||
nsIInterfaceRequestor *aWindowContext,
|
||||
@ -922,7 +1002,18 @@ nsExternalHelperAppService::LoadURI(nsIURI *aURI,
|
||||
return NS_OK; // explicitly denied
|
||||
}
|
||||
|
||||
|
||||
#ifdef NECKO_PROTOCOL_rtsp
|
||||
// Handle rtsp protocol.
|
||||
{
|
||||
bool isRTSP = false;
|
||||
rv = aURI->SchemeIs("rtsp", &isRTSP);
|
||||
if (NS_SUCCEEDED(rv) && isRTSP) {
|
||||
LaunchVideoAppForRtsp(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIHandlerInfo> handler;
|
||||
rv = GetProtocolHandlerInfo(scheme, getter_AddRefs(handler));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "necko-config.h"
|
||||
|
||||
class nsExternalAppHandler;
|
||||
class nsIMIMEInfo;
|
||||
@ -175,6 +176,15 @@ protected:
|
||||
* the private browsing mode)
|
||||
*/
|
||||
void ExpungeTemporaryPrivateFiles();
|
||||
|
||||
#ifdef NECKO_PROTOCOL_rtsp
|
||||
/**
|
||||
* Launch video app for rtsp protocol. This function is supported only on Gonk
|
||||
* for now.
|
||||
*/
|
||||
static void LaunchVideoAppForRtsp(nsIURI* aURI);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Array for the files that should be deleted
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user