Closed Bug 887268 Opened 11 years ago Closed 11 years ago

Open items from "tabs from last time" page on a new tabs

Categories

(Firefox for Android Graveyard :: Awesomescreen, defect, P1)

All
Android
defect

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 26

People

(Reporter: lucasr, Assigned: lucasr)

References

Details

(Whiteboard: fixed-fig)

Attachments

(3 files, 1 obsolete file)

Instead of simply opening the URL in the current tab.
Priority: -- → P1
Attachment #773282 - Flags: review?(bnicholson)
Assignee: nobody → lucasr.at.mozilla
Attachment #773280 - Flags: review?(bnicholson) → review+
Attachment #773281 - Flags: review?(bnicholson) → review+
Comment on attachment 773282 [details] [diff] [review]
(3/3) Open items from "tabs from last time" on a new tabs

Review of attachment 773282 [details] [diff] [review]:
-----------------------------------------------------------------

Since we have a single method called openUrl() in BrowserApp that's overloaded to handle both behaviors, wouldn't it be more consistent to add another onUrlOpen() method that accepts an EditingTarget? This could be added to the existing OnUrlOpenListener interface instead of creating a new one.
(In reply to Brian Nicholson (:bnicholson) from comment #4)
> Comment on attachment 773282 [details] [diff] [review]
> (3/3) Open items from "tabs from last time" on a new tabs
> 
> Review of attachment 773282 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Since we have a single method called openUrl() in BrowserApp that's
> overloaded to handle both behaviors, wouldn't it be more consistent to add
> another onUrlOpen() method that accepts an EditingTarget? This could be
> added to the existing OnUrlOpenListener interface instead of creating a new
> one.

I considered doing that but EditingTarget is an implementation detail of toolbar/editing mode in the main UI. I don't want to leak this into the about:home interface. I feel that the new listener creates a more clear/concise contract between the two components.
Attachment #774036 - Flags: review?(bnicholson)
Attachment #773282 - Attachment is obsolete: true
Attachment #773282 - Flags: review?(bnicholson)
Changes the OnNewTabsListener interface to better support the fix for bug 887269.
Comment on attachment 774036 [details] [diff] [review]
Open items from "tabs from last time" on a new tabs

Review of attachment 774036 [details] [diff] [review]:
-----------------------------------------------------------------

I don't understand the reasoning behind an array here. In bug 887269, you're iterating through the cursors, building an array, passing it to onNewTabs(), then iterating through that array. Wouldn't it be more straightforward to simply call mNewTabsListener.onNewTab() directly for each item in the cursor? From an API perspective, it's also cleaner IMO to pass a single URL over an array of them.

I guess one advantage of using an array would be that you could execute some kind of pre/post batch operation without needing a separate callback, but I don't see you using that here. Any reason you can't just use the single onNewTab() callback you used before?

::: mobile/android/base/BrowserApp.java
@@ +1966,5 @@
>  
> +    // HomePager.OnNewTabsListener
> +    @Override
> +    public void onNewTabs(String[] urls) {
> +        for (int i = 0; i < urls.length; i++) {

Nit: use a for each loop
(In reply to Brian Nicholson (:bnicholson) from comment #8)
> Comment on attachment 774036 [details] [diff] [review]
> Open items from "tabs from last time" on a new tabs
> 
> Review of attachment 774036 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> I don't understand the reasoning behind an array here. In bug 887269, you're
> iterating through the cursors, building an array, passing it to onNewTabs(),
> then iterating through that array. Wouldn't it be more straightforward to
> simply call mNewTabsListener.onNewTab() directly for each item in the
> cursor? From an API perspective, it's also cleaner IMO to pass a single URL
> over an array of them.

The reason is simple: about:home is guaranteed to be closed once the onNewTab listener is used (see the last few lines in openUrl() for reference). We can't assume the state of the HomePager fragments will be alive once onNewTab is called.

In other words, the operation to open new tabs has to done in one step. Hence the list-of-tabs approach. I'm open to suggestions for a better API though. Just let me know.
 
> ::: mobile/android/base/BrowserApp.java
> @@ +1966,5 @@
> >  
> > +    // HomePager.OnNewTabsListener
> > +    @Override
> > +    public void onNewTabs(String[] urls) {
> > +        for (int i = 0; i < urls.length; i++) {
> 
> Nit: use a for each loop

Done.
Comment on attachment 774036 [details] [diff] [review]
Open items from "tabs from last time" on a new tabs

Review of attachment 774036 [details] [diff] [review]:
-----------------------------------------------------------------

OK, makes sense.
Attachment #774036 - Flags: review?(bnicholson) → review+
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: