1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
// // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIPrincipal.idl // /// `interface nsIPrincipal : nsISerializable` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIPrincipal { vtable: *const nsIPrincipalVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIPrincipal. unsafe impl XpCom for nsIPrincipal { const IID: nsIID = nsID(0xf75f502d, 0x79fd, 0x48be, [0xa0, 0x79, 0xe5, 0xa7, 0xb8, 0xf8, 0x0c, 0x8b]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIPrincipal { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIPrincipal. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIPrincipalCoerce { /// Cheaply cast a value of this type from a `nsIPrincipal`. fn coerce_from(v: &nsIPrincipal) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIPrincipalCoerce for nsIPrincipal { #[inline] fn coerce_from(v: &nsIPrincipal) -> &Self { v } } impl nsIPrincipal { /// Cast this `nsIPrincipal` to one of its base interfaces. #[inline] pub fn coerce<T: nsIPrincipalCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIPrincipal { type Target = nsISerializable; #[inline] fn deref(&self) -> &nsISerializable { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISerializableCoerce> nsIPrincipalCoerce for T { #[inline] fn coerce_from(v: &nsIPrincipal) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIPrincipal // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIPrincipalVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISerializableVTable, /* boolean equals (in nsIPrincipal other); */ pub Equals: unsafe extern "system" fn (this: *const nsIPrincipal, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult, /* boolean equalsConsideringDomain (in nsIPrincipal other); */ pub EqualsConsideringDomain: unsafe extern "system" fn (this: *const nsIPrincipal, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult, /* [noscript] readonly attribute unsigned long hashValue; */ pub GetHashValue: unsafe extern "system" fn (this: *const nsIPrincipal, aHashValue: *mut libc::uint32_t) -> nsresult, /* readonly attribute nsIURI URI; */ pub GetURI: unsafe extern "system" fn (this: *const nsIPrincipal, aURI: *mut *const nsIURI) -> nsresult, /* [noscript] attribute nsIURI domain; */ pub GetDomain: unsafe extern "system" fn (this: *const nsIPrincipal, aDomain: *mut *const nsIURI) -> nsresult, /* [noscript] attribute nsIURI domain; */ pub SetDomain: unsafe extern "system" fn (this: *const nsIPrincipal, aDomain: *const nsIURI) -> nsresult, /* boolean subsumes (in nsIPrincipal other); */ pub Subsumes: unsafe extern "system" fn (this: *const nsIPrincipal, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult, /* boolean subsumesConsideringDomain (in nsIPrincipal other); */ pub SubsumesConsideringDomain: unsafe extern "system" fn (this: *const nsIPrincipal, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult, /* boolean subsumesConsideringDomainIgnoringFPD (in nsIPrincipal other); */ pub SubsumesConsideringDomainIgnoringFPD: unsafe extern "system" fn (this: *const nsIPrincipal, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult, /* void checkMayLoad (in nsIURI uri, in boolean report, in boolean allowIfInheritsPrincipal); */ pub CheckMayLoad: unsafe extern "system" fn (this: *const nsIPrincipal, uri: *const nsIURI, report: bool, allowIfInheritsPrincipal: bool) -> nsresult, /* [noscript] attribute nsIContentSecurityPolicy csp; */ pub GetCsp: unsafe extern "system" fn (this: *const nsIPrincipal, aCsp: *mut *const nsIContentSecurityPolicy) -> nsresult, /* [noscript] attribute nsIContentSecurityPolicy csp; */ pub SetCsp: unsafe extern "system" fn (this: *const nsIPrincipal, aCsp: *const nsIContentSecurityPolicy) -> nsresult, /* [noscript] nsIContentSecurityPolicy ensureCSP (in nsIDOMDocument aDocument); */ pub EnsureCSP: unsafe extern "system" fn (this: *const nsIPrincipal, aDocument: *const nsIDOMDocument, _retval: *mut *const nsIContentSecurityPolicy) -> nsresult, /* [noscript] readonly attribute nsIContentSecurityPolicy preloadCsp; */ pub GetPreloadCsp: unsafe extern "system" fn (this: *const nsIPrincipal, aPreloadCsp: *mut *const nsIContentSecurityPolicy) -> nsresult, /* [noscript] nsIContentSecurityPolicy ensurePreloadCSP (in nsIDOMDocument aDocument); */ pub EnsurePreloadCSP: unsafe extern "system" fn (this: *const nsIPrincipal, aDocument: *const nsIDOMDocument, _retval: *mut *const nsIContentSecurityPolicy) -> nsresult, /* readonly attribute AString cspJSON; */ pub GetCspJSON: unsafe extern "system" fn (this: *const nsIPrincipal, aCspJSON: &mut ::nsstring::nsAString) -> nsresult, /* [implicit_jscontext] readonly attribute jsval originAttributes; */ /// Unable to generate binding because `native type JS::Value is unsupported` pub GetOriginAttributes: *const ::libc::c_void, /* [binaryname(OriginAttributesRef),noscript,nostdcall,notxpcom] const_OriginAttributes OriginAttributesRef (); */ /// Unable to generate binding because `nostdcall is unsupported` pub OriginAttributesRef: *const ::libc::c_void, /* readonly attribute ACString origin; */ pub GetOrigin: unsafe extern "system" fn (this: *const nsIPrincipal, aOrigin: &mut ::nsstring::nsACString) -> nsresult, /* readonly attribute ACString originNoSuffix; */ pub GetOriginNoSuffix: unsafe extern "system" fn (this: *const nsIPrincipal, aOriginNoSuffix: &mut ::nsstring::nsACString) -> nsresult, /* readonly attribute AUTF8String originSuffix; */ pub GetOriginSuffix: unsafe extern "system" fn (this: *const nsIPrincipal, aOriginSuffix: &mut ::nsstring::nsACString) -> nsresult, /* readonly attribute ACString baseDomain; */ pub GetBaseDomain: unsafe extern "system" fn (this: *const nsIPrincipal, aBaseDomain: &mut ::nsstring::nsACString) -> nsresult, /* [infallible] readonly attribute unsigned long appId; */ pub GetAppId: unsafe extern "system" fn (this: *const nsIPrincipal, aAppId: *mut libc::uint32_t) -> nsresult, /* readonly attribute AString addonId; */ pub GetAddonId: unsafe extern "system" fn (this: *const nsIPrincipal, aAddonId: &mut ::nsstring::nsAString) -> nsresult, /* readonly attribute nsISupports addonPolicy; */ pub GetAddonPolicy: unsafe extern "system" fn (this: *const nsIPrincipal, aAddonPolicy: *mut *const nsISupports) -> nsresult, /* [infallible] readonly attribute unsigned long userContextId; */ pub GetUserContextId: unsafe extern "system" fn (this: *const nsIPrincipal, aUserContextId: *mut libc::uint32_t) -> nsresult, /* [infallible] readonly attribute unsigned long privateBrowsingId; */ pub GetPrivateBrowsingId: unsafe extern "system" fn (this: *const nsIPrincipal, aPrivateBrowsingId: *mut libc::uint32_t) -> nsresult, /* [infallible] readonly attribute boolean isInIsolatedMozBrowserElement; */ pub GetIsInIsolatedMozBrowserElement: unsafe extern "system" fn (this: *const nsIPrincipal, aIsInIsolatedMozBrowserElement: *mut bool) -> nsresult, /* [infallible] readonly attribute boolean isNullPrincipal; */ pub GetIsNullPrincipal: unsafe extern "system" fn (this: *const nsIPrincipal, aIsNullPrincipal: *mut bool) -> nsresult, /* [infallible] readonly attribute boolean isCodebasePrincipal; */ pub GetIsCodebasePrincipal: unsafe extern "system" fn (this: *const nsIPrincipal, aIsCodebasePrincipal: *mut bool) -> nsresult, /* [infallible] readonly attribute boolean isExpandedPrincipal; */ pub GetIsExpandedPrincipal: unsafe extern "system" fn (this: *const nsIPrincipal, aIsExpandedPrincipal: *mut bool) -> nsresult, /* [infallible] readonly attribute boolean isSystemPrincipal; */ pub GetIsSystemPrincipal: unsafe extern "system" fn (this: *const nsIPrincipal, aIsSystemPrincipal: *mut bool) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIPrincipal { /// ```text /// /** /// * Returns whether the other principal is equivalent to this principal. /// * Principals are considered equal if they are the same principal, or /// * they have the same origin. /// */ /// ``` /// /// `boolean equals (in nsIPrincipal other);` #[inline] pub unsafe fn Equals(&self, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult { ((*self.vtable).Equals)(self, other, _retval) } /// ```text /// /** /// * Like equals, but takes document.domain changes into account. /// */ /// ``` /// /// `boolean equalsConsideringDomain (in nsIPrincipal other);` #[inline] pub unsafe fn EqualsConsideringDomain(&self, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult { ((*self.vtable).EqualsConsideringDomain)(self, other, _retval) } /// ```text /// /** /// * Returns a hash value for the principal. /// */ /// ``` /// /// `[noscript] readonly attribute unsigned long hashValue;` #[inline] pub unsafe fn GetHashValue(&self, aHashValue: *mut libc::uint32_t) -> nsresult { ((*self.vtable).GetHashValue)(self, aHashValue) } /// ```text /// /** /// * The codebase URI to which this principal pertains. This is /// * generally the document URI. /// */ /// ``` /// /// `readonly attribute nsIURI URI;` #[inline] pub unsafe fn GetURI(&self, aURI: *mut *const nsIURI) -> nsresult { ((*self.vtable).GetURI)(self, aURI) } /// ```text /// /** /// * The domain URI to which this principal pertains. /// * This is null unless script successfully sets document.domain to our URI /// * or a superdomain of our URI. /// * Setting this has no effect on the URI. /// * See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#Changing_origin /// */ /// ``` /// /// `[noscript] attribute nsIURI domain;` #[inline] pub unsafe fn GetDomain(&self, aDomain: *mut *const nsIURI) -> nsresult { ((*self.vtable).GetDomain)(self, aDomain) } /// ```text /// /** /// * The domain URI to which this principal pertains. /// * This is null unless script successfully sets document.domain to our URI /// * or a superdomain of our URI. /// * Setting this has no effect on the URI. /// * See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#Changing_origin /// */ /// ``` /// /// `[noscript] attribute nsIURI domain;` #[inline] pub unsafe fn SetDomain(&self, aDomain: *const nsIURI) -> nsresult { ((*self.vtable).SetDomain)(self, aDomain) } /// ```text /// /** /// * Returns whether the other principal is equal to or weaker than this /// * principal. Principals are equal if they are the same object or they /// * have the same origin. /// * /// * Thus a principal always subsumes itself. /// * /// * The system principal subsumes itself and all other principals. /// * /// * A null principal (corresponding to an unknown, hence assumed minimally /// * privileged, security context) is not equal to any other principal /// * (including other null principals), and therefore does not subsume /// * anything but itself. /// */ /// ``` /// /// `boolean subsumes (in nsIPrincipal other);` #[inline] pub unsafe fn Subsumes(&self, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult { ((*self.vtable).Subsumes)(self, other, _retval) } /// ```text /// /** /// * Same as the previous method, subsumes(), but takes document.domain into /// * account. /// */ /// ``` /// /// `boolean subsumesConsideringDomain (in nsIPrincipal other);` #[inline] pub unsafe fn SubsumesConsideringDomain(&self, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult { ((*self.vtable).SubsumesConsideringDomain)(self, other, _retval) } /// ```text /// /** /// * Same as the subsumesConsideringDomain(), but ignores the first party /// * domain in its originAttributes. /// */ /// ``` /// /// `boolean subsumesConsideringDomainIgnoringFPD (in nsIPrincipal other);` #[inline] pub unsafe fn SubsumesConsideringDomainIgnoringFPD(&self, other: *const nsIPrincipal, _retval: *mut bool) -> nsresult { ((*self.vtable).SubsumesConsideringDomainIgnoringFPD)(self, other, _retval) } /// ```text /// /** /// * Checks whether this principal is allowed to load the network resource /// * located at the given URI under the same-origin policy. This means that /// * codebase principals are only allowed to load resources from the same /// * domain, the system principal is allowed to load anything, and null /// * principals can only load URIs where they are the principal. This is /// * changed by the optional flag allowIfInheritsPrincipal (which defaults to /// * false) which allows URIs that inherit their loader's principal. /// * /// * If the load is allowed this function does nothing. If the load is not /// * allowed the function throws NS_ERROR_DOM_BAD_URI. /// * /// * NOTE: Other policies might override this, such as the Access-Control /// * specification. /// * NOTE: The 'domain' attribute has no effect on the behaviour of this /// * function. /// * /// * /// * @param uri The URI about to be loaded. /// * @param report If true, will report a warning to the console service /// * if the load is not allowed. /// * @param allowIfInheritsPrincipal If true, the load is allowed if the /// * loadee inherits the principal of the /// * loader. /// * @throws NS_ERROR_DOM_BAD_URI if the load is not allowed. /// */ /// ``` /// /// `void checkMayLoad (in nsIURI uri, in boolean report, in boolean allowIfInheritsPrincipal);` #[inline] pub unsafe fn CheckMayLoad(&self, uri: *const nsIURI, report: bool, allowIfInheritsPrincipal: bool) -> nsresult { ((*self.vtable).CheckMayLoad)(self, uri, report, allowIfInheritsPrincipal) } /// ```text /// /** /// * A Content Security Policy associated with this principal. /// * Use this function to query the associated CSP with this principal. /// * Please *only* use this function to *set* a CSP when you know exactly what you are doing. /// * Most likely you want to call ensureCSP instead of setCSP. /// */ /// ``` /// /// `[noscript] attribute nsIContentSecurityPolicy csp;` #[inline] pub unsafe fn GetCsp(&self, aCsp: *mut *const nsIContentSecurityPolicy) -> nsresult { ((*self.vtable).GetCsp)(self, aCsp) } /// ```text /// /** /// * A Content Security Policy associated with this principal. /// * Use this function to query the associated CSP with this principal. /// * Please *only* use this function to *set* a CSP when you know exactly what you are doing. /// * Most likely you want to call ensureCSP instead of setCSP. /// */ /// ``` /// /// `[noscript] attribute nsIContentSecurityPolicy csp;` #[inline] pub unsafe fn SetCsp(&self, aCsp: *const nsIContentSecurityPolicy) -> nsresult { ((*self.vtable).SetCsp)(self, aCsp) } /// `[noscript] nsIContentSecurityPolicy ensureCSP (in nsIDOMDocument aDocument);` #[inline] pub unsafe fn EnsureCSP(&self, aDocument: *const nsIDOMDocument, _retval: *mut *const nsIContentSecurityPolicy) -> nsresult { ((*self.vtable).EnsureCSP)(self, aDocument, _retval) } /// ```text /// /** /// * A speculative Content Security Policy associated with this /// * principal. Set during speculative loading (preloading) and /// * used *only* for preloads. /// * /// * If you want to query the CSP associated with that principal, /// * then this is *not* what you want. Instead query 'csp'. /// */ /// ``` /// /// `[noscript] readonly attribute nsIContentSecurityPolicy preloadCsp;` #[inline] pub unsafe fn GetPreloadCsp(&self, aPreloadCsp: *mut *const nsIContentSecurityPolicy) -> nsresult { ((*self.vtable).GetPreloadCsp)(self, aPreloadCsp) } /// `[noscript] nsIContentSecurityPolicy ensurePreloadCSP (in nsIDOMDocument aDocument);` #[inline] pub unsafe fn EnsurePreloadCSP(&self, aDocument: *const nsIDOMDocument, _retval: *mut *const nsIContentSecurityPolicy) -> nsresult { ((*self.vtable).EnsurePreloadCSP)(self, aDocument, _retval) } /// ```text /// /** /// * The CSP of the principal in JSON notation. /// * Note, that the CSP itself is not exposed to JS, but script /// * should be able to obtain a JSON representation of the CSP. /// */ /// ``` /// /// `readonly attribute AString cspJSON;` #[inline] pub unsafe fn GetCspJSON(&self, aCspJSON: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetCspJSON)(self, aCspJSON) } /// ```text /// /** /// * A dictionary of the non-default origin attributes associated with this /// * nsIPrincipal. /// * /// * Attributes are tokens that are taken into account when determining whether /// * two principals are same-origin - if any attributes differ, the principals /// * are cross-origin, even if the scheme, host, and port are the same. /// * Attributes should also be considered for all security and bucketing decisions, /// * even those which make non-standard comparisons (like cookies, which ignore /// * scheme, or quotas, which ignore subdomains). /// * /// * If you're looking for an easy-to-use canonical stringification of the origin /// * attributes, see |originSuffix| below. /// */ /// ``` /// /// `[implicit_jscontext] readonly attribute jsval originAttributes;` const _GetOriginAttributes: () = (); /// `[binaryname(OriginAttributesRef),noscript,nostdcall,notxpcom] const_OriginAttributes OriginAttributesRef ();` const _OriginAttributesRef: () = (); /// ```text /// /** /// * A canonical representation of the origin for this principal. This /// * consists of a base string (which, for codebase principals, is of the /// * format scheme://host:port), concatenated with |originAttributes| (see /// * below). /// * /// * We maintain the invariant that principalA.equals(principalB) if and only /// * if principalA.origin == principalB.origin. /// */ /// ``` /// /// `readonly attribute ACString origin;` #[inline] pub unsafe fn GetOrigin(&self, aOrigin: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetOrigin)(self, aOrigin) } /// ```text /// /** /// * The base part of |origin| without the concatenation with |originSuffix|. /// * This doesn't have the important invariants described above with |origin|, /// * and as such should only be used for legacy situations. /// */ /// ``` /// /// `readonly attribute ACString originNoSuffix;` #[inline] pub unsafe fn GetOriginNoSuffix(&self, aOriginNoSuffix: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetOriginNoSuffix)(self, aOriginNoSuffix) } /// ```text /// /** /// * A string of the form !key1=value1&key2=value2, where each pair represents /// * an attribute with a non-default value. If all attributes have default /// * values, this is the empty string. /// * /// * The value of .originSuffix is automatically serialized into .origin, so any /// * consumers using that are automatically origin-attribute-aware. Consumers with /// * special requirements must inspect and compare .originSuffix manually. /// */ /// ``` /// /// `readonly attribute AUTF8String originSuffix;` #[inline] pub unsafe fn GetOriginSuffix(&self, aOriginSuffix: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetOriginSuffix)(self, aOriginSuffix) } /// ```text /// /** /// * The base domain of the codebase URI to which this principal pertains /// * (generally the document URI), handling null principals and /// * non-hierarchical schemes correctly. /// */ /// ``` /// /// `readonly attribute ACString baseDomain;` #[inline] pub unsafe fn GetBaseDomain(&self, aBaseDomain: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetBaseDomain)(self, aBaseDomain) } /// ```text /// /** /// * Gets the id of the app this principal is inside. If this principal is /// * not inside an app, returns nsIScriptSecurityManager::NO_APP_ID. /// * /// * Note that this principal does not necessarily have the permissions of /// * the app identified by appId. For example, this principal might /// * correspond to an iframe whose origin differs from that of the app frame /// * containing it. In this case, the iframe will have the appId of its /// * containing app frame, but the iframe must not run with the app's /// * permissions. /// * /// * Similarly, this principal might correspond to an <iframe mozbrowser> /// * inside an app frame; in this case, the content inside the iframe should /// * not have any of the app's permissions, even if the iframe is at the same /// * origin as the app. /// */ /// ``` /// /// `[infallible] readonly attribute unsigned long appId;` #[inline] pub unsafe fn GetAppId(&self) -> libc::uint32_t { let mut result = <libc::uint32_t as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetAppId)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } /// ```text /// /** /// * Gets the ID of the add-on this principal belongs to. /// */ /// ``` /// /// `readonly attribute AString addonId;` #[inline] pub unsafe fn GetAddonId(&self, aAddonId: &mut ::nsstring::nsAString) -> nsresult { ((*self.vtable).GetAddonId)(self, aAddonId) } /// `readonly attribute nsISupports addonPolicy;` #[inline] pub unsafe fn GetAddonPolicy(&self, aAddonPolicy: *mut *const nsISupports) -> nsresult { ((*self.vtable).GetAddonPolicy)(self, aAddonPolicy) } /// ```text /// /** /// * Gets the id of the user context this principal is inside. If this /// * principal is inside the default userContext, this returns /// * nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID. /// */ /// ``` /// /// `[infallible] readonly attribute unsigned long userContextId;` #[inline] pub unsafe fn GetUserContextId(&self) -> libc::uint32_t { let mut result = <libc::uint32_t as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetUserContextId)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } /// ```text /// /** /// * Gets the id of the private browsing state of the context containing /// * this principal. If the principal has a private browsing value of 0, it /// * is not in private browsing. /// */ /// ``` /// /// `[infallible] readonly attribute unsigned long privateBrowsingId;` #[inline] pub unsafe fn GetPrivateBrowsingId(&self) -> libc::uint32_t { let mut result = <libc::uint32_t as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetPrivateBrowsingId)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } /// ```text /// /** /// * Returns true iff the principal is inside an isolated mozbrowser element. /// * <xul:browser> is not considered to be a mozbrowser element. /// * <iframe mozbrowser noisolation> does not count as isolated since /// * isolation is disabled. Isolation can only be disabled if the /// * containing document is chrome. /// */ /// ``` /// /// `[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;` #[inline] pub unsafe fn GetIsInIsolatedMozBrowserElement(&self) -> bool { let mut result = <bool as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetIsInIsolatedMozBrowserElement)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } /// ```text /// /** /// * Returns true iff this is a null principal (corresponding to an /// * unknown, hence assumed minimally privileged, security context). /// */ /// ``` /// /// `[infallible] readonly attribute boolean isNullPrincipal;` #[inline] pub unsafe fn GetIsNullPrincipal(&self) -> bool { let mut result = <bool as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetIsNullPrincipal)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } /// ```text /// /** /// * Returns true iff this principal corresponds to a codebase origin. /// */ /// ``` /// /// `[infallible] readonly attribute boolean isCodebasePrincipal;` #[inline] pub unsafe fn GetIsCodebasePrincipal(&self) -> bool { let mut result = <bool as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetIsCodebasePrincipal)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } /// ```text /// /** /// * Returns true iff this is an expanded principal. /// */ /// ``` /// /// `[infallible] readonly attribute boolean isExpandedPrincipal;` #[inline] pub unsafe fn GetIsExpandedPrincipal(&self) -> bool { let mut result = <bool as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetIsExpandedPrincipal)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } /// ```text /// /** /// * Returns true iff this is the system principal. /// */ /// ``` /// /// `[infallible] readonly attribute boolean isSystemPrincipal;` #[inline] pub unsafe fn GetIsSystemPrincipal(&self) -> bool { let mut result = <bool as ::std::default::Default>::default(); let _rv = ((*self.vtable).GetIsSystemPrincipal)(self, &mut result); debug_assert!(::nserror::NsresultExt::succeeded(_rv)); result } } /// `interface nsIExpandedPrincipal : nsISupports` /// /// ```text /// /** /// * If SystemPrincipal is too risky to use, but we want a principal to access /// * more than one origin, ExpandedPrincipals letting us define an array of /// * principals it subsumes. So script with an ExpandedPrincipals will gain /// * same origin access when at least one of its principals it contains gained /// * sameorigin acccess. An ExpandedPrincipal will be subsumed by the system /// * principal, and by another ExpandedPrincipal that has all its principals. /// * It is added for jetpack content-scripts to let them interact with the /// * content and a well defined set of other domains, without the risk of /// * leaking out a system principal to the content. See: Bug 734891 /// */ /// ``` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIExpandedPrincipal { vtable: *const nsIExpandedPrincipalVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIExpandedPrincipal. unsafe impl XpCom for nsIExpandedPrincipal { const IID: nsIID = nsID(0xf3e177df, 0x6a5e, 0x489f, [0x80, 0xa7, 0x2d, 0xd1, 0x48, 0x14, 0x71, 0xd8]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIExpandedPrincipal { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIExpandedPrincipal. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIExpandedPrincipalCoerce { /// Cheaply cast a value of this type from a `nsIExpandedPrincipal`. fn coerce_from(v: &nsIExpandedPrincipal) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIExpandedPrincipalCoerce for nsIExpandedPrincipal { #[inline] fn coerce_from(v: &nsIExpandedPrincipal) -> &Self { v } } impl nsIExpandedPrincipal { /// Cast this `nsIExpandedPrincipal` to one of its base interfaces. #[inline] pub fn coerce<T: nsIExpandedPrincipalCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIExpandedPrincipal { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIExpandedPrincipalCoerce for T { #[inline] fn coerce_from(v: &nsIExpandedPrincipal) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIExpandedPrincipal // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIExpandedPrincipalVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* [noscript,nostdcall,notxpcom] PrincipalArray WhiteList (); */ /// Unable to generate binding because `nostdcall is unsupported` pub WhiteList: *const ::libc::c_void, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIExpandedPrincipal { /// ```text /// /** /// * An array of principals that the expanded principal subsumes. /// * /// * When an expanded principal is used as a triggering principal for a /// * request that inherits a security context, one of its constitutent /// * principals is inherited rather than the expanded principal itself. The /// * last principal in the whitelist is the default principal to inherit. /// * /// * Note: this list is not reference counted, it is shared, so /// * should not be changed and should only be used ephemerally. /// */ /// ``` /// /// `[noscript,nostdcall,notxpcom] PrincipalArray WhiteList ();` const _WhiteList: () = (); }