Commit 9adc1c9d authored by Bobby Holley's avatar Bobby Holley
Browse files

Bug 713747 - Remove usage of UniversalFoo in gecko. r=bz

parent fb019bcc
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -232,10 +232,9 @@ public:
  static bool     IsCallerTrustedForWrite();

  /**
   * Check whether a caller is trusted to have aCapability.  This also
   * checks for UniversalXPConnect in addition to aCapability.
   * Check whether a caller has UniversalXPConnect.
   */
  static bool     IsCallerTrustedForCapability(const char* aCapability);
  static bool     CallerHasUniversalXPConnect();

  static bool     IsImageSrcSetDisabled();

+6 −20
Original line number Diff line number Diff line
@@ -1148,16 +1148,9 @@ nsContentUtils::Shutdown()

// static
bool
nsContentUtils::IsCallerTrustedForCapability(const char* aCapability)
nsContentUtils::CallerHasUniversalXPConnect()
{
  // The secman really should handle UniversalXPConnect case, since that
  // should include UniversalBrowserRead... doesn't right now, though.
  bool hasCap;
  if (NS_FAILED(sSecurityManager->IsCapabilityEnabled(aCapability, &hasCap)))
    return false;
  if (hasCap)
    return true;
    
  if (NS_FAILED(sSecurityManager->IsCapabilityEnabled("UniversalXPConnect",
                                                      &hasCap)))
    return false;
@@ -1228,15 +1221,8 @@ nsContentUtils::CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
  }

  // The subject doesn't subsume aPrincipal. Allow access only if the subject
  // has either "UniversalXPConnect" (if aPrincipal is system principal) or
  // "UniversalBrowserRead" (in all other cases).
  bool isSystem;
  rv = sSecurityManager->IsSystemPrincipal(aPrincipal, &isSystem);
  isSystem = NS_FAILED(rv) || isSystem;
  const char* capability =
    NS_FAILED(rv) || isSystem ? "UniversalXPConnect" : "UniversalBrowserRead";

  return IsCallerTrustedForCapability(capability);
  // has UniversalXPConnect.
  return CallerHasUniversalXPConnect();
}

// static
@@ -1469,13 +1455,13 @@ nsContentUtils::IsCallerChrome()
bool
nsContentUtils::IsCallerTrustedForRead()
{
  return IsCallerTrustedForCapability("UniversalBrowserRead");
  return CallerHasUniversalXPConnect();
}

bool
nsContentUtils::IsCallerTrustedForWrite()
{
  return IsCallerTrustedForCapability("UniversalBrowserWrite");
  return CallerHasUniversalXPConnect();
}

bool
+2 −2
Original line number Diff line number Diff line
@@ -165,12 +165,12 @@ nsDOMFileBase::GetMozFullPath(nsAString &aFileName)
{
  NS_ASSERTION(mIsFile, "Should only be called on files");

  // It is unsafe to call IsCallerTrustedForCapability on a non-main thread. If
  // It is unsafe to call CallerHasUniversalXPConnect on a non-main thread. If
  // you hit the following assertion you need to figure out some other way to
  // determine privileges and call GetMozFullPathInternal.
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  if (nsContentUtils::IsCallerTrustedForCapability("UniversalFileRead")) {
  if (nsContentUtils::CallerHasUniversalXPConnect()) {
    return GetMozFullPathInternal(aFileName);
  }
  aFileName.Truncate();
+2 −2
Original line number Diff line number Diff line
@@ -2749,10 +2749,10 @@ nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
  }

  // Prevent modification to certain HTTP headers (see bug 302263), unless
  // the executing script has UniversalBrowserWrite permission.
  // the executing script has UniversalXPConnect.

  bool privileged;
  rv = IsCapabilityEnabled("UniversalBrowserWrite", &privileged);
  rv = IsCapabilityEnabled("UniversalXPConnect", &privileged);
  if (NS_FAILED(rv))
    return NS_ERROR_FAILURE;

+1 −1
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ public:
   * Dispatches an event.
   * If aDOMEvent is not nsnull, it is used for dispatching
   * (aEvent can then be nsnull) and (if aDOMEvent is not |trusted| already),
   * the |trusted| flag is set based on the UniversalBrowserWrite capability.
   * the |trusted| flag is set based on the UniversalXPConnect capability.
   * Otherwise this works like nsEventDispatcher::Dispatch.
   * @note Use this method when dispatching nsIDOMEvent.
   */
Loading