Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: ios/shared/chrome/browser/tabs/web_state_list.mm

Issue 2699833004: Add WebStateListOrderController to control WebState insertion. (Closed)
Patch Set: Address comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e6f4579d22fb35440773676484588ef1d487bfda..77c01a6f938064f25c233665c52409ae00e1216c 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;
@@ -155,6 +157,16 @@ void WebStateList::InsertWebState(int index,
observer.WebStateInsertedAt(this, web_state, index);
}
+void WebStateList::AppendWebState(ui::PageTransition transition,
+ web::WebState* web_state,
+ web::WebState* opener) {
+ int index = order_controller_->DetermineInsertionIndex(transition, opener);
+ if (index < 0 || count() < index)
+ index = count();
+
+ InsertWebState(index, web_state, opener);
+}
+
void WebStateList::MoveWebStateAt(int from_index, int to_index) {
DCHECK(ContainsIndex(from_index));
DCHECK(ContainsIndex(to_index));
« no previous file with comments | « ios/shared/chrome/browser/tabs/web_state_list.h ('k') | ios/shared/chrome/browser/tabs/web_state_list_order_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698