4

I've developed a little chrome extension for personal needs. But there's something in the user experience I don't like, the pop-up containing the application automatically closes when it loses the focus.

I would like to control the closing behaviour and/or create an always on top popup, I've tried to find my way on Google, Chrome dev forums and API ref but can't find a way to accomplish that.

Xan
  • 74,770
  • 16
  • 179
  • 206
Emmanuel Istace
  • 1,209
  • 2
  • 14
  • 32
  • Please show the relevant code snippets or links from your existing research. You've downvoted Chris' answer below with the comment "Already tested-it, it's not working." However, there's nothing in the question that suggests that you've tried it. So explain what you mean by "it did not work". What did you expect, what happened instead? – Rob W Jan 27 '14 at 18:45

2 Answers2

5

Look at this article: http://www.chromium.org/developers/design-documents/extensions/proposed-changes/apis-under-development/panels

Enable using panels here: chrome://flags/#enable-panels

Here is the code I use to create a panel:

let window_id;
chrome.browserAction.onClicked.addListener(()=>{
  if(window_id === undefined){
    chrome.windows.create(
      {url:'panel.html', type:'panel', focused:true, width:150, height:162}
      ,_=>window_id = _.id
    );
  }else{
    chrome.windows.update(window_id, {focused:true});
  }
  chrome.windows.onRemoved.addListener(_=>_ === window_id? window_id = undefined:3);
});
Pacerier
  • 86,231
  • 106
  • 366
  • 634
Daniel Herr
  • 19,083
  • 6
  • 44
  • 61
  • Good solution, as far as **extensions for private needs** go. Too bad it's not yet stable. – Xan May 20 '14 at 15:51
  • @Daniel, A better way is to avoid the overhead of the onremoved listener. Simply create a new window on browseraction if you cant find a window with that existing id. – Pacerier Aug 07 '17 at 16:05
  • @Xan, Daniel. But in any case, this doesn't work: It's not a floating always-on-top window. – Pacerier Aug 07 '17 at 16:05
1

Apparently you need to set the type to 'panel', and I can't tell whether this is possible or not at the moment. From what I gather, you can set type to panel, but you'll need to set the key-value pair in the manifest.json to the one used by GTalk(Hangouts) which will stop you being able to use the GTalk/Hangouts panel.

There's a bit more of an explanation here: Having panel behavior in chrome extension

Community
  • 1
  • 1
Chris
  • 572
  • 4
  • 13
  • That appears to be the only way anyone has made it work so far, I did say I wasn't sure if it'd work for you or not. I think until Google roll panels out to the masses (if they do), it's unlikely to be possible. My answer might not have been the one you were hoping for, but a 'not useful' mark down isn't really going to change that. – Chris Jan 27 '14 at 16:29
  • The -1 is not because it didn't work, it's because it's an answer based on assumption. I'm sorry but I'm asking someone who know how, not someone who will search like me on google and SO, I've already done these searches, that's why I'm asking here. So you don't know how, you've neer tested, you're not sure if it's possible, you're not sure if that's impossible... Sorry, but for all these reasons, -1. (And I got -1 for less than that on SE-ElecEngen, don't take it so harsh ;) ) – Emmanuel Istace Jan 27 '14 at 16:40
  • I have tried it myself, I was previously in a similar situation to you. That's the only success I've ever heard of in my attempt to make it work, it worked for a few other people but not for me. Whatever, best of luck finding a fix. – Chris Jan 27 '14 at 16:44
  • That' because it's a 2 years old answer and google chrome evolve. A solution might be to use a PageAction re-triggering the popup but not sure about the impact on the navigation. – Emmanuel Istace Jan 27 '14 at 16:48