e10s - 我想从nsIObserver-nsIHttpChannel-nsIDOMWindow-nsIDOMDocument获取。我该怎么做?

时间:2015-10-06 05:03:02

标签: e10s


我的插件在FF41上工作。现在我想在e10s上迁移。使用Firefox开发人员版v43
示例观察者(c ++)。

NS_IMETHODIMP CFFObserver::Observe( nsISupports* aSubject, const char* aTopic, const char16_t* aData ) 
{ ......... 
    if ( lstrcmpA( aTopic, "http-on-modify-request" ) == 0 ) 
    { 
        CFFObserver::onSending( aSubject ); 
    } ..........    
} 
void CFFObserver::onSending( nsISupports* IHttpChannel ) 
{ 
.............. 
    nsISupports* IDOMWindowOwner = m_gate.Channel_GetOwnerWindow( IHttpChannel ); 
................. 
}


示例JS助手。

Channel_GetOwnerWindow:

function( objChannel ) // This option does not worked in v43[e10s]; <br>
{ 
    try 
    { 
        var notificationCallbacks = objChannel.QueryInterface(Components.interfaces.nsIHttpChannel).notificationCallbacks; 
        if ( !notificationCallbacks ) 
        { 
            var loadGroup = objChannel.QueryInterface(Components.interfaces.nsIRequest).loadGroup.notificationCallbacks; 
            if ( loadGroup ) notificationCallbacks = loadGroup.notificationCallbacks; 
        } 
        if ( notificationCallbacks ) 
        { 
            return notificationCallbacks.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                                                                    .getInterface(Components.interfaces.nsIDOMWindow) 
                                                                    .QueryInterface(Components.interfaces.nsISupports); 
        } 
    } 
    catch ( err ) 
    { 
        this.ErrorOut( err ); 
    }   
    return null;
}

下面的代码有效,但我无法从获取nsIDOMWindow获取文档。

...... 
objWindow.QueryInterface(Components.interfaces.nsIDOMWindow).document.QueryInterface(Components.interfaces.nsISupports) 

是错误 - 没有界面....


Channel_GetOwnerWindow:

function( objChannel ) 
{   
    try 
    { 
        return objChannel.QueryInterface(Components.interfaces.nsIHttpChannel) 
                                            .notificationCallbacks 
                                            .getInterface(Components.interfaces.nsILoadContext)
                                            .topFrameElement 
                                            .QueryInterface(Components.interfaces.nsISupports); 
    } 
    catch ( err ) 
    { 
        this.ErrorOut( err ); 
    }   
    return null; 
}


帮帮我解决这个问题。感谢。

1 个答案:

答案 0 :(得分:0)

解决!

var browser = objChannel.QueryInterface(Components.interfaces.nsIHttpChannel)
    .notificationCallbacks
    .getInterface(Components.interfaces.nsILoadContext).topFrameElement;

var window = browser.contentWindow.QueryInterface(Components.interfaces.nsISupports);