Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | #include "nsIPrefBranch.idl" |
michael@0 | 8 | |
michael@0 | 9 | %{C++ |
michael@0 | 10 | struct PrefTuple; |
michael@0 | 11 | #include "nsTArrayForwardDeclare.h" |
michael@0 | 12 | %} |
michael@0 | 13 | |
michael@0 | 14 | [ptr] native nsPreferencesArrayPtr(nsTArray<PrefTuple>); |
michael@0 | 15 | [ptr] native nsPreferencePtr(PrefTuple); |
michael@0 | 16 | [ptr] native nsPreferencePtrConst(const PrefTuple); |
michael@0 | 17 | |
michael@0 | 18 | interface nsIFile; |
michael@0 | 19 | |
michael@0 | 20 | /** |
michael@0 | 21 | * The nsIPrefService interface is the main entry point into the back end |
michael@0 | 22 | * preferences management library. The preference service is directly |
michael@0 | 23 | * responsible for the management of the preferences files and also facilitates |
michael@0 | 24 | * access to the preference branch object which allows the direct manipulation |
michael@0 | 25 | * of the preferences themselves. |
michael@0 | 26 | * |
michael@0 | 27 | * @see nsIPrefBranch |
michael@0 | 28 | */ |
michael@0 | 29 | |
michael@0 | 30 | [scriptable, uuid(decb9cc7-c08f-4ea5-be91-a8fc637ce2d2)] |
michael@0 | 31 | interface nsIPrefService : nsISupports |
michael@0 | 32 | { |
michael@0 | 33 | /** |
michael@0 | 34 | * Called to read in the preferences specified in a user preference file. |
michael@0 | 35 | * |
michael@0 | 36 | * @param aFile The file to be read. |
michael@0 | 37 | * |
michael@0 | 38 | * @note |
michael@0 | 39 | * If nullptr is passed in for the aFile parameter the default preferences |
michael@0 | 40 | * file(s) [prefs.js, user.js] will be read and processed. |
michael@0 | 41 | * |
michael@0 | 42 | * @throws Error File failed to read or contained invalid data. |
michael@0 | 43 | * |
michael@0 | 44 | * @see savePrefFile |
michael@0 | 45 | * @see nsIFile |
michael@0 | 46 | */ |
michael@0 | 47 | void readUserPrefs(in nsIFile aFile); |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Called to completely flush and re-initialize the preferences system. |
michael@0 | 51 | * |
michael@0 | 52 | * @throws Error The preference service failed to restart correctly. |
michael@0 | 53 | */ |
michael@0 | 54 | void resetPrefs(); |
michael@0 | 55 | |
michael@0 | 56 | /** |
michael@0 | 57 | * Called to reset all preferences with user set values back to the |
michael@0 | 58 | * application default values. |
michael@0 | 59 | */ |
michael@0 | 60 | void resetUserPrefs(); |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Called to write current preferences state to a file. |
michael@0 | 64 | * |
michael@0 | 65 | * @param aFile The file to be written. |
michael@0 | 66 | * |
michael@0 | 67 | * @note |
michael@0 | 68 | * If nullptr is passed in for the aFile parameter the preference data is |
michael@0 | 69 | * written out to the current preferences file (usually prefs.js.) |
michael@0 | 70 | * |
michael@0 | 71 | * @throws Error File failed to write. |
michael@0 | 72 | * |
michael@0 | 73 | * @see readUserPrefs |
michael@0 | 74 | * @see nsIFile |
michael@0 | 75 | */ |
michael@0 | 76 | void savePrefFile(in nsIFile aFile); |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | * Call to get a Preferences "Branch" which accesses user preference data. |
michael@0 | 80 | * Using a Set method on this object will always create or set a user |
michael@0 | 81 | * preference value. When using a Get method a user set value will be |
michael@0 | 82 | * returned if one exists, otherwise a default value will be returned. |
michael@0 | 83 | * |
michael@0 | 84 | * @param aPrefRoot The preference "root" on which to base this "branch". |
michael@0 | 85 | * For example, if the root "browser.startup." is used, the |
michael@0 | 86 | * branch will be able to easily access the preferences |
michael@0 | 87 | * "browser.startup.page", "browser.startup.homepage", or |
michael@0 | 88 | * "browser.startup.homepage_override" by simply requesting |
michael@0 | 89 | * "page", "homepage", or "homepage_override". nullptr or "" |
michael@0 | 90 | * may be used to access to the entire preference "tree". |
michael@0 | 91 | * |
michael@0 | 92 | * @return nsIPrefBranch The object representing the requested branch. |
michael@0 | 93 | * |
michael@0 | 94 | * @see getDefaultBranch |
michael@0 | 95 | */ |
michael@0 | 96 | nsIPrefBranch getBranch(in string aPrefRoot); |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Call to get a Preferences "Branch" which accesses only the default |
michael@0 | 100 | * preference data. Using a Set method on this object will always create or |
michael@0 | 101 | * set a default preference value. When using a Get method a default value |
michael@0 | 102 | * will always be returned. |
michael@0 | 103 | * |
michael@0 | 104 | * @param aPrefRoot The preference "root" on which to base this "branch". |
michael@0 | 105 | * For example, if the root "browser.startup." is used, the |
michael@0 | 106 | * branch will be able to easily access the preferences |
michael@0 | 107 | * "browser.startup.page", "browser.startup.homepage", or |
michael@0 | 108 | * "browser.startup.homepage_override" by simply requesting |
michael@0 | 109 | * "page", "homepage", or "homepage_override". nullptr or "" |
michael@0 | 110 | * may be used to access to the entire preference "tree". |
michael@0 | 111 | * |
michael@0 | 112 | * @note |
michael@0 | 113 | * Few consumers will want to create default branch objects. Many of the |
michael@0 | 114 | * branch methods do nothing on a default branch because the operations only |
michael@0 | 115 | * make sense when applied to user set preferences. |
michael@0 | 116 | * |
michael@0 | 117 | * @return nsIPrefBranch The object representing the requested default branch. |
michael@0 | 118 | * |
michael@0 | 119 | * @see getBranch |
michael@0 | 120 | */ |
michael@0 | 121 | nsIPrefBranch getDefaultBranch(in string aPrefRoot); |
michael@0 | 122 | |
michael@0 | 123 | }; |
michael@0 | 124 | |
michael@0 | 125 | %{C++ |
michael@0 | 126 | |
michael@0 | 127 | #define NS_PREFSERVICE_CID \ |
michael@0 | 128 | { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */ \ |
michael@0 | 129 | 0x91ca2441, \ |
michael@0 | 130 | 0x050f, \ |
michael@0 | 131 | 0x4f7c, \ |
michael@0 | 132 | { 0x9d, 0xf8, 0x75, 0xb4, 0x0e, 0xa4, 0x01, 0x56 } \ |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | #define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1" |
michael@0 | 136 | |
michael@0 | 137 | /** |
michael@0 | 138 | * Notification sent before reading the default user preferences files. |
michael@0 | 139 | */ |
michael@0 | 140 | #define NS_PREFSERVICE_READ_TOPIC_ID "prefservice:before-read-userprefs" |
michael@0 | 141 | |
michael@0 | 142 | /** |
michael@0 | 143 | * Notification sent when resetPrefs has been called, but before the actual |
michael@0 | 144 | * reset process occurs. |
michael@0 | 145 | */ |
michael@0 | 146 | #define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset" |
michael@0 | 147 | |
michael@0 | 148 | /** |
michael@0 | 149 | * Notification sent when after reading app-provided default |
michael@0 | 150 | * preferences, but before user profile override defaults or extension |
michael@0 | 151 | * defaults are loaded. |
michael@0 | 152 | */ |
michael@0 | 153 | #define NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID "prefservice:after-app-defaults" |
michael@0 | 154 | |
michael@0 | 155 | %} |