Commit 9803b986 authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1337056 - Part 5: Add support for finer-grained permission update messages...

Bug 1337056 - Part 5: Add support for finer-grained permission update messages to ContentParent, r=baku

MozReview-Commit-ID: 6y6eBLWPTue
parent 092eeed6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2065,7 +2065,6 @@ ContentParent::ContentParent(ContentParent* aOpener,
  , mNumDestroyingTabs(0)
  , mIsAvailable(true)
  , mIsAlive(true)
  , mSendPermissionUpdates(false)
  , mIsForBrowser(!mRemoteType.IsEmpty())
  , mCalledClose(false)
  , mCalledKillHard(false)
@@ -5112,6 +5111,12 @@ ContentParent::EnsurePermissionsByKey(const nsCString& aKey)
#endif
}

bool
ContentParent::NeedsPermissionsUpdate(const nsACString& aPermissionKey) const
{
  return mActivePermissionKeys.Contains(aPermissionKey);
}

mozilla::ipc::IPCResult
ContentParent::RecvAccumulateChildHistograms(
                InfallibleTArray<Accumulation>&& aAccumulations)
+1 −5
Original line number Diff line number Diff line
@@ -377,10 +377,7 @@ public:
    return mScriptableHelper;
  }

  bool NeedsPermissionsUpdate() const
  {
    return mSendPermissionUpdates;
  }
  bool NeedsPermissionsUpdate(const nsACString& aPermissionKey) const;

  /**
   * Kill our subprocess and make sure it dies.  Should only be used
@@ -1185,7 +1182,6 @@ private:
  // still pass through.
  bool mIsAlive;

  bool mSendPermissionUpdates;
  bool mIsForBrowser;

  // These variables track whether we've called Close() and KillHard() on our
+4 −1
Original line number Diff line number Diff line
@@ -1568,11 +1568,14 @@ nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal,
    IPC::Permission permission(origin, aType, aPermission,
                               aExpireType, aExpireTime);

    nsAutoCString permissionKey;
    GetKeyForPrincipal(aPrincipal, permissionKey);

    nsTArray<ContentParent*> cplist;
    ContentParent::GetAll(cplist);
    for (uint32_t i = 0; i < cplist.Length(); ++i) {
      ContentParent* cp = cplist[i];
      if (cp->NeedsPermissionsUpdate())
      if (cp->NeedsPermissionsUpdate(permissionKey))
        Unused << cp->SendAddPermission(permission);
    }
  }