Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Share global data in Firefox through javascript implemented XPCOM
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lei Sun  
View profile  
 More options Jun 25 2007, 12:04 am
Newsgroups: mozilla.dev.extensions
From: "Lei Sun" <lei....@gmail.com>
Date: Sun, 24 Jun 2007 21:04:09 -0700
Local: Mon, Jun 25 2007 12:04 am
Subject: Share global data in Firefox through javascript implemented XPCOM
Hi Guys,

I know there are docs and posts about this topic, and I have tried to
make them work, but I kept on getting exceptions like (Service
Manager::GetSerice returned failure code....)

I followed
* http://developer.mozilla.org/en/docs/Working_with_windows_in_chrome_c...
* http://groups.google.com/group/mozilla.dev.extensions/browse_thread/t...
* http://ted.mielczarek.org/code/mozilla/jscomponentwiz/

I was able to create an xpcom component alright, but I would like to
have it have a custom interface that defines get(namespace, data),
set(namespace, data).

After reading "passing/getting data from/to custom xpcom service", I
got confused and stuck on:
1. Do I still need to create an IDL, and compile it into xpt?  (I think~ I need)
2. If so, since I might be passing complex js objects into the XPCOM
to store, what variable type should I define? (Since I didn't see any
type for js objects, void?)
3. Should I do
    var myService =  Components.classes["@my.com/myService;1"]
         .getService(Components.interfaces.nsISupports);
  or
      var myService =  Components.classes["@my.com/myService;1"]
         .getService();
Well, both of them are giving me the same errors. (I am on firefox
2.0.0.4 ubuntu)

Can someone please show me some working code or examples of how to
store and retrieve js objects from XPCOM component?

Thanks you so much!

Lei


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed  
View profile  
 More options Jun 25 2007, 7:12 am
Newsgroups: mozilla.dev.extensions
From: Ed <e...@siliconforks.com>
Date: Mon, 25 Jun 2007 06:12:39 -0500
Local: Mon, Jun 25 2007 7:12 am
Subject: Re: Share global data in Firefox through javascript implemented XPCOM

Lei Sun wrote:
> 1. Do I still need to create an IDL, and compile it into xpt?  (I think~
> I need)
> 2. If so, since I might be passing complex js objects into the XPCOM
> to store, what variable type should I define? (Since I didn't see any
> type for js objects, void?)

You don't need IDL.  You will have to use the wrappedJSObject trick, though.

> 3. Should I do
>    var myService =  Components.classes["@my.com/myService;1"]
>         .getService(Components.interfaces.nsISupports);
>  or
>      var myService =  Components.classes["@my.com/myService;1"]
>         .getService();

Either one should work.

> Well, both of them are giving me the same errors. (I am on firefox
> 2.0.0.4 ubuntu)

You could try shutting down firefox and deleting compreg.dat and
xpti.dat as described here:

http://developer.mozilla.org/en/docs/How_to_Build_an_XPCOM_Component_...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nickolay Ponomarev  
View profile  
 More options Jun 25 2007, 7:55 am
Newsgroups: mozilla.dev.extensions
From: "Nickolay Ponomarev" <asquee...@gmail.com>
Date: Mon, 25 Jun 2007 15:55:28 +0400
Local: Mon, Jun 25 2007 7:55 am
Subject: Re: Share global data in Firefox through javascript implemented XPCOM
On 6/25/07, Lei Sun <lei....@gmail.com> wrote:
> 3. Should I do
>     var myService =  Components.classes["@my.com/myService;1"]
>          .getService(Components.interfaces.nsISupports);
>   or
>       var myService =  Components.classes["@my.com/myService;1"]
>          .getService();
> Well, both of them are giving me the same errors. (I am on firefox
> 2.0.0.4 ubuntu)

It doesn't matter - if you get an error here, your component did not
get registered. Have you read
http://developer.mozilla.org/en/docs/Troubleshooting_XPCOM_components...
?

Nickolay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lei Sun  
View profile  
 More options Jun 25 2007, 12:14 pm
Newsgroups: mozilla.dev.extensions
From: "Lei Sun" <lei....@gmail.com>
Date: Mon, 25 Jun 2007 09:14:13 -0700
Local: Mon, Jun 25 2007 12:14 pm
Subject: Re: Share global data in Firefox through javascript implemented XPCOM
Hi All,

It worked after I removed the compreg.dat and xpti.dat in the profile
dir, and restarted the application.

Then my follow up question is:

Say, we are using reference to refer to this component. Are we able to
alter this component's inner implementations? (Please see the code
below)

in component's code:
function Test() {
  // you can cheat and use this
  // while testing without
  // writing your own interface
  this.wrappedJSObject = this;

}

