Hello,
I'm writing a plugin to shorten URLs. In fact, I've already written and published it. But, it has one bug that I'm fighting and need some help with this issue.
The plugin is working great except for one issue with tabs and the current URL in the Omnibox. Let me explain how the plugin works.
I have an icon sitting in the Omnibox (Page action) that acts on specific URL types (hence the need to hide and show it at specific times) rather than using a Browser action.
So, the plugin works when acting on an individual tab. But, when switching tabs, I use chrome.tabs.getSelected() to determine the currently selected tab so I can grab the focused tab.url. For some reason, Chrome seems to either cache or not immediately return the current tab's Omnibox URL after a tab switch. So, after switching tabs and I click my icon once, I get the previous tab's URL. If I close my tool and click the icon a second time, it then pulls in the currently focused and correct tab's URL.
This appears to be some kind of synchronization problem when switching between tabs.
For example, I'm using:
chrome.pageAction.onClicked.addListener(function(reply) {
chrome.tabs.getSelected(null, function(tab) {
updateTabData(tab);
})
chrome.windows.create({url: "chrome-extension://heaacngjhlnimlemljdooglmlemmhkhh/hotlinkmanager.html?" + urlbar1, width: 600, height: 600});
})
And updateTabData simply fills the global variable urlbar1 with contents from tab.url for use throughout the app. The variable urlbar1 should always be filled with the current tab's Omnibox URL and that's the problem. The code works fine when using one tab and also when you refresh or update to a new page in any tab. It's only a problem when you click to a new tab and want the existing URL without refreshing that tab.
I've tried everything I can think of to get this synchronization issue solved when moving between tabs. I'm fairly new to Chrome's API, so there may be a lot of nuances I'm missing with this stuff.
Anyway, anyone have any ideas on how I can reliably pull the correct tab.url from the currently focused tab after a switch, but without a page refresh?
Thanks.
--
Brian


LinkBack URL
About LinkBacks



Reply With Quote