@@ -172,7 +172,7 @@ export { Management };
172
172
173
173
const { getUniqueId, promiseTimeout } = ExtensionUtils ;
174
174
175
- const { EventEmitter, updateAllowedOrigins } = ExtensionCommon ;
175
+ const { EventEmitter, redefineGetter , updateAllowedOrigins } = ExtensionCommon ;
176
176
177
177
ChromeUtils . defineLazyGetter (
178
178
lazy ,
@@ -869,6 +869,19 @@ const manifestTypes = new Map([
869
869
* `loadManifest` has been called, and completed.
870
870
*/
871
871
export class ExtensionData {
872
+ /**
873
+ * Note: These fields are only available and meant to be used on Extension
874
+ * instances, declared here because methods from this class reference them.
875
+ */
876
+ /** @type {object } TODO: move to the Extension class, bug 1871094. */
877
+ addonData ;
878
+ /** @type {nsIURI } */
879
+ baseURI ;
880
+ /** @type {nsIPrincipal } */
881
+ principal ;
882
+ /** @type {boolean } */
883
+ temporarilyInstalled ;
884
+
872
885
constructor ( rootURI , isPrivileged = false ) {
873
886
this . rootURI = rootURI ;
874
887
this . resourceURL = rootURI . spec ;
@@ -2676,7 +2689,7 @@ class BootstrapScope {
2676
2689
// APP_STARTED. In some situations, such as background and
2677
2690
// persisted listeners, we also need to know that the addon
2678
2691
// was updated.
2679
- this . updateReason = this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ] ;
2692
+ this . updateReason = BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ] ;
2680
2693
// Retain any previously granted permissions that may have migrated
2681
2694
// into the optional list.
2682
2695
if ( data . oldPermissions ) {
@@ -2703,39 +2716,35 @@ class BootstrapScope {
2703
2716
// eslint-disable-next-line no-use-before-define
2704
2717
this . extension = new Extension (
2705
2718
data ,
2706
- this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ] ,
2719
+ BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ] ,
2707
2720
this . updateReason
2708
2721
) ;
2709
2722
return this . extension . startup ( ) ;
2710
2723
}
2711
2724
2712
2725
async shutdown ( data , reason ) {
2713
2726
let result = await this . extension . shutdown (
2714
- this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ]
2727
+ BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ]
2715
2728
) ;
2716
2729
this . extension = null ;
2717
2730
return result ;
2718
2731
}
2719
- }
2720
2732
2721
- ChromeUtils . defineLazyGetter (
2722
- BootstrapScope . prototype ,
2723
- "BOOTSTRAP_REASON_TO_STRING_MAP" ,
2724
- ( ) => {
2725
- const { BOOTSTRAP_REASONS } = lazy . AddonManagerPrivate ;
2726
-
2727
- return Object . freeze ( {
2728
- [ BOOTSTRAP_REASONS . APP_STARTUP ] : "APP_STARTUP" ,
2729
- [ BOOTSTRAP_REASONS . APP_SHUTDOWN ] : "APP_SHUTDOWN" ,
2730
- [ BOOTSTRAP_REASONS . ADDON_ENABLE ] : "ADDON_ENABLE" ,
2731
- [ BOOTSTRAP_REASONS . ADDON_DISABLE ] : "ADDON_DISABLE" ,
2732
- [ BOOTSTRAP_REASONS . ADDON_INSTALL ] : "ADDON_INSTALL" ,
2733
- [ BOOTSTRAP_REASONS . ADDON_UNINSTALL ] : "ADDON_UNINSTALL" ,
2734
- [ BOOTSTRAP_REASONS . ADDON_UPGRADE ] : "ADDON_UPGRADE" ,
2735
- [ BOOTSTRAP_REASONS . ADDON_DOWNGRADE ] : "ADDON_DOWNGRADE" ,
2733
+ static get BOOTSTRAP_REASON_MAP ( ) {
2734
+ const BR = lazy . AddonManagerPrivate . BOOTSTRAP_REASONS ;
2735
+ const value = Object . freeze ( {
2736
+ [ BR . APP_STARTUP ] : "APP_STARTUP" ,
2737
+ [ BR . APP_SHUTDOWN ] : "APP_SHUTDOWN" ,
2738
+ [ BR . ADDON_ENABLE ] : "ADDON_ENABLE" ,
2739
+ [ BR . ADDON_DISABLE ] : "ADDON_DISABLE" ,
2740
+ [ BR . ADDON_INSTALL ] : "ADDON_INSTALL" ,
2741
+ [ BR . ADDON_UNINSTALL ] : "ADDON_UNINSTALL" ,
2742
+ [ BR . ADDON_UPGRADE ] : "ADDON_UPGRADE" ,
2743
+ [ BR . ADDON_DOWNGRADE ] : "ADDON_DOWNGRADE" ,
2736
2744
} ) ;
2745
+ return redefineGetter ( this , "BOOTSTRAP_REASON_TO_STRING_MAP" , value ) ;
2737
2746
}
2738
- ) ;
2747
+ }
2739
2748
2740
2749
class DictionaryBootstrapScope extends BootstrapScope {
2741
2750
install ( data , reason ) { }
@@ -2744,28 +2753,28 @@ class DictionaryBootstrapScope extends BootstrapScope {
2744
2753
startup ( data , reason ) {
2745
2754
// eslint-disable-next-line no-use-before-define
2746
2755
this . dictionary = new Dictionary ( data ) ;
2747
- return this . dictionary . startup ( this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ] ) ;
2756
+ return this . dictionary . startup ( BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ] ) ;
2748
2757
}
2749
2758
2750
- shutdown ( data , reason ) {
2751
- this . dictionary . shutdown ( this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ] ) ;
2759
+ async shutdown ( data , reason ) {
2760
+ this . dictionary . shutdown ( BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ] ) ;
2752
2761
this . dictionary = null ;
2753
2762
}
2754
2763
}
2755
2764
2756
2765
class LangpackBootstrapScope extends BootstrapScope {
2757
2766
install ( data , reason ) { }
2758
2767
uninstall ( data , reason ) { }
2759
- update ( data , reason ) { }
2768
+ async update ( data , reason ) { }
2760
2769
2761
2770
startup ( data , reason ) {
2762
2771
// eslint-disable-next-line no-use-before-define
2763
2772
this . langpack = new Langpack ( data ) ;
2764
- return this . langpack . startup ( this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ] ) ;
2773
+ return this . langpack . startup ( BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ] ) ;
2765
2774
}
2766
2775
2767
- shutdown ( data , reason ) {
2768
- this . langpack . shutdown ( this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ] ) ;
2776
+ async shutdown ( data , reason ) {
2777
+ this . langpack . shutdown ( BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ] ) ;
2769
2778
this . langpack = null ;
2770
2779
}
2771
2780
}
@@ -2779,12 +2788,12 @@ class SitePermissionBootstrapScope extends BootstrapScope {
2779
2788
// eslint-disable-next-line no-use-before-define
2780
2789
this . sitepermission = new SitePermission ( data ) ;
2781
2790
return this . sitepermission . startup (
2782
- this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ]
2791
+ BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ]
2783
2792
) ;
2784
2793
}
2785
2794
2786
- shutdown ( data , reason ) {
2787
- this . sitepermission . shutdown ( this . BOOTSTRAP_REASON_TO_STRING_MAP [ reason ] ) ;
2795
+ async shutdown ( data , reason ) {
2796
+ this . sitepermission . shutdown ( BootstrapScope . BOOTSTRAP_REASON_MAP [ reason ] ) ;
2788
2797
this . sitepermission = null ;
2789
2798
}
2790
2799
}
@@ -2800,6 +2809,9 @@ let pendingExtensions = new Map();
2800
2809
* @augments ExtensionData
2801
2810
*/
2802
2811
export class Extension extends ExtensionData {
2812
+ /** @type {Map<string, Map<string, any>> } */
2813
+ persistentListeners ;
2814
+
2803
2815
constructor ( addonData , startupReason , updateReason ) {
2804
2816
super ( addonData . resourceURI , addonData . isPrivileged ) ;
2805
2817
@@ -2832,6 +2844,7 @@ export class Extension extends ExtensionData {
2832
2844
this . startupData = addonData . startupData || { } ;
2833
2845
this . startupReason = startupReason ;
2834
2846
this . updateReason = updateReason ;
2847
+ this . temporarilyInstalled = ! ! addonData . temporarilyInstalled ;
2835
2848
2836
2849
if (
2837
2850
updateReason ||
@@ -3077,10 +3090,6 @@ export class Extension extends ExtensionData {
3077
3090
return [ this . id , this . version , Services . locale . appLocaleAsBCP47 ] ;
3078
3091
}
3079
3092
3080
- get temporarilyInstalled ( ) {
3081
- return ! ! this . addonData . temporarilyInstalled ;
3082
- }
3083
-
3084
3093
saveStartupData ( ) {
3085
3094
if ( this . dontSaveStartupData ) {
3086
3095
return ;
0 commit comments