// This is the implementation of your component.
Test.prototype = {
  // for nsISupports
  QueryInterface: function(aIID)
  {
    // add any other interfaces you support here
    if (!aIID.equals(nsISupports))
        throw Components.results.NS_ERROR_NO_INTERFACE;
    return this;
  },

  hello: function() {
    return {a: 'hello'};
  }

}

in calling code:
var s =  Components.classes["@my.com/myService;1"]
        .getService().wrappedJSObject;
s.hello = function() {
  // do something really bad, like stealing people's passwords... //
--- evil implementation

}

So if I do a

var s =  Components.classes["@my.com/myService;1"]
        .getService().wrappedJSObject;

again, Would that still have the evil implementation from the last
block of code? If so, How long will it last? Until the next
application restart? And how do I protect the component from being
evil used like this?

Lei

On 6/25/07, Nickolay Ponomarev <asquee...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nickolay Ponomarev  
View profile  
 More options Jun 25 2007, 3:01 pm
Newsgroups: mozilla.dev.extensions
From: "Nickolay Ponomarev" <asquee...@gmail.com>
Date: Mon, 25 Jun 2007 23:01:27 +0400
Local: Mon, Jun 25 2007 3:01 pm
Subject: Re: Share global data in Firefox through javascript implemented XPCOM
On 6/25/07, Lei Sun <lei....@gmail.com> wrote:

Yes.

> If so, How long will it last? Until the next
> application restart?

Yes.

> And how do I protect the component from being
> evil used like this?

By avoiding the wrappedJSObject thing and exposing your component's
functionality via IDL interfaces instead.

Nickolay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eric.j...@yahoo.com  
View profile  
 More options Jun 25 2007, 4:22 pm
Newsgroups: mozilla.dev.extensions
From: eric.j...@yahoo.com
Date: Mon, 25 Jun 2007 13:22:09 -0700 (PDT)
Local: Mon, Jun 25 2007 4:22 pm
Subject: Re: Share global data in Firefox through javascript implemented XPCOM
I think it's important to point out that the attack Lei describes can only be achieve from other privileged code; i.e., user-installed code, not arbitrary web sites. A user would have to install code specifically targeted at the custom XPCOM service in question.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lei Sun  
View profile  
 More options Jun 25 2007, 8:46 pm
Newsgroups: mozilla.dev.extensions
From: "Lei Sun" <lei....@gmail.com>
Date: Mon, 25 Jun 2007 17:46:14 -0700
Local: Mon, Jun 25 2007 8:46 pm
Subject: Re: Share global data in Firefox through javascript implemented XPCOM
Hi Nickolay,

Hum... In that case, from the reference
http://developer.mozilla.org/en/docs/XPIDL:Syntax

what type should I declare in IDL? void?

Lei


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lei Sun  
View profile  
 More options Jun 26 2007, 1:53 am
Newsgroups: mozilla.dev.extensions
From: "Lei Sun" <lei....@gmail.com>
Date: Mon, 25 Jun 2007 22:53:12 -0700
Local: Tues, Jun 26 2007 1:53 am
Subject: Re: Share global data in Firefox through javascript implemented XPCOM
Hi Nick,

I tried to define void, but it didn't work.

Hi Eric,

The intension for this extension is actually to make user to install
local script easier? and I am trying to figure out a way, so that they
won't be stepping on each other, and I can have a guaranteed way to
get all of them fresh without restarting firefox.

Lei

On 6/25/07, Lei Sun <lei....@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eric.j...@yahoo.com  
View profile  
 More options Jun 26 2007, 7:24 am
Newsgroups: mozilla.dev.extensions
From: eric.j...@yahoo.com
Date: Tue, 26 Jun 2007 04:24:48 -0700 (PDT)
Local: Tues, Jun 26 2007 7:24 am
Subject: Re: Share global data in Firefox through javascript implemented XPCOM
You might consider loading the local scripts with nsIScriptLoader since this creates a unique, separated namespace where variables and functions cannot step on each other.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neil  
View profile  
 More options Jul 4 2007, 11:03 am
Newsgroups: mozilla.dev.extensions
From: Neil <n...@parkwaycc.co.uk>
Date: Wed, 04 Jul 2007 16:03:52 +0100
Local: Wed, Jul 4 2007 11:03 am
Subject: Re: Share global data in Firefox through javascript implemented XPCOM

Lei Sun wrote:
> 2. If so, since I might be passing complex js objects into the XPCOM
> to store, what variable type should I define?

You can't really do this, because the Object prototype for your custom
js objects is defined on your current window, which will go away when
the window is closed. If your objects have a consistent interface then
you can of course create them in your XPCOM component and retrieve them
from your UI code.

--
Warning: May contain traces of nuts.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »