| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/tabs/tab_strip_controller.h" | 5 #import "ios/chrome/browser/ui/tabs/tab_strip_controller.h" |
| 6 #import "ios/chrome/browser/ui/tabs/tab_strip_controller_private.h" | 6 #import "ios/chrome/browser/ui/tabs/tab_strip_controller_private.h" |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #import "base/ios/weak_nsobject.h" | 12 #import "base/ios/weak_nsobject.h" |
| 13 #include "base/mac/bundle_locations.h" | 13 #include "base/mac/bundle_locations.h" |
| 14 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
| 15 #include "base/mac/objc_property_releaser.h" | 15 #include "base/mac/objc_release_properties.h" |
| 16 #include "base/mac/scoped_nsobject.h" | 16 #include "base/mac/scoped_nsobject.h" |
| 17 #include "base/metrics/user_metrics.h" | 17 #include "base/metrics/user_metrics.h" |
| 18 #include "base/metrics/user_metrics_action.h" | 18 #include "base/metrics/user_metrics_action.h" |
| 19 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 21 #include "ios/chrome/browser/experimental_flags.h" | 21 #include "ios/chrome/browser/experimental_flags.h" |
| 22 #import "ios/chrome/browser/tabs/tab.h" | 22 #import "ios/chrome/browser/tabs/tab.h" |
| 23 #import "ios/chrome/browser/tabs/tab_model.h" | 23 #import "ios/chrome/browser/tabs/tab_model.h" |
| 24 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 24 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
| 25 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 25 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // as the new model index of the dragged tab when it is dropped. | 184 // as the new model index of the dragged tab when it is dropped. |
| 185 NSUInteger _placeholderGapModelIndex; | 185 NSUInteger _placeholderGapModelIndex; |
| 186 | 186 |
| 187 // If YES, display the mode toggle switch at the left side of the strip. Can | 187 // If YES, display the mode toggle switch at the left side of the strip. Can |
| 188 // be set after creation. | 188 // be set after creation. |
| 189 BOOL _hasModeToggleSwitch; | 189 BOOL _hasModeToggleSwitch; |
| 190 | 190 |
| 191 // If YES, display the tab switcher toggle switch at the left side of the | 191 // If YES, display the tab switcher toggle switch at the left side of the |
| 192 // strip. Can be set after creation. | 192 // strip. Can be set after creation. |
| 193 BOOL _hasTabSwitcherToggleSwitch; | 193 BOOL _hasTabSwitcherToggleSwitch; |
| 194 | |
| 195 base::mac::ObjCPropertyReleaser _propertyReleaser_TabStripController; | |
| 196 } | 194 } |
| 197 | 195 |
| 198 @property(nonatomic, readonly, retain) TabStripView* tabStripView; | 196 @property(nonatomic, readonly, retain) TabStripView* tabStripView; |
| 199 @property(nonatomic, readonly, retain) UIButton* buttonNewTab; | 197 @property(nonatomic, readonly, retain) UIButton* buttonNewTab; |
| 200 @property(nonatomic, readonly, assign) UIButton* tabSwitcherToggleButton; | 198 @property(nonatomic, readonly, assign) UIButton* tabSwitcherToggleButton; |
| 201 | 199 |
| 202 // Initializes the tab array based on the the entries in the TabModel. Creates | 200 // Initializes the tab array based on the the entries in the TabModel. Creates |
| 203 // one TabView per Tab and adds it to the tabstrip. A later call to | 201 // one TabView per Tab and adds it to the tabstrip. A later call to |
| 204 // |-layoutTabs| is needed to properly place the tabs in the correct positions. | 202 // |-layoutTabs| is needed to properly place the tabs in the correct positions. |
| 205 - (void)initializeTabArrayFromTabModel; | 203 - (void)initializeTabArrayFromTabModel; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 @synthesize hasTabSwitcherToggleSwitch = _hasTabSwitcherToggleSwitch; | 330 @synthesize hasTabSwitcherToggleSwitch = _hasTabSwitcherToggleSwitch; |
| 333 @synthesize highlightsSelectedTab = _highlightsSelectedTab; | 331 @synthesize highlightsSelectedTab = _highlightsSelectedTab; |
| 334 @synthesize modeToggleButton = _modeToggleButton; | 332 @synthesize modeToggleButton = _modeToggleButton; |
| 335 @synthesize tabStripView = _tabStripView; | 333 @synthesize tabStripView = _tabStripView; |
| 336 @synthesize tabSwitcherToggleButton = _tabSwitcherToggleButton; | 334 @synthesize tabSwitcherToggleButton = _tabSwitcherToggleButton; |
| 337 @synthesize view = _view; | 335 @synthesize view = _view; |
| 338 | 336 |
| 339 - (instancetype)initWithTabModel:(TabModel*)tabModel | 337 - (instancetype)initWithTabModel:(TabModel*)tabModel |
| 340 style:(TabStrip::Style)style { | 338 style:(TabStrip::Style)style { |
| 341 if ((self = [super init])) { | 339 if ((self = [super init])) { |
| 342 _propertyReleaser_TabStripController.Init(self, [TabStripController class]); | |
| 343 _tabArray.reset([[NSMutableArray alloc] initWithCapacity:10]); | 340 _tabArray.reset([[NSMutableArray alloc] initWithCapacity:10]); |
| 344 _closingTabs.reset([[NSMutableSet alloc] initWithCapacity:5]); | 341 _closingTabs.reset([[NSMutableSet alloc] initWithCapacity:5]); |
| 345 | 342 |
| 346 _tabModel.reset([tabModel retain]); | 343 _tabModel.reset([tabModel retain]); |
| 347 [_tabModel addObserver:self]; | 344 [_tabModel addObserver:self]; |
| 348 _style = style; | 345 _style = style; |
| 349 _hasModeToggleSwitch = NO; | 346 _hasModeToggleSwitch = NO; |
| 350 _hasTabSwitcherToggleSwitch = NO; | 347 _hasTabSwitcherToggleSwitch = NO; |
| 351 | 348 |
| 352 // |self.view| setup. | 349 // |self.view| setup. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 435 |
| 439 - (instancetype)init { | 436 - (instancetype)init { |
| 440 NOTREACHED(); | 437 NOTREACHED(); |
| 441 return nil; | 438 return nil; |
| 442 } | 439 } |
| 443 | 440 |
| 444 - (void)dealloc { | 441 - (void)dealloc { |
| 445 [_tabStripView setDelegate:nil]; | 442 [_tabStripView setDelegate:nil]; |
| 446 [_tabStripView setLayoutDelegate:nil]; | 443 [_tabStripView setLayoutDelegate:nil]; |
| 447 [_tabModel removeObserver:self]; | 444 [_tabModel removeObserver:self]; |
| 445 base::mac::ReleaseProperties(self); |
| 448 [super dealloc]; | 446 [super dealloc]; |
| 449 } | 447 } |
| 450 | 448 |
| 451 - (id<FullScreenControllerDelegate>)fullscreenDelegate { | 449 - (id<FullScreenControllerDelegate>)fullscreenDelegate { |
| 452 return _fullscreenDelegate; | 450 return _fullscreenDelegate; |
| 453 } | 451 } |
| 454 | 452 |
| 455 - (void)setFullscreenDelegate: | 453 - (void)setFullscreenDelegate: |
| 456 (id<FullScreenControllerDelegate>)fullscreenDelegate { | 454 (id<FullScreenControllerDelegate>)fullscreenDelegate { |
| 457 _fullscreenDelegate.reset(fullscreenDelegate); | 455 _fullscreenDelegate.reset(fullscreenDelegate); |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 | 1655 |
| 1658 @implementation TabStripController (Testing) | 1656 @implementation TabStripController (Testing) |
| 1659 | 1657 |
| 1660 - (TabView*)existingTabViewForTab:(Tab*)tab { | 1658 - (TabView*)existingTabViewForTab:(Tab*)tab { |
| 1661 NSUInteger tabIndex = [_tabModel indexOfTab:tab]; | 1659 NSUInteger tabIndex = [_tabModel indexOfTab:tab]; |
| 1662 NSUInteger tabViewIndex = [self indexForModelIndex:tabIndex]; | 1660 NSUInteger tabViewIndex = [self indexForModelIndex:tabIndex]; |
| 1663 return [_tabArray objectAtIndex:tabViewIndex]; | 1661 return [_tabArray objectAtIndex:tabViewIndex]; |
| 1664 } | 1662 } |
| 1665 | 1663 |
| 1666 @end | 1664 @end |
| OLD | NEW |