Chromium Code Reviews| Index: ios/shared/chrome/browser/tabs/web_state_list.mm |
| diff --git a/ios/shared/chrome/browser/tabs/web_state_list.mm b/ios/shared/chrome/browser/tabs/web_state_list.mm |
| index 1137e81b349d7b4701a395aef542999c55bc0699..b1a440ee0505b12c4dfdac1a2dff9f2691c533ee 100644 |
| --- a/ios/shared/chrome/browser/tabs/web_state_list.mm |
| +++ b/ios/shared/chrome/browser/tabs/web_state_list.mm |
| @@ -9,6 +9,7 @@ |
| #include "base/logging.h" |
| #include "base/memory/ptr_util.h" |
| #import "ios/shared/chrome/browser/tabs/web_state_list_observer.h" |
| +#import "ios/shared/chrome/browser/tabs/web_state_list_order_controller.h" |
| #import "ios/web/public/navigation_manager.h" |
| #import "ios/web/public/web_state/web_state.h" |
| @@ -95,7 +96,8 @@ bool WebStateList::WebStateWrapper::WasOpenedBy(const web::WebState* opener, |
| } |
| WebStateList::WebStateList(WebStateOwnership ownership) |
| - : web_state_ownership_(ownership) {} |
| + : web_state_ownership_(ownership), |
| + order_controller_(base::MakeUnique<WebStateListOrderController>(this)) {} |
| WebStateList::~WebStateList() = default; |
| @@ -149,6 +151,33 @@ void WebStateList::InsertWebState(int index, |
| observer.WebStateInsertedAt(this, web_state, index); |
| } |
| +void WebStateList::AddWebState(int index, |
| + ui::PageTransition transition, |
| + web::WebState* web_state, |
| + web::WebState* opener) { |
| + if (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK)) { |
| + // Assume WebStates opened via link clicks are part of the same "task" as |
| + // their parent and are grouped together, unless the index is forced. |
| + if (index == kInvalidIndex) |
|
marq (ping after 24h)
2017/02/17 13:33:00
The header says to pass kInvalidIndex to have the
sdefresne
2017/02/20 16:12:56
Addressed.
|
| + index = order_controller_->DetermineInsertionIndex(transition, opener); |
| + } |
| + |
| + if (index < 0 || count() < index) |
| + index = count(); |
| + |
| + if (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED)) { |
| + // Also, any WebState opened at the end of the WebStateList with a "TYPED" |
| + // transition inherit groups as well. This covers the cases where the user |
| + // creats a New Tab (e.g. Ctrl+T, or clicks the New Tab button), or types |
|
rohitrao (ping after 24h)
2017/02/17 13:04:12
creates
sdefresne
2017/02/20 16:12:56
Removed.
|
| + // in the address bar and presses Alt+Enter. This allows for opening a new |
| + // Tab to quickly look up something. When this Tab is closed, the old one |
|
marq (ping after 24h)
2017/02/17 13:33:00
Nit: do we need a comment in our iOS code that des
sdefresne
2017/02/20 16:12:56
Removed.
|
| + // is re-selected, not the next-adjacent. |
| + // TODO(crbug.com/661988): Make this work. |
| + } |
| + |
| + InsertWebState(index, web_state, opener); |
| +} |
| + |
| void WebStateList::MoveWebStateAt(int from_index, int to_index) { |
| DCHECK(ContainsIndex(from_index)); |
| DCHECK(ContainsIndex(to_index)); |