| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // as the new model index of the dragged tab when it is dropped. | 185 // as the new model index of the dragged tab when it is dropped. |
| 186 NSUInteger _placeholderGapModelIndex; | 186 NSUInteger _placeholderGapModelIndex; |
| 187 | 187 |
| 188 // If YES, display the mode toggle switch at the left side of the strip. Can | 188 // If YES, display the mode toggle switch at the left side of the strip. Can |
| 189 // be set after creation. | 189 // be set after creation. |
| 190 BOOL _hasModeToggleSwitch; | 190 BOOL _hasModeToggleSwitch; |
| 191 | 191 |
| 192 // If YES, display the tab switcher toggle switch at the left side of the | 192 // If YES, display the tab switcher toggle switch at the left side of the |
| 193 // strip. Can be set after creation. | 193 // strip. Can be set after creation. |
| 194 BOOL _hasTabSwitcherToggleSwitch; | 194 BOOL _hasTabSwitcherToggleSwitch; |
| 195 | |
| 196 base::mac::ObjCPropertyReleaser _propertyReleaser_TabStripController; | |
| 197 } | 195 } |
| 198 | 196 |
| 199 @property(nonatomic, readonly, retain) TabStripView* tabStripView; | 197 @property(nonatomic, readonly, retain) TabStripView* tabStripView; |
| 200 @property(nonatomic, readonly, retain) UIButton* buttonNewTab; | 198 @property(nonatomic, readonly, retain) UIButton* buttonNewTab; |
| 201 @property(nonatomic, readonly, assign) UIButton* tabSwitcherToggleButton; | 199 @property(nonatomic, readonly, assign) UIButton* tabSwitcherToggleButton; |
| 202 | 200 |
| 203 // Initializes the tab array based on the the entries in the TabModel. Creates | 201 // Initializes the tab array based on the the entries in the TabModel. Creates |
| 204 // one TabView per Tab and adds it to the tabstrip. A later call to | 202 // one TabView per Tab and adds it to the tabstrip. A later call to |
| 205 // |-layoutTabs| is needed to properly place the tabs in the correct positions. | 203 // |-layoutTabs| is needed to properly place the tabs in the correct positions. |
| 206 - (void)initializeTabArrayFromTabModel; | 204 - (void)initializeTabArrayFromTabModel; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 @synthesize hasTabSwitcherToggleSwitch = _hasTabSwitcherToggleSwitch; | 343 @synthesize hasTabSwitcherToggleSwitch = _hasTabSwitcherToggleSwitch; |
| 346 @synthesize highlightsSelectedTab = _highlightsSelectedTab; | 344 @synthesize highlightsSelectedTab = _highlightsSelectedTab; |
| 347 @synthesize modeToggleButton = _modeToggleButton; | 345 @synthesize modeToggleButton = _modeToggleButton; |
| 348 @synthesize tabStripView = _tabStripView; | 346 @synthesize tabStripView = _tabStripView; |
| 349 @synthesize tabSwitcherToggleButton = _tabSwitcherToggleButton; | 347 @synthesize tabSwitcherToggleButton = _tabSwitcherToggleButton; |
| 350 @synthesize view = _view; | 348 @synthesize view = _view; |
| 351 | 349 |
| 352 - (instancetype)initWithTabModel:(TabModel*)tabModel | 350 - (instancetype)initWithTabModel:(TabModel*)tabModel |
| 353 style:(TabStrip::Style)style { | 351 style:(TabStrip::Style)style { |
| 354 if ((self = [super init])) { | 352 if ((self = [super init])) { |
| 355 _propertyReleaser_TabStripController.Init(self, [TabStripController class]); | |
| 356 _tabArray.reset([[NSMutableArray alloc] initWithCapacity:10]); | 353 _tabArray.reset([[NSMutableArray alloc] initWithCapacity:10]); |
| 357 _closingTabs.reset([[NSMutableSet alloc] initWithCapacity:5]); | 354 _closingTabs.reset([[NSMutableSet alloc] initWithCapacity:5]); |
| 358 | 355 |
| 359 _tabModel.reset([tabModel retain]); | 356 _tabModel.reset([tabModel retain]); |
| 360 [_tabModel addObserver:self]; | 357 [_tabModel addObserver:self]; |
| 361 _style = style; | 358 _style = style; |
| 362 _hasModeToggleSwitch = NO; | 359 _hasModeToggleSwitch = NO; |
| 363 _hasTabSwitcherToggleSwitch = NO; | 360 _hasTabSwitcherToggleSwitch = NO; |
| 364 | 361 |
| 365 // |self.view| setup. | 362 // |self.view| setup. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 448 |
| 452 - (instancetype)init { | 449 - (instancetype)init { |
| 453 NOTREACHED(); | 450 NOTREACHED(); |
| 454 return nil; | 451 return nil; |
| 455 } | 452 } |
| 456 | 453 |
| 457 - (void)dealloc { | 454 - (void)dealloc { |
| 458 [_tabStripView setDelegate:nil]; | 455 [_tabStripView setDelegate:nil]; |
| 459 [_tabStripView setLayoutDelegate:nil]; | 456 [_tabStripView setLayoutDelegate:nil]; |
| 460 [_tabModel removeObserver:self]; | 457 [_tabModel removeObserver:self]; |
| 458 base::mac::ReleaseProperties(self); |
| 461 [super dealloc]; | 459 [super dealloc]; |
| 462 } | 460 } |
| 463 | 461 |
| 464 - (id<FullScreenControllerDelegate>)fullscreenDelegate { | 462 - (id<FullScreenControllerDelegate>)fullscreenDelegate { |
| 465 return _fullscreenDelegate; | 463 return _fullscreenDelegate; |
| 466 } | 464 } |
| 467 | 465 |
| 468 - (void)setFullscreenDelegate: | 466 - (void)setFullscreenDelegate: |
| 469 (id<FullScreenControllerDelegate>)fullscreenDelegate { | 467 (id<FullScreenControllerDelegate>)fullscreenDelegate { |
| 470 _fullscreenDelegate.reset(fullscreenDelegate); | 468 _fullscreenDelegate.reset(fullscreenDelegate); |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 | 1720 |
| 1723 @implementation TabStripController (Testing) | 1721 @implementation TabStripController (Testing) |
| 1724 | 1722 |
| 1725 - (TabView*)existingTabViewForTab:(Tab*)tab { | 1723 - (TabView*)existingTabViewForTab:(Tab*)tab { |
| 1726 NSUInteger tabIndex = [_tabModel indexOfTab:tab]; | 1724 NSUInteger tabIndex = [_tabModel indexOfTab:tab]; |
| 1727 NSUInteger tabViewIndex = [self indexForModelIndex:tabIndex]; | 1725 NSUInteger tabViewIndex = [self indexForModelIndex:tabIndex]; |
| 1728 return [_tabArray objectAtIndex:tabViewIndex]; | 1726 return [_tabArray objectAtIndex:tabViewIndex]; |
| 1729 } | 1727 } |
| 1730 | 1728 |
| 1731 @end | 1729 @end |
| OLD | NEW |