Message passing is intended for communication between extensions and their
content scripts. Since you're only using popups and a background page, you
can communicated between them using direct javascript calls. See
http://code.google.com/chrome/extensions/extension.html#method-getBackgroundPage
-
you can call this from your popup and call methods directly on the
background page, eg:
  // popup.html
  chrome.extension.getBackgroundPage().popupClicked("random_test_arg");

  // background.html
  function popupClicked(arg) { ... }

On Wed, Nov 11, 2009 at 1:18 PM, Bartek <[email protected]> wrote:

> Hi there,
>
> I'm playing with Browser actions right now and have a popup.html file
> which contains 2 elements:
>
> - One is a button that will popup a new window using the regular
> window.open command from Javascript.
> - The second is a list of recent entries that my extension will fetch
> from the service it's for.
>
> My biggest issue right now is not fully understanding how background
> pages work with the front end of an extension. I've read the
> documentation and only half-understand the message passing that is to
> be done.
>
> Right now I have code like so in my popup.html file:
> $(document).ready(function() {
>    $("#pin").click(function() {
>        var q;
>        var port = chrome.extension.connect({"name":
> "random_test_arg"});
>
>        window.open(....);
>    });
> });
>
> I understand I need to send a message to my background process to
> collect information I want, but how do I get this back and what's the
> right way to catch/send the info? In background.html I see this works:
>
> chrome.extension.onConnect.addListener(function(port) {
>    var q;
>    chrome.tabs.getSelected(null, function(tab) {
>        console.log(tab);
>        q = tab.url;
>    });
> });
>
> And I get the correct tab object, with a url, but I have no clue how
> to send it back to my front-end function so I can open the window with
> the variables I get in my backend.
>
> Hopefully my question makes sense. I'm very close to getting it, but I
> just want to verify I'm on the right track here! :)
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<chromium-extensions%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=.


Reply via email to