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
Trying to fully understand background pages.
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
  2 messages - Collapse 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
 
Bartek  
View profile  
 More options Nov 11 2009, 4:18 pm
From: Bartek <bart.ci...@gmail.com>
Date: Wed, 11 Nov 2009 13:18:49 -0800 (PST)
Local: Wed, Nov 11 2009 4:18 pm
Subject: Trying to fully understand background pages.
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 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.
Matt Perry  
View profile  
 More options Nov 11 2009, 4:51 pm
From: Matt Perry <mpcompl...@chromium.org>
Date: Wed, 11 Nov 2009 13:51:01 -0800
Local: Wed, Nov 11 2009 4:51 pm
Subject: Re: [chromium-extensions] Trying to fully understand background pages.

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-getBac...
-
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) { ... }


 
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 »