summaryrefslogtreecommitdiff
path: root/chrome/nsIChromeRegistry.idl
blob: 8df3a8bdf9107af18e1b63c793b60af92cbf36d2 (plain)
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
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIURI;

[scriptable, uuid(249fb5ad-ae29-4e2c-a728-ba5cf464d188)]
interface nsIChromeRegistry : nsISupports
{
  const int32_t NONE = 0;
  const int32_t PARTIAL = 1;
  const int32_t FULL = 2;

  /**
   * Resolve a chrome URL to an loadable URI using the information in the
   * registry. Does not modify aChromeURL.
   *
   * Chrome URLs are allowed to be specified in "shorthand", leaving the
   * "file" portion off. In that case, the URL is expanded to:
   *
   *   chrome://package/provider/package.ext
   *
   * where "ext" is:
   *
   *   "xul" for a "content" package,
   *   "css" for a "skin" package, and
   *   "dtd" for a "locale" package.
   *
   * @param aChromeURL the URL that is to be converted.
   */
  nsIURI convertChromeURL(in nsIURI aChromeURL);

  /**
   * refresh the chrome list at runtime, looking for new packages/etc
   */
  void checkForNewChrome();

  /**
   * returns whether XPCNativeWrappers are enabled for aURI.
   */
  [notxpcom] boolean wrappersEnabled(in nsIURI aURI);
};

[scriptable, uuid(93251ddf-5e85-4172-ac2a-31780562974f)]
interface nsIXULChromeRegistry : nsIChromeRegistry
{
  /* Should be called when locales change to reload all chrome (including XUL). */
  void reloadChrome();

  // If the optional asBCP47 parameter is true, the locale code will be
  // converted to a BCP47 language tag; in particular, this means that
  // "ja-JP-mac" will be returned as "ja-JP-x-lvariant-mac", which can be
  // passed to ECMA402 Intl API methods without throwing a RangeError.
  ACString getSelectedLocale(in ACString packageName,
                             [optional] in boolean asBCP47);
  
  // Get the direction of the locale via the intl.uidirection.<locale> pref
  boolean isLocaleRTL(in ACString package);

  /* Should be called when skins change. Reloads only stylesheets. */
  void refreshSkins();

  /**
   * Installable skin XBL is not always granted the same privileges as other
   * chrome. This asks the chrome registry whether scripts are allowed to be
   * run for a particular chrome URI. Do not pass non-chrome URIs to this
   * method.
   */
  boolean allowScriptsForPackage(in nsIURI url);

  /**
   * Content should only be allowed to load chrome JS from certain packages.
   * This method reflects the contentaccessible flag on packages.
   * Do not pass non-chrome URIs to this method.
   */
  boolean allowContentToAccess(in nsIURI url);

  /**
   * Returns true if the passed chrome URL is allowed to be loaded in a remote
   * process. This reflects the remoteenabled flag on packages.
   * Do not pass non-chrome URIs to this method.
   */
  boolean canLoadURLRemotely(in nsIURI url);

  /**
   * Returns true if the passed chrome URL must be loaded in a remote process.
   * This reflects the remoterequired flag on packages.
   * Do not pass non-chrome URIs to this method.
   */
  boolean mustLoadURLRemotely(in nsIURI url);
};

%{ C++

#define NS_CHROMEREGISTRY_CONTRACTID \
  "@mozilla.org/chrome/chrome-registry;1"

/**
 * Chrome registry will notify various caches that all chrome files need
 * flushing.
 */
#define NS_CHROME_FLUSH_TOPIC \
  "chrome-flush-caches"

/**
 * Chrome registry will notify various caches that skin files need flushing.
 * If "chrome-flush-caches" is notified, this topic will *not* be notified.
 */
#define NS_CHROME_FLUSH_SKINS_TOPIC \
  "chrome-flush-skin-caches"

%}