@@ -6,69 +6,79 @@ const Cr = Components.results;
6
6
7
7
Components . utils . import ( "resource://gre/modules/Services.jsm" ) ;
8
8
9
- const gPrefService = Cc [ "@mozilla.org/preferences-service;1" ] . getService ( Ci . nsIPrefService ) ;
10
- const gPrefBranch = gPrefService . getBranch ( null ) . QueryInterface ( Ci . nsIPrefBranch2 ) ;
11
9
const idleService = Cc [ "@mozilla.org/widget/idleservice;1" ] . getService ( Ci . nsIIdleService )
12
10
13
11
var timeout = 0 ;
14
12
15
13
var idleObserver = {
16
- observe : function ( subject , topic , data ) {
17
- idleService . removeIdleObserver ( idleObserver , timeout ) ;
18
- var nsIAppStartup = Cc [ "@mozilla.org/toolkit/app-startup;1" ] . getService ( Ci . nsIAppStartup ) ;
19
- nsIAppStartup . quit ( nsIAppStartup . eForceQuit ) ;
20
- }
14
+ observe : function ( subject , topic , data ) {
15
+ idleService . removeIdleObserver ( idleObserver , timeout ) ;
16
+ Services . startup . quit ( Services . startup . eForceQuit ) ;
17
+ }
21
18
} ;
22
19
20
+ var gProxyUsername = null ;
21
+ var gProxyPassword = null ;
22
+ var gForceSafeSearch = false ;
23
23
24
24
try {
25
- timeout = gPrefBranch . getIntPref ( "extensions.webconverger.kioskresetstation" ) ;
26
- if ( timeout > 0 ) {
27
- idleService . addIdleObserver ( idleObserver , timeout ) ; // timeout is in minutes
28
- }
25
+ timeout = Services . prefs . getIntPref ( "extensions.webconverger.kioskresetstation" ) ;
26
+ if ( timeout > 0 ) {
27
+ idleService . addIdleObserver ( idleObserver , timeout ) ; // timeout is in minutes
28
+ }
29
29
} catch ( ex ) { }
30
30
31
31
var HTTPObserver = {
32
- observe : function observe ( subject , topic , data ) {
33
- switch ( topic ) {
34
- case "http-on-modify-request" :
35
- var httpChannel = subject . QueryInterface ( Ci . nsIHttpChannel ) ;
36
- if ( / .* \. g o o g l e \. .* / . test ( httpChannel . URI . host ) ) {
37
- if ( / ^ ( \/ c u s t o m | \/ s e a r c h | \/ i m a g e s \/ c o m p l e t e ) / . test ( httpChannel . URI . path ) ) {
38
- if ( httpChannel . URI . spec . indexOf ( "safe=strict" ) == - 1 ) {
39
- httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&safe=strict" , null , null ) ) ;
40
- }
41
- }
42
- return ;
43
- }
44
- if ( / .* \. y a h o o \. c o m / . test ( httpChannel . URI . host ) ) {
45
- if ( / ^ ( \/ s e a r c h ) / . test ( httpChannel . URI . path ) ) {
46
- if ( httpChannel . URI . spec . indexOf ( "vm=r" ) == - 1 ) {
47
- httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&vm=r" , null , null ) ) ;
48
- }
49
- }
50
- return ;
51
- }
52
- if ( / .* \. b i n g \. c o m / . test ( httpChannel . URI . host ) ) {
53
- if ( / ^ ( \/ s e a r c h | \/ v i d e o s | \/ i m a g e s | \/ n e w s ) / . test ( httpChannel . URI . path ) ) {
54
- if ( httpChannel . URI . spec . indexOf ( "adlt=strict" ) == - 1 ) {
55
- httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&adlt=strict" , null , null ) ) ;
56
- }
57
- }
58
- return ;
59
- }
60
- if ( httpChannel . URI . host == "duckduckgo.com" ) {
61
- if ( httpChannel . URI . spec . indexOf ( "kp=1" ) == - 1 ) {
62
- httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&kp=1" , null , null ) ) ;
63
- }
64
- return ;
65
- }
66
- }
67
- }
32
+ observe : function observe ( subject , topic , data ) {
33
+ switch ( topic ) {
34
+ case "http-on-modify-request" :
35
+ var httpChannel = subject . QueryInterface ( Ci . nsIHttpChannel ) ;
36
+ if ( gProxyUsername && gProxyPassword ) {
37
+ httpChannel . setRequestHeader ( "Proxy-Authorization" , "Basic " + btoa ( gProxyUsername + ":" + gProxyPassword ) , false ) ;
38
+ }
39
+ if ( ! gForceSafeSearch ) {
40
+ return ;
41
+ }
42
+ if ( / .* \. g o o g l e \. .* / . test ( httpChannel . URI . host ) ) {
43
+ if ( / ^ ( \/ c u s t o m | \/ s e a r c h | \/ i m a g e s \/ c o m p l e t e ) / . test ( httpChannel . URI . path ) ) {
44
+ if ( httpChannel . URI . spec . indexOf ( "safe=strict" ) == - 1 ) {
45
+ httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&safe=strict" , null , null ) ) ;
46
+ }
47
+ }
48
+ return ;
49
+ }
50
+ if ( / .* \. y a h o o \. c o m / . test ( httpChannel . URI . host ) ) {
51
+ if ( / ^ ( \/ s e a r c h ) / . test ( httpChannel . URI . path ) ) {
52
+ if ( httpChannel . URI . spec . indexOf ( "vm=r" ) == - 1 ) {
53
+ httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&vm=r" , null , null ) ) ;
54
+ }
55
+ }
56
+ return ;
57
+ }
58
+ if ( / .* \. b i n g \. c o m / . test ( httpChannel . URI . host ) ) {
59
+ if ( / ^ ( \/ s e a r c h | \/ v i d e o s | \/ i m a g e s | \/ n e w s ) / . test ( httpChannel . URI . path ) ) {
60
+ if ( httpChannel . URI . spec . indexOf ( "adlt=strict" ) == - 1 ) {
61
+ httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&adlt=strict" , null , null ) ) ;
62
+ }
63
+ }
64
+ return ;
65
+ }
66
+ if ( httpChannel . URI . host == "duckduckgo.com" ) {
67
+ if ( httpChannel . URI . spec . indexOf ( "kp=1" ) == - 1 ) {
68
+ httpChannel . redirectTo ( Services . io . newURI ( httpChannel . URI . spec + "&kp=1" , null , null ) ) ;
69
+ }
70
+ return ;
71
+ }
72
+ }
73
+ }
68
74
}
69
75
70
76
try {
71
- if ( gPrefBranch . getBoolPref ( "extensions.webconverger.forcesafesearch" ) ) {
72
- Services . obs . addObserver ( HTTPObserver , "http-on-modify-request" , false ) ;
73
- }
77
+ gProxyUsername = Services . prefs . getCharPref ( "extensions.webconverger.proxyusername" ) ;
78
+ gProxyPassword = Services . prefs . getCharPref ( "extensions.webconverger.proxypassword" ) ;
79
+ } catch ( e ) { }
80
+ try {
81
+ gForceSafeSearch = Services . prefs . getBoolPref ( "extensions.webconverger.forcesafesearch" ) ;
74
82
} catch ( ex ) { }
83
+
84
+ Services . obs . addObserver ( HTTPObserver , "http-on-modify-request" , false ) ;
0 commit comments