programmatically detect if a tab is pinned

703 views
Skip to first unread message

brillout.com

unread,
Mar 3, 2011, 3:23:46 PM3/3/11
to Chromium Apps
as mentioned in the subject, is there any way to detect with
javascript if a tab is pinned?

thanks!

PhistucK

unread,
Mar 3, 2011, 4:29:30 PM3/3/11
to brillout.com, Chromium Apps
The Tab object which the various tab API methods (getCurrent, for example) return (within the callback) now has a "pinned" property which you can query.

PhistucK

brillout.com

unread,
Mar 3, 2011, 4:34:54 PM3/3/11
to Chromium Apps
thanks PhistucK

the tab object seems to be accessible only for packaged apps, but my
app is an hosted app

what about hosted apps?

greets,

On Mar 3, 10:29 pm, PhistucK <phist...@gmail.com> wrote:
> The Tab object <http://code.google.com/chrome/extensions/tabs.html#type-Tab>
> which
> the various tab API methods
> (getCurrent<http://code.google.com/chrome/extensions/trunk/tabs.html#method-getCu...>,
> for example) return (within the callback) now has a "pinned" property which
> you can query.
>
> ☆*PhistucK*

Arne Roomann-Kurrik

unread,
Mar 3, 2011, 10:42:56 PM3/3/11
to brillout.com, Chromium Apps
Unfortunately hosted apps won't be able to access this information.  You can think of a hosted app as being more like a website in terms of capabilities, and a packaged app as being closer to a Chrome extension.

I'm curious to hear what you'd expect to do with this if it were available.

~Arne

brillout.com

unread,
Mar 10, 2011, 4:22:43 PM3/10/11
to Chromium Apps
@arne:
i wrote a timer app with the countdown written in the tab title and
tab icon.
-if the tab is pinned -> don't change the title when the countdown
changes in order to avoid the blinking -- the tab blinks when the
title changes
-if the tab isn't pinned -> don't change the tab icon when the
countdown changes in order to save CPU ressource -- turns out changing
the tab icon every second needs some CPU + it's kinda ugly to have
redundant information

i know i'm kinda perfectionist ^^

Arne Roomann-Kurrik

unread,
Mar 15, 2011, 1:20:40 PM3/15/11
to brillout.com, Chromium Apps
I see.  Unfortunately I can't think of a workaround which would give you this information.

I'm sure the CPU utilization won't be that large if you're only updating the title every second.  I could see how the blinking might be annoying though - have you considered changing the favicon dynamically to reflect the current countdown time?  Might be a cooler effect: http://softwareas.com/dynamic-favicons

~Arne

brillout.com

unread,
Mar 15, 2011, 1:38:36 PM3/15/11
to Chromium Apps
yeah with "tab icon" i meant "favicon".
i changed the terminology so that non techies would understand :-)

so i'm already changing the favicon and setting the countdown to the
favicon which means: create an image with canvas + set this image as
favicon. And this surprisingly take some CPU resource. you can see it
for yourself: http://www.timer-tab.com
since firefox doesn't have any pinned tabs i disabled the dynamic
favicon for it in order to save some CPU which i would like to make
the same for chromium if the tab isn't pinned.
but it's okay, it's kinda minor :-)

thanks for caring

Ian Ni-Lewis

unread,
Mar 15, 2011, 6:17:53 PM3/15/11
to brillout.com, Chromium Apps
How are you measuring CPU? On my machine this page consumes pretty much no CPU at all.
Ian
--
Ian Ni-Lewis
Developer Advocate
Google Game Developer Relations

Arne Roomann-Kurrik

unread,
Mar 15, 2011, 9:11:27 PM3/15/11
to brillout.com, Chromium Apps
Sorry, I didn't read your original email carefully enough.

I'd be interested in seeing your unobfuscated source if you're willing to make it available - that page takes up 3% on my laptop, which seems pretty high considering the functionality.

In particular, this could be troublesome:

p=window.setInterval(function(){for(var b in o)o[b]()},150)
depending on how many functions you call in that loop, 150ms might be aggressive.

~Arne



On Tue, Mar 15, 2011 at 10:38 AM, brillout.com <rom...@gmail.com> wrote:

brillout.com

unread,
May 6, 2011, 6:14:56 AM5/6/11
to Chromium Apps
Hi Arne, first of all thank you for caring :-)

Ok so i stripped down the code to the relevant code for the favicon
refresh.
the stripped down code: http://dev.timerintab.appspot.com/test/icon

If you change the line
window.changeFavicon(window.getTimerIcon(diff));
to
console.log(window.getTimerIcon(diff));
the CPU usage is near to 0%
so the high amount of CPU usage is caused by changing the favicon
every second

~Romuald

@ian: this is strange since in my case and in the case of Arne the
page takes up 3% of CPU computing, what computer and OS do you have?

Arne Roomann-Kurrik

unread,
May 26, 2011, 4:28:59 PM5/26/11
to brillout.com, Chromium Apps
Hey I finally got around to profiling this, but now I see about 0.7 - 1.0% on Mac Dev Channel.  Do you still see 3%?

~Arne
Reply all
Reply to author
Forward
0 new messages