nsIAddonPolicyService.idl 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. #include "nsIURI.idl"
  8. /**
  9. * This interface allows the security manager to query custom per-addon security
  10. * policy.
  11. */
  12. [scriptable,uuid(8a034ef9-9d14-4c5d-8319-06c1ab574baa)]
  13. interface nsIAddonPolicyService : nsISupports
  14. {
  15. /**
  16. * Returns the base content security policy, which is applied to all
  17. * extension documents, in addition to any custom policies.
  18. */
  19. readonly attribute AString baseCSP;
  20. /**
  21. * Returns the default content security policy which applies to extension
  22. * documents which do not specify any custom policies.
  23. */
  24. readonly attribute AString defaultCSP;
  25. /**
  26. * Returns the content security policy which applies to documents belonging
  27. * to the extension with the given ID. This may be either a custom policy,
  28. * if one was supplied, or the default policy if one was not.
  29. */
  30. AString getAddonCSP(in AString aAddonId);
  31. /**
  32. * Returns the generated background page as a data-URI, if any. If the addon
  33. * does not have an auto-generated background page, an empty string is
  34. * returned.
  35. */
  36. ACString getGeneratedBackgroundPageUrl(in ACString aAddonId);
  37. /**
  38. * Returns true if the addon was granted the |aPerm| API permission.
  39. */
  40. boolean addonHasPermission(in AString aAddonId, in AString aPerm);
  41. /**
  42. * Returns true if unprivileged code associated with the given addon may load
  43. * data from |aURI|.
  44. */
  45. boolean addonMayLoadURI(in AString aAddonId, in nsIURI aURI);
  46. /**
  47. * Returns true if a given extension:// URI is web-accessible.
  48. */
  49. boolean extensionURILoadableByAnyone(in nsIURI aURI);
  50. /**
  51. * Maps an extension URI to the ID of the addon it belongs to.
  52. */
  53. AString extensionURIToAddonId(in nsIURI aURI);
  54. };
  55. /**
  56. * This interface exposes functionality related to add-on content policy
  57. * enforcement.
  58. */
  59. [scriptable,uuid(7a4fe60b-9131-45f5-83f3-dc63b5d71a5d)]
  60. interface nsIAddonContentPolicy : nsISupports
  61. {
  62. /**
  63. * Checks a custom content security policy string, to ensure that it meets
  64. * minimum security requirements. Returns null for valid policies, or a
  65. * string describing the error for invalid policies.
  66. */
  67. AString validateAddonCSP(in AString aPolicyString);
  68. };