Bug 1580782 - Expose SchemeIs on nsIPrincipal r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D45653
This commit is contained in:
@@ -410,6 +410,18 @@ BasePrincipal::GetIsAddonOrExpandedAddonPrincipal(bool* aResult) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::SchemeIs(const char* aScheme, bool* aResult) {
|
||||
*aResult = false;
|
||||
nsCOMPtr<nsIURI> prinURI;
|
||||
nsresult rv = GetURI(getter_AddRefs(prinURI));
|
||||
if (NS_FAILED(rv) || !prinURI) {
|
||||
return NS_OK;
|
||||
}
|
||||
*aResult = prinURI->SchemeIs(aScheme);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetOriginAttributes(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aVal) {
|
||||
|
||||
@@ -116,6 +116,7 @@ class BasePrincipal : public nsJSPrincipals {
|
||||
NS_IMETHOD GetIsContentPrincipal(bool* aResult) override;
|
||||
NS_IMETHOD GetIsExpandedPrincipal(bool* aResult) override;
|
||||
NS_IMETHOD GetIsSystemPrincipal(bool* aResult) override;
|
||||
NS_IMETHOD SchemeIs(const char* aScheme, bool* aResult) override;
|
||||
NS_IMETHOD GetIsAddonOrExpandedAddonPrincipal(bool* aResult) override;
|
||||
NS_IMETHOD GetOriginAttributes(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aVal) final;
|
||||
|
||||
@@ -180,6 +180,22 @@ interface nsIPrincipal : nsISerializable
|
||||
*/
|
||||
readonly attribute ACString origin;
|
||||
|
||||
/**
|
||||
* Checks if the Principal's URI Scheme matches with the parameter
|
||||
*
|
||||
* @param scheme The scheme to be checked
|
||||
*/
|
||||
boolean schemeIs(in string scheme);
|
||||
|
||||
// Nicer, C++ Callable Version of SchemeIs
|
||||
%{C++
|
||||
inline bool SchemeIs(const char* aScheme) {
|
||||
bool ret;
|
||||
SchemeIs(aScheme, &ret);
|
||||
return ret;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* The base part of |origin| without the concatenation with |originSuffix|.
|
||||
* This doesn't have the important invariants described above with |origin|,
|
||||
|
||||
Reference in New Issue
Block a user