@@ -283,44 +283,42 @@ HTTPSEverywhere.prototype = {
283283 getExpando : function ( browser , key ) {
284284 let obj = this . expandoMap . get ( browser ) ;
285285 if ( ! obj ) {
286- dump ( new Error ( ) . stack ) ;
287- this . log ( INFO , "No expando for " + browser ) ;
288- return null ;
286+ this . log ( WARN , "No expando for " + browser . currentURI ) ;
287+ return null ;
289288 }
290289 return obj [ key ] ;
291290 } ,
292291
293292 setExpando : function ( browser , key , value ) {
294- dump ( "SET EXPANDO\n" ) ;
295- dump ( new Error ( ) . stack ) ;
293+ this . log ( WARN , "setting expandomap value: " + value ) ;
296294 if ( ! this . expandoMap . has ( browser ) ) {
297295 this . expandoMap . set ( browser , { } ) ;
298296 }
299297 let obj = this . expandoMap . get ( browser ) ;
300298 obj [ key ] = value ;
301299 } ,
302300
301+ // XXX: This never fires in e10s
303302 onStateChange : function ( wp , req , flags , status ) {
304303 if ( ( flags & CI . nsIWebProgressListener . STATE_START ) &&
305304 ( flags & CI . nsIWebProgressListener . STATE_IS_DOCUMENT ) &&
306305 wp . isTopLevel ) {
307- dump ( "\nDOC START\n\n" ) ;
308306 let channel = req . QueryInterface ( CI . nsIChannel ) ;
309307 let browser = this . getBrowserForChannel ( channel ) ;
310308 if ( ! browser ) {
311- this . log ( WARN , "Unable to get <browser>" ) ;
309+ this . log ( WARN , "Unable to get <browser> for " + channel . URI . spec ) ;
312310 return ;
313311 }
314- dump ( "ON LOCATION $$$$$$$$$$\n" ) ;
315- if ( ! this . newApplicableListForBrowser ( browser ) )
316- this . log ( WARN , "Something went wrong in onLocationChange" ) ;
312+ dump ( "In on location change\n" ) ;
313+ this . newApplicableListForBrowser ( browser ) ;
317314 }
318315 } ,
319- /*
316+
320317 // We use onLocationChange to make a fresh list of rulesets that could have
321318 // applied to the content in the current page (the "applicable list" is used
322319 // for the context menu in the UI). This will be appended to as various
323320 // content is embedded / requested by JavaScript.
321+ // XXX: This never fires in e10s
324322 onLocationChange : function ( wp , req , uri ) {
325323 if ( wp instanceof CI . nsIWebProgress ) {
326324 let location = uri . spec ;
@@ -337,52 +335,45 @@ HTTPSEverywhere.prototype = {
337335 return ;
338336 }
339337 dump ( "ON LOCATION $$$$$$$$$$\n" ) ;
340- if (!this.newApplicableListForBrowser(browser))
338+ if ( ! this . newApplicableListForBrowser ( browser ) )
341339 this . log ( WARN , "Something went wrong in onLocationChange" ) ;
342340 } else {
343341 this . log ( WARN , "onLocationChange: no nsIWebProgress" ) ;
344342 }
345343 } ,
346- */
344+
347345 getBrowserForChannel : function ( channel ) {
348- // Obtain an nsIDOMWindow from a channel
349- let nc ;
350- try {
351- nc = channel . notificationCallbacks ?
352- channel . notificationCallbacks :
353- channel . loadGroup . notificationCallbacks ;
354- } catch ( e ) {
355- this . log ( WARN , "no loadgroup notificationCallbacks for " + channel . URI . spec ) ;
356- return null ;
357- }
358- if ( ! nc ) {
359- return null ;
360- }
346+ // Obtain a browser element from a channel
347+ let loadContext ;
361348 try {
362- var loadContext = nc . getInterface ( CI . nsILoadContext ) ;
363- dump ( "loadContext = " + loadContext + "\n" ) ;
364- let domWin = loadContext . associatedWindow ;
365- var browser = gBrowser . getBrowserForDocument ( domWin . top . document ) ;
349+ loadContext = channel . notificationCallbacks . getInterface ( CI . nsILoadContext ) ;
366350 } catch ( e ) {
367- this . log ( INFO , "No <browser> element associated with request: " + channel . URI . spec ) ;
368- return null ;
351+ try {
352+ loadContext = channel . loadGroup . notificationCallbacks
353+ . getInterface ( CI . nsILoadContext ) ;
354+ } catch ( e ) {
355+ this . log ( INFO , "no loadgroup notificationCallbacks for "
356+ + channel . URI . spec + e ) ;
357+ return null ;
358+ }
369359 }
370- if ( ! browser ) {
371- this . log ( NOTE , "failed to get <browser> for " + channel . URI . spec ) ;
360+ if ( ! loadContext ) {
361+ this . log ( WARN , "No loadContext for: " + channel . URI . spec ) ;
372362 return null ;
373363 }
364+ let browser = loadContext . topFrameElement ;
374365 return browser ;
375366 } ,
376367
377368 // the lists get made when the urlbar is loading something new, but they
378369 // need to be appended to with reference only to the channel
379370 getApplicableListForChannel : function ( channel ) {
380371 var browser = this . getBrowserForChannel ( channel ) ;
381- return this . getApplicableListForBrowser ( browser , "on-modify-request w " + browser ) ;
372+ return this . getApplicableListForBrowser ( browser ) ;
382373 } ,
383374
384375 newApplicableListForBrowser : function ( browser ) {
385- if ( ! browser || ! ( browser instanceof CI . nsIContent ) ) {
376+ if ( ! browser ) {
386377 this . log ( WARN , "Get alist without browser" ) ;
387378 return null ;
388379 }
@@ -391,16 +382,15 @@ HTTPSEverywhere.prototype = {
391382 return alist ;
392383 } ,
393384
394- getApplicableListForBrowser : function ( browser , where ) {
395- if ( ! browser || ! ( browser instanceof CI . nsIContent ) ) {
385+ getApplicableListForBrowser : function ( browser ) {
386+ if ( ! browser ) {
387+ //this.log(WARN, "Get alist without browser");
396388 return null ;
397389 }
398390 var alist = this . getExpando ( browser , "applicable_rules" ) ;
399391 if ( alist ) {
400- //this.log(DBUG,"get AL success in " + where);
401392 return alist ;
402393 } else {
403- //this.log(DBUG, "Making new AL in getApplicableListForBrowser in " + where);
404394 alist = new ApplicableList ( this . log , browser ) ;
405395 this . setExpando ( browser , "applicable_rules" , alist ) ;
406396 }
0 commit comments