Bug 1032525 - Making isolation dependent on peerIdentity property r=abr

This commit is contained in:
Martin Thomson 2014-07-02 13:56:10 -07:00
Родитель 233eb2e9e3
Коммит c5c3855cbb
3 изменённых файлов: 11 добавлений и 21 удалений

Просмотреть файл

@ -1226,13 +1226,7 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP)
STAMP_TIMECARD(tc, "Set Local Description");
#ifdef MOZILLA_INTERNAL_API
nsIDocument* doc = GetWindow()->GetExtantDoc();
bool isolated = true;
if (doc) {
isolated = mMedia->AnyLocalStreamIsolated(doc->NodePrincipal());
} else {
CSFLogInfo(logTag, "%s - no document, failing safe", __FUNCTION__);
}
bool isolated = mMedia->AnyLocalStreamHasPeerIdentity();
mPrivacyRequested = mPrivacyRequested || isolated;
#endif

Просмотреть файл

@ -572,26 +572,23 @@ PeerConnectionMedia::ConnectDtlsListener_s(const RefPtr<TransportFlow>& aFlow)
#ifdef MOZILLA_INTERNAL_API
/**
* Tells you if any local streams is isolated. Obviously, we want all the
* streams to be isolated equally so that they can all be sent or not. But we
* can't make that determination for certain, because stream principals change.
* Therefore, we check once when we are setting a local description and that
* determines if we flip the "privacy requested" bit on. If a stream cannot be
* sent, then we'll be sending black/silence later; maybe this will correct
* itself and we can send actual content.
* Tells you if any local streams is isolated to a specific peer identity.
* Obviously, we want all the streams to be isolated equally so that they can
* all be sent or not. We check once when we are setting a local description
* and that determines if we flip the "privacy requested" bit on. Once the bit
* is on, all media originating from this peer connection is isolated.
*
* @param scriptPrincipal the principal
* @returns true if any stream is isolated
* @returns true if any stream has a peerIdentity set on it
*/
bool
PeerConnectionMedia::AnyLocalStreamIsolated(nsIPrincipal *scriptPrincipal) const
PeerConnectionMedia::AnyLocalStreamHasPeerIdentity() const
{
ASSERT_ON_THREAD(mMainThread);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
// check if we should be asking for a private call for this stream
DOMMediaStream* stream = mLocalSourceStreams[u]->GetMediaStream();
if (!scriptPrincipal->Subsumes(stream->GetPrincipal())) {
if (stream->GetPeerIdentity()) {
return true;
}
}

Просмотреть файл

@ -330,9 +330,8 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
// the stream, that would potentially affect others), so that it sends
// black/silence. Once the peer is identified, re-enable those streams.
void UpdateSinkIdentity_m(nsIPrincipal* aPrincipal, const PeerIdentity* aSinkIdentity);
// this determines if any stream is isolated, given the current
// document (or script) principal
bool AnyLocalStreamIsolated(nsIPrincipal *scriptPrincipal) const;
// this determines if any stream is peerIdentity constrained
bool AnyLocalStreamHasPeerIdentity() const;
// When we finally learn who is on the other end, we need to change the ownership
// on streams
void UpdateRemoteStreamPrincipals_m(nsIPrincipal* aPrincipal);