diff --git a/extensions/xforms/nsXFormsSubmissionElement.cpp b/extensions/xforms/nsXFormsSubmissionElement.cpp index 5ecdc1abeb5..5b3ba020e44 100644 --- a/extensions/xforms/nsXFormsSubmissionElement.cpp +++ b/extensions/xforms/nsXFormsSubmissionElement.cpp @@ -899,7 +899,7 @@ nsXFormsSubmissionElement::CheckSameOrigin(nsIDocument *aBaseDocument, // same origin check. if (!allowSubmission) { // replace instance is both a send and a load - PRUint8 mode; + nsXFormsUtils::ConnectionType mode; if (mIsReplaceInstance) mode = nsXFormsUtils::kXFormsActionLoadSend; else diff --git a/extensions/xforms/nsXFormsUtils.cpp b/extensions/xforms/nsXFormsUtils.cpp index 0ff6d48a7ba..0b1a9322fd7 100644 --- a/extensions/xforms/nsXFormsUtils.cpp +++ b/extensions/xforms/nsXFormsUtils.cpp @@ -1302,7 +1302,7 @@ nsXFormsUtils::FindParentContext(nsIDOMElement *aElement, /* static */ PRBool nsXFormsUtils::CheckSameOrigin(nsIDocument *aBaseDocument, nsIURI *aTestURI, - PRUint8 aType) + ConnectionType aType) { nsresult rv; @@ -1346,7 +1346,9 @@ nsXFormsUtils::CheckSameOrigin(nsIDocument *aBaseDocument, nsIURI *aTestURI, rv = permMgr->TestPermission(principalURI, "xforms-xd", &perm); if (NS_SUCCEEDED(rv) && perm != nsIPermissionManager::UNKNOWN_ACTION) { - if (perm == kXFormsActionLoadSend || perm == aType) + // Safe cast, as we only have few ConnectionTypes. + PRInt32 permSigned = perm; + if (permSigned == kXFormsActionLoadSend || permSigned == aType) return PR_TRUE; } } diff --git a/extensions/xforms/nsXFormsUtils.h b/extensions/xforms/nsXFormsUtils.h index 4c271312892..3fac8953f27 100644 --- a/extensions/xforms/nsXFormsUtils.h +++ b/extensions/xforms/nsXFormsUtils.h @@ -372,26 +372,30 @@ public: PRInt32 *aContextPosition, PRInt32 *aContextSize); - /** CheckSameOrigin takes in the connection type. We either: - * - Send data, such as doing submission - * - Load data, such as getting external instance data - * - Send and Load data, which is replace instance - */ - static const PRUint8 kXFormsActionSend = 1; - static const PRUint8 kXFormsActionLoad = 2; - static const PRUint8 kXFormsActionLoadSend = 3; + /** Connection type used by CheckSameOrigin */ + enum ConnectionType { + /** Send data, such as doing submission */ + kXFormsActionSend = 1, + + /** Load data, such as getting external instance data */ + kXFormsActionLoad = 2, + + /** Send and Load data, which is replace=instance */ + kXFormsActionLoadSend = 3 + }; /** + * Check whether aTestURI has the same origin as aBaseDocument or the user + * has allowed the connection type using the permission manager + * * @param aBaseDocument The document the XForms lives in * @param aTestURI The uri we are trying to connect to - * @param aType The connection type (see above 3 consts) - * @return true if aTestURI has the same origin as aBaseDocument or - * the user has allowed the connection type using the permission - * manager. + * @param aType The type of connection (see ConnectionType) + * @return Whether connection is allowed */ static NS_HIDDEN_(PRBool) CheckSameOrigin(nsIDocument *aBaseDocument, nsIURI *aTestURI, - PRUint8 aType = kXFormsActionLoad); + ConnectionType aType = kXFormsActionLoad); /** * @return true if aNode is element, its namespace URI is