开发者

How to make use of c++ xpcom component from javascript xpcom component

I have developed a xpcom component using c++. I have GetHWND() me开发者_StackOverflowthod in my component. I have also developed another xpcom component using javascript. I want to make use of GetHWND function in javascript xpcom component. I am using following code to do so.

netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

var myComponent = Components.classes['@dougt/WebLock'].createInstance(Components.interfaces.IWebLock);

myComponent = myComponent.QueryInterface(Components.interfaces.IWebLock);

var res = myComponent.GetHWND(mainWindow.content.document);

But it is giving error as "ReferenceError: netscape is not defined". I did google search but did not find the solution to it.

I am using Mozilla Firefox and I want it to get worked for the same.

Please help me to come out of this problem. Thanks in advance.


You don't need these:

netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");


I agree with Nickolay, when your extension code is executed it has chrome privileges, which allow you to access XPCOM layer and components.

What I would like to see is if it will work with the lines Nikolay mentioned out. And second item >> how your interface of C++ component is defined. XPIDL doesn't aware of HWND type, so you have to provide some different type, or you can use native type but it's not supported by [scriptable] interfaces

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