Reputation: 29597
I have a chrome extension. When the user clicks the icon I want to:
Check if the user is logged in. This uses google storage (I've got this code already).
If user is logged in, there should NOT be a popup.
If user is not logged in, show browser action pop-up with login post/ajax form.
Google says "If a browser action has a popup, the popup appears when the user clicks the icon." https://developer.chrome.com/extensions/browserAction.html
So I guess not? I could instead add a form to the page DOM, but I'd rather not do that. Any other nice solutions?
Upvotes: 4
Views: 2812
Reputation: 115990
Use chrome.browserAction.setPopup({ popup: ''})
to remove the popup.
From the browserAction.setPopup
docs:
Sets the html document to be opened as a popup when the user clicks on the browser action's icon...
popup ( string ): If set to the empty string (
''
), no popup is shown.
You can use chrome.browserAction.setPopup
to specify a popup page to show, or no popup at all. However, you must specify the popup before the user clicks the browser action; I don't believe you can change it "just in time" as the user clicks. You should simply start with the popup active by default, and then turn it off once the user has successfully logged in.
Upvotes: 5