0

I'm creating an extension where I'd like to be able to figure out whether Chrome (as an application) has the user's focus, i.e. is it not minimized or in the background?

I believe there are javascript functions that check if a tab has focus, would injecting that code into every tab and seeing if any of the tabs return false work? That sounds like terrible peformance though, maybe just inject it into the "active" window using chrome.tabs.onUpdated?

Or would this be do-able relatively easily using NPAPI? Would it require different code for different OSes?

Thanks!

Community
  • 1
  • 1
Thariq Shihipar
  • 1,072
  • 1
  • 12
  • 27
  • 2
    NPAPI would require different for code for different OS'es and you wouldn't be able to tell if the settings tab or the new tab pages where currently active, with the other approach. – Tyilo May 12 '12 at 01:11
  • I'm overriding the newtab, so I can be aware of that, but you're right there are other chrome-specific pages you can't inject into. Perhaps chrome.tabs.onUpdated can be used to figure out if you're on a page like that and then just assume you have focus (or don't have focus, depending on what's the better default setting). I figured NPAPI would need different code for different OS'es, do you know if there's any sample code out there that has done this? Or the relative complexity of doing it from scratch? – Thariq Shihipar May 12 '12 at 01:25
  • 1
    realize that NPAPI itself doesn't have any way to connect with the browser at least in Mac OS, so you'd really be running system APIs to try to find chrome, etc. It would be a very messy solution, and I don't know of anyone who has attempted it. – taxilian May 12 '12 at 02:57

0 Answers0