Bholley,

Thanks for your quick response. Sorry for being naive and I am a newbee in this 
area. After modifying the IDL and jsXPCOM as below, my question now is "How to 
call the injected or page java scripts by using nsIDOMWindow"?

1 - My modified IDL 
               #include "nsISupports.idl"
               [scriptable, uuid(f22e7808-17a7-11e4-9620-58fc1d5d46b0)]
               interface nsIJSSupport: nsISupports
               {
                 boolean doSomething(in nsIDOMWindow gdomwindow, in string 
siteId,in bool  bRescanPage, in bool bIsFF30orGreater);
               }; 
                           
2 - My modified JS file is as follows

              Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

               function MyComponent() { }

               MyComponent.prototype = {
                 classDescription: "Shans Javascript XPCOM Component",
                 classID:          
Components.ID("{17ca79ee-17ae-11e4-a5ea-fa011e5d46b0}"),
                 contractID:       "@Shans.com/jssource;1",
                 QueryInterface: 
XPCOMUtils.generateQI([Components.interfaces.nsIJSSupport,Components.interfaces.nsISupports]),
                 
               doSomething: function(gdomwindow,  siteId, bPage, bIsGreater) { 
                                          
                                             
//win.wrappedJSObject.injectedJSFunctioninWebPage(gdomwindow,  siteId, bPage, 
bIsGreater);
                                                                                
         //How to call the injected or page java scripts by using nsIDOMWindow??
                              }
               }
Thanks for pointing me in right direction.

Shan'




On Wednesday, July 30, 2014 9:36:18 PM UTC+5:30, Bobby Holley wrote:
> On Wed, Jul 30, 2014 at 8:56 AM, Shanmugham Sundaram 
> > wrote:
> 
> 
> 
> > 1 - My IDL is as follows
> 
> >                #include "nsISupports.idl"
> 
> >                [scriptable, uuid(f22e7808-17a7-11e4-9620-58fc1d5d46b0)]
> 
> >                interface nsIJSSupport: nsISupports
> 
> >                {
> 
> >                  boolean doSomething(in string frameId, in string
> 
> > siteId,in bool  bPage, in bool bIsGreater);
> 
> >                };
> 
> >
> 
> >
> 
> > 2 - My JS file is as follows
> 
> >
> 
> >
> 
> > Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
> 
> >
> 
> >                function MyComponent() { }
> 
> >
> 
> >                MyComponent.prototype = {
> 
> >                  classDescription: "Shans Javascript XPCOM Component",
> 
> >                  classID:
> 
> >  Components.ID("{17ca79ee-17ae-11e4-a5ea-fa011e5d46b0}"),
> 
> >                  contractID:       "@Shans.com/jssource;1",
> 
> >                  QueryInterface:
> 
> > XPCOMUtils.generateQI([Components.interfaces.nsIJSSupport,Components.interfaces.nsISupports]),
> 
> >
> 
> >                doSomething: function(frameId,  siteId, bPage, bIsGreater) {
> 
> >                                              //Get the proper window and
> 
> > get the call to sb_MyComponent
> 
> >                                              //assuming the following will
> 
> > call the "sb_MyComponent"
> 
> >
> 
> >  win.wrappedJSObject.injectedFunctioninWebPage(frameId,  siteId, bPage,
> 
> > bIsGreater);
> 
> >                               }
> 
> >                }
> 
> >
> 
> >                var components = [MyComponent];
> 
> >
> 
> >                if ("generateNSGetFactory" in XPCOMUtils)
> 
> >                  var NSGetFactory =
> 
> > XPCOMUtils.generateNSGetFactory(components);
> 
> >                else
> 
> >                  var NSGetModule =
> 
> > XPCOMUtils.generateNSGetModule(components);
> 
> >
> 
> >
> 
> >
> 
> > 3 - My C++ XP-COM code (skeleton) to make JS-XPCOM call as below :
> 
> >
> 
> >                nsresult rv;
> 
> >                nsCOMPtr<nsIDOMWindow> aDOMWindow( do_GetInterface(
> 
> > aWebProgress, &rv ) );
> 
> >                nsCOMPtr< nsPIDOMWindow > privateWindow( do_QueryInterface(
> 
> > aDOMWindow, &rv ) );
> 
> >                nsCOMPtr< nsIDocShell > docShell =
> 
> > privateWindow->GetDocShell();
> 
> >                                 nsCOMPtr<nsIJSSupport> iJSSupport =
> 
> > do_CreateInstance("@Shans.com/jssource;1",&rv);
> 
> >                if(NS_SUCCEEDED(rv) && iJSSupport)
> 
> >                  {
> 
> >                           iJSSupport-> doSomething (frameId,  siteId,
> 
> > bPage, bIsGreater)
> 
> >                                 }
> 
> >
> 
> >
> 
> > Is it possible to call the "injectedFunctioninWebPage()" by using
> 
> > win.wrappedJSObject ? If not, how to call the JS functions  in the page by
> 
> > using JS-XPCOM?
> 
> >
> 
> 
> 
> Yes. You might consider passing aDOMWindow directly through the IDL since
> 
> you already have it in C++, rather than using the frameId.
> 
> 
> 
> bholley
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to