| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_TABS_TAB_MODEL_ORDER_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_TABS_TAB_MODEL_ORDER_CONTROLLER_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 #import "ios/chrome/browser/tabs/tab_model.h" |
| 11 #include "ui/base/page_transition_types.h" |
| 12 |
| 13 namespace TabModelOrderConstants { |
| 14 |
| 15 // InsertionPolicy is a general policy for opening all new tabs. |
| 16 enum InsertionPolicy { |
| 17 // Newly created tabs are created after the selection. This is the default. |
| 18 kInsertAfter, |
| 19 // Newly created tabs are inserted before the selection. |
| 20 kInsertBefore, |
| 21 }; |
| 22 |
| 23 // InsertionAdjacency allows different links to choose to open tabs directly |
| 24 // before or after a given tab, depending on context. |
| 25 enum InsertionAdjacency { |
| 26 // Insert a card just before (to the left of) a given card. |
| 27 kAdjacentBefore, |
| 28 // Insert a card just after (to the right of) a given card. |
| 29 kAdjacentAfter, |
| 30 }; |
| 31 |
| 32 } // namespace TabModelOrderConstants |
| 33 |
| 34 // An object that allows different types of ordering and reselection to be |
| 35 // heuristics plugged into a TabStripModel. Closely parallels |
| 36 // chrome/browser/tabs/tab_strip_model_order_controller.h |
| 37 // but without the dependence on TabContentsWrapper and TabStripModel. |
| 38 @interface TabModelOrderController : NSObject { |
| 39 @private |
| 40 TabModel* model_; // weak, owns us |
| 41 TabModelOrderConstants::InsertionPolicy insertionPolicy_; |
| 42 } |
| 43 |
| 44 // Sets the insertion policy for new tabs. Default is |kInsertAfter|. |
| 45 @property(nonatomic, assign) |
| 46 TabModelOrderConstants::InsertionPolicy insertionPolicy; |
| 47 |
| 48 // Initializer, |model| must be non-nil and is not retained. |
| 49 - (id)initWithTabModel:(TabModel*)model; |
| 50 |
| 51 // Determines where to place a newly opened tab by using the transition and |
| 52 // adjacency flags. |
| 53 - (NSUInteger)insertionIndexForTab:(Tab*)newTab |
| 54 transition:(ui::PageTransition)transition |
| 55 opener:(Tab*)parentTab |
| 56 adjacency:(TabModelOrderConstants::InsertionAdjacency) |
| 57 adjacency; |
| 58 |
| 59 // Returns the index at which to append tabs, based on |insertionPolicy|. |
| 60 - (NSUInteger)insertionIndexForAppending; |
| 61 |
| 62 // Returns the tab in which to shift selection after a tab is closed. May |
| 63 // return nil if there are no more tabs. |
| 64 - (Tab*)determineNewSelectedTabFromRemovedTab:(Tab*)removedTab; |
| 65 |
| 66 @end |
| 67 |
| 68 #endif // IOS_CHROME_BROWSER_TABS_TAB_MODEL_ORDER_CONTROLLER_H_ |
| OLD | NEW |