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

Unified Diff: ios/chrome/browser/tabs/tab_model_order_controller.mm

Issue 2690893003: Remove obsolete code in TabModelOrderController. (Closed)
Patch Set: Rebase on origin/master. 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
« no previous file with comments | « ios/chrome/browser/tabs/tab_model_order_controller.h ('k') | ios/chrome/browser/tabs/tab_model_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/tab_model_order_controller.mm
diff --git a/ios/chrome/browser/tabs/tab_model_order_controller.mm b/ios/chrome/browser/tabs/tab_model_order_controller.mm
index 215540b6c9312f9f7e333c033207985d7e76b909..0eb1f32d76a504000b4924dde1c85f04fb85251c 100644
--- a/ios/chrome/browser/tabs/tab_model_order_controller.mm
+++ b/ios/chrome/browser/tabs/tab_model_order_controller.mm
@@ -6,17 +6,18 @@
#include "base/logging.h"
-@implementation TabModelOrderController
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
-@synthesize insertionPolicy = insertionPolicy_;
+@implementation TabModelOrderController {
+ __weak TabModel* model_;
+}
-- (id)initWithTabModel:(TabModel*)model {
+- (instancetype)initWithTabModel:(TabModel*)model {
DCHECK(model);
- self = [super init];
- if (self) {
+ if ((self = [super init]))
model_ = model;
- insertionPolicy_ = TabModelOrderConstants::kInsertAfter;
- }
return self;
}
@@ -28,35 +29,23 @@
if (model_.isEmpty)
return 0;
- if (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK) &&
- parentTab) {
- NSUInteger referenceIndex = [model_ indexOfTab:parentTab];
- Tab* openLocation = nil;
- if (insertionPolicy_ == TabModelOrderConstants::kInsertAfter) {
- openLocation = [model_ lastTabWithOpener:parentTab];
- } else {
- openLocation = [model_ firstTabWithOpener:parentTab];
- }
- if (openLocation)
- referenceIndex = [model_ indexOfTab:openLocation];
-
- // If the reference tab is no longer in the model (e.g., it was closed
- // before the open request was handled), fall through to default behavior.
- if (referenceIndex != NSNotFound) {
- BOOL insertAfter =
- insertionPolicy_ == TabModelOrderConstants::kInsertAfter ||
- adjacency == TabModelOrderConstants::kAdjacentAfter;
- NSUInteger delta = insertAfter ? 1 : 0;
- return referenceIndex + delta;
- }
- }
- // In other cases, such as a normal new tab, open at the end.
- return [self insertionIndexForAppending];
+ if (!parentTab)
+ return [self insertionIndexForAppending];
+
+ if (!PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK))
+ return [self insertionIndexForAppending];
+
+ NSUInteger referenceIndex = [model_ indexOfTab:parentTab];
+ Tab* openLocation = [model_ lastTabWithOpener:parentTab];
+ if (openLocation)
+ referenceIndex = [model_ indexOfTab:openLocation];
+
+ DCHECK_NE(referenceIndex, static_cast<NSUInteger>(NSNotFound));
+ return referenceIndex + 1;
}
- (NSUInteger)insertionIndexForAppending {
- return insertionPolicy_ == TabModelOrderConstants::kInsertAfter ? model_.count
- : 0;
+ return model_.count;
}
- (Tab*)determineNewSelectedTabFromRemovedTab:(Tab*)removedTab {
@@ -69,6 +58,7 @@
const NSUInteger numberOfTabs = model_.count;
if (numberOfTabs < 2)
return nil;
+
DCHECK(numberOfTabs >= 2);
DCHECK(removedTab == model_.currentTab);
« no previous file with comments | « ios/chrome/browser/tabs/tab_model_order_controller.h ('k') | ios/chrome/browser/tabs/tab_model_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698