Bug 804174 - Inline IsCallerTrustedForRead with IsCallerChrome. r=mccr8

This commit is contained in:
Nikhil Marathe 2012-10-25 16:10:53 -07:00
parent 625fe10014
commit 9e080f6dff
10 changed files with 23 additions and 31 deletions

View File

@ -203,8 +203,6 @@ public:
static bool IsCallerChrome();
static bool IsCallerTrustedForRead();
static bool IsCallerTrustedForWrite();
static bool IsImageSrcSetDisabled();

View File

@ -1779,12 +1779,6 @@ nsContentUtils::IsCallerChrome()
return xpc::IsUniversalXPConnectEnabled(GetCurrentJSContext());
}
bool
nsContentUtils::IsCallerTrustedForRead()
{
return IsCallerChrome();
}
bool
nsContentUtils::IsCallerTrustedForWrite()
{

View File

@ -3894,7 +3894,7 @@ CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x,
// -- rendering the user's theme and then extracting the results
// -- rendering native anonymous content (e.g., file input paths;
// scrollbars should be allowed)
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
// not permitted to use DrawWindow
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
error.Throw(NS_ERROR_DOM_SECURITY_ERR);
@ -3995,7 +3995,7 @@ CanvasRenderingContext2D::AsyncDrawXULElement(nsIDOMXULElement* elem,
// -- rendering the user's theme and then extracting the results
// -- rendering native anonymous content (e.g., file input paths;
// scrollbars should be allowed)
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
// not permitted to use DrawWindow
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
error.Throw(NS_ERROR_DOM_SECURITY_ERR);
@ -4132,7 +4132,7 @@ CanvasRenderingContext2D::GetImageData(JSContext* aCx, double aSx,
// Check only if we have a canvas element; if we were created with a docshell,
// then it's special internal use.
if (mCanvasElement && mCanvasElement->IsWriteOnly() &&
!nsContentUtils::IsCallerTrustedForRead())
!nsContentUtils::IsCallerChrome())
{
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
error.Throw(NS_ERROR_DOM_SECURITY_ERR);

View File

@ -3137,7 +3137,7 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
return;
}
if (mCanvasElement->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) {
if (mCanvasElement->IsWriteOnly() && !nsContentUtils::IsCallerChrome()) {
GenerateWarning("readPixels: Not allowed");
return rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
}

View File

@ -40,7 +40,7 @@ nsRegion
nsDOMNotifyPaintEvent::GetRegion()
{
nsRegion r;
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
return r;
}
for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
@ -97,7 +97,7 @@ nsDOMNotifyPaintEvent::GetPaintRequests(nsIDOMPaintRequestList** aResult)
if (!requests)
return NS_ERROR_OUT_OF_MEMORY;
if (nsContentUtils::IsCallerTrustedForRead()) {
if (nsContentUtils::IsCallerChrome()) {
for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
nsRefPtr<nsPaintRequest> r = new nsPaintRequest();
if (!r)

View File

@ -372,7 +372,7 @@ nsHTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams,
uint8_t optional_argc, nsAString& aDataURL)
{
// do a trust check if this is a write-only canvas
if (mWriteOnly && !nsContentUtils::IsCallerTrustedForRead()) {
if (mWriteOnly && !nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -584,7 +584,7 @@ nsHTMLCanvasElement::ToBlob(nsIFileCallback* aCallback,
uint8_t optional_argc)
{
// do a trust check if this is a write-only canvas
if (mWriteOnly && !nsContentUtils::IsCallerTrustedForRead()) {
if (mWriteOnly && !nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -633,7 +633,7 @@ nsHTMLCanvasElement::MozGetAsFile(const nsAString& aName,
{
// do a trust check if this is a write-only canvas
if ((mWriteOnly) &&
!nsContentUtils::IsCallerTrustedForRead()) {
!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -807,7 +807,7 @@ NS_IMETHODIMP
nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
nsISupports **aContext)
{
if(!nsContentUtils::IsCallerTrustedForRead()) {
if(!nsContentUtils::IsCallerChrome()) {
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
return NS_ERROR_DOM_SECURITY_ERR;
}

View File

@ -354,7 +354,7 @@ Navigator::GetPlatform(nsAString& aPlatform)
NS_IMETHODIMP
Navigator::GetOscpu(nsAString& aOSCPU)
{
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
const nsAdoptingString& override =
Preferences::GetString("general.oscpu.override");
@ -494,7 +494,7 @@ Navigator::GetOnLine(bool* aOnline)
NS_IMETHODIMP
Navigator::GetBuildID(nsAString& aBuildID)
{
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
const nsAdoptingString& override =
Preferences::GetString("general.buildID.override");
@ -1452,7 +1452,7 @@ NS_GetNavigatorUserAgent(nsAString& aUserAgent)
nsresult
NS_GetNavigatorPlatform(nsAString& aPlatform)
{
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
const nsAdoptingString& override =
mozilla::Preferences::GetString("general.platform.override");
@ -1496,7 +1496,7 @@ NS_GetNavigatorPlatform(nsAString& aPlatform)
nsresult
NS_GetNavigatorAppVersion(nsAString& aAppVersion)
{
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
const nsAdoptingString& override =
mozilla::Preferences::GetString("general.appversion.override");
@ -1531,7 +1531,7 @@ NS_GetNavigatorAppVersion(nsAString& aAppVersion)
nsresult
NS_GetNavigatorAppName(nsAString& aAppName)
{
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
const nsAdoptingString& override =
mozilla::Preferences::GetString("general.appname.override");

View File

@ -1506,7 +1506,7 @@ nsDOMWindowUtils::GetFullZoom(float* aFullZoom)
{
*aFullZoom = 1.0f;
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -1526,7 +1526,7 @@ nsDOMWindowUtils::DispatchDOMEventViaPresShell(nsIDOMNode* aTarget,
bool aTrusted,
bool* aRetVal)
{
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -1847,7 +1847,7 @@ nsDOMWindowUtils::SendContentCommandEvent(const nsAString& aType,
NS_IMETHODIMP
nsDOMWindowUtils::GetClassName(const JS::Value& aObject, JSContext* aCx, char** aName)
{
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}

View File

@ -3428,7 +3428,7 @@ nsGlobalWindow::GetOpener(nsIDOMWindow** aOpener)
}
// First, check if we were called from a privileged chrome script
if (nsContentUtils::IsCallerTrustedForRead()) {
if (nsContentUtils::IsCallerChrome()) {
NS_ADDREF(*aOpener = opener);
return NS_OK;
}

View File

@ -76,7 +76,7 @@ nsHistory::GetLength(int32_t* aLength)
NS_IMETHODIMP
nsHistory::GetCurrent(nsAString& aCurrent)
{
if (!nsContentUtils::IsCallerTrustedForRead())
if (!nsContentUtils::IsCallerChrome())
return NS_ERROR_DOM_SECURITY_ERR;
int32_t curIndex=0;
@ -108,7 +108,7 @@ nsHistory::GetCurrent(nsAString& aCurrent)
NS_IMETHODIMP
nsHistory::GetPrevious(nsAString& aPrevious)
{
if (!nsContentUtils::IsCallerTrustedForRead())
if (!nsContentUtils::IsCallerChrome())
return NS_ERROR_DOM_SECURITY_ERR;
int32_t curIndex;
@ -140,7 +140,7 @@ nsHistory::GetPrevious(nsAString& aPrevious)
NS_IMETHODIMP
nsHistory::GetNext(nsAString& aNext)
{
if (!nsContentUtils::IsCallerTrustedForRead())
if (!nsContentUtils::IsCallerChrome())
return NS_ERROR_DOM_SECURITY_ERR;
int32_t curIndex;
@ -335,7 +335,7 @@ NS_IMETHODIMP
nsHistory::Item(uint32_t aIndex, nsAString& aReturn)
{
aReturn.Truncate();
if (!nsContentUtils::IsCallerTrustedForRead()) {
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}