You need to handle the whole problem yourself, here is a suggested
solution:

You need a data structure to hold some information about each tab and
its children:
> tabChildren[parentTabId] = [childTabId1, childTabId2, ...];

Now when you want to position the new tab you should simply do the
following:
> parentTabIndex = getIndex(parentTabId);
> maxChildIndex = max(getIndex(childTabId1), getIndex(childTabId2), ...); // 
> should return '0' if there's no children
> newTabIndex = max(parentTabIndex, maxChildIndex); // create the new tab at 
> this index and add it to tabChildren

This will simulate Chrome's behavior in different cases.
Also you need to write some code to remove a child tab when it's
closed or detached, and you're done.

On Jan 4, 11:03 pm, Rafael Weinstein <[email protected]> wrote:
> You are correct. I never noticed that the cntl-click open new tab
> behavior was more complex than open at max(index)+1.
>
> Apologies. Feel free to open a bug for this request at crbug.com.
>
> Rafael
>
>
>
> On Mon, Jan 4, 2010 at 12:24 PM, Ionut Bilica <[email protected]> wrote:
> > Omitting the "index" parameter results in positioning the tab as last
> > tab in window (not the default behavior).
> > So problem still not solved.
>
> > Thanks for your replay.
>
> > Is there a solution?
>
> > On Mon, Jan 4, 2010 at 9:42 PM, Rafael Weinstein <[email protected]> 
> > wrote:
> >> Just omit the index parameter like this:
>
> >>                                        chrome.tabs.create({
> >>                                                windowId: tab.windowId,
> >>                                                url:      request.url,
> >>                                                selected: 
> >> (localStorage[request.click] == "foreground")
> >>                                          });
>
> >> Doing so tells chrome to use the default behavior of inserting a new tab.
>
> >> I tried it with your extension and it seems to work.
>
> >> Cheers
> >> Rafael
>
> >> On Mon, Jan 4, 2010 at 12:13 AM, Ionut Bilica <[email protected]> 
> >> wrote:
> >>> Tanks for your replay,
>
> >>> I know about the "index" parameter, but you can not use it to get the
> >>> right behavior.
>
> >>> If I ctrl+click two links in tab A, my Chrome will show tabs A,B,C in
> >>> this order. If I use tabs.create using index as you suggested, I get
> >>> A, C, B. The last tab opened is inserted (using the index parameter)
> >>> right after the current tab. So if you open more than one tabs, the
> >>> last opened will be the one next to the active tab. Which is not the
> >>> normal behavior.
>
> >>> Chrome's positioning of new opened tab is clever. Not making it
> >>> available for extension writers is not so clever.
>
> >>> The extension I'm working on, and which gives me this headache is:
> >>>https://chrome.google.com/extensions/detail/afalkcagoidkdjdlfoaicbanb...
>
> >>> Thanks again
>
> >>> On Mon, Jan 4, 2010 at 12:36 AM, Mohamed Mansour <[email protected]> 
> >>> wrote:
> >>>> The tab api has a "create" method as you have seen:
> >>>>http://code.google.com/chrome/extensions/tabs.html#method-create
> >>>> One of the parameters is "index", you can use that index to position that
> >>>> tab anywhere in that window. So once you open a new link, you get its 
> >>>> tab's
> >>>> index from the tab object, and you increment 1. That value gets passed 
> >>>> into
> >>>> the "index" of the createProperties for chrome.tabs.create.
> >>>> -Mohamed Mansour
>
> >>>> On Fri, Jan 1, 2010 at 8:56 AM, ionut.bilica <[email protected]> 
> >>>> wrote:
>
> >>>>> In Chrome, when opening a link in a new tab, it is positioned after
> >>>>> the last tab created to open a link from the current tab.
> >>>>> How do I simulate this with chrome.tabs.create?
>
> >>>>> Thanks
>
> >>>>> --
>
> >>>>> You received this message because you are subscribed to the Google 
> >>>>> Groups
> >>>>> "Chromium-extensions" group.
> >>>>> To post to this group, send email to 
> >>>>> [email protected].
> >>>>> To unsubscribe from this group, send email to
> >>>>> [email protected].
> >>>>> For more options, visit this group at
> >>>>>http://groups.google.com/group/chromium-extensions?hl=en.
>
> >>> --
>
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "Chromium-extensions" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to 
> >>> [email protected].
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/chromium-extensions?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to