| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/tools_menu/tools_menu_view_controller.h" | 5 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/mac/objc_property_releaser.h" | 12 #include "base/mac/objc_release_properties.h" |
| 13 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "components/reading_list/core/reading_list_switches.h" | 15 #include "components/reading_list/core/reading_list_switches.h" |
| 16 #include "components/strings/grit/components_strings.h" | 16 #include "components/strings/grit/components_strings.h" |
| 17 #include "ios/chrome/browser/experimental_flags.h" | 17 #include "ios/chrome/browser/experimental_flags.h" |
| 18 #import "ios/chrome/browser/ui/animation_util.h" | 18 #import "ios/chrome/browser/ui/animation_util.h" |
| 19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 20 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 20 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 21 #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notification_deleg
ate.h" | 21 #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notification_deleg
ate.h" |
| 22 #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h" | 22 #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 @interface ToolsMenuViewToolsCell : UICollectionViewCell | 250 @interface ToolsMenuViewToolsCell : UICollectionViewCell |
| 251 @property(nonatomic, retain) ToolsMenuButton* reloadButton; | 251 @property(nonatomic, retain) ToolsMenuButton* reloadButton; |
| 252 @property(nonatomic, retain) ToolsMenuButton* shareButton; | 252 @property(nonatomic, retain) ToolsMenuButton* shareButton; |
| 253 @property(nonatomic, retain) ToolsMenuButton* starButton; | 253 @property(nonatomic, retain) ToolsMenuButton* starButton; |
| 254 @property(nonatomic, retain) ToolsMenuButton* starredButton; | 254 @property(nonatomic, retain) ToolsMenuButton* starredButton; |
| 255 @property(nonatomic, retain) ToolsMenuButton* stopButton; | 255 @property(nonatomic, retain) ToolsMenuButton* stopButton; |
| 256 @property(nonatomic, retain) ToolsMenuButton* toolsButton; | 256 @property(nonatomic, retain) ToolsMenuButton* toolsButton; |
| 257 @end | 257 @end |
| 258 | 258 |
| 259 @implementation ToolsMenuViewToolsCell { | 259 @implementation ToolsMenuViewToolsCell |
| 260 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewToolsCell; | |
| 261 } | |
| 262 | 260 |
| 263 @synthesize reloadButton = _reloadButton; | 261 @synthesize reloadButton = _reloadButton; |
| 264 @synthesize shareButton = _shareButton; | 262 @synthesize shareButton = _shareButton; |
| 265 @synthesize starButton = _starButton; | 263 @synthesize starButton = _starButton; |
| 266 @synthesize starredButton = _starredButton; | 264 @synthesize starredButton = _starredButton; |
| 267 @synthesize stopButton = _stopButton; | 265 @synthesize stopButton = _stopButton; |
| 268 @synthesize toolsButton = _toolsButton; | 266 @synthesize toolsButton = _toolsButton; |
| 269 | 267 |
| 270 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 268 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 271 self = [super initWithCoder:aDecoder]; | 269 self = [super initWithCoder:aDecoder]; |
| 272 if (self) | 270 if (self) |
| 273 [self commonInitialization]; | 271 [self commonInitialization]; |
| 274 | 272 |
| 275 return self; | 273 return self; |
| 276 } | 274 } |
| 277 | 275 |
| 278 - (instancetype)initWithFrame:(CGRect)frame { | 276 - (instancetype)initWithFrame:(CGRect)frame { |
| 279 self = [super initWithFrame:frame]; | 277 self = [super initWithFrame:frame]; |
| 280 if (self) | 278 if (self) |
| 281 [self commonInitialization]; | 279 [self commonInitialization]; |
| 282 | 280 |
| 283 return self; | 281 return self; |
| 284 } | 282 } |
| 285 | 283 |
| 286 - (void)commonInitialization { | 284 - (void)commonInitialization { |
| 287 _propertyReleaser_ToolsMenuViewToolsCell.Init(self, | |
| 288 [ToolsMenuViewToolsCell class]); | |
| 289 | |
| 290 [self setBackgroundColor:[UIColor whiteColor]]; | 285 [self setBackgroundColor:[UIColor whiteColor]]; |
| 291 [self setOpaque:YES]; | 286 [self setOpaque:YES]; |
| 292 | 287 |
| 293 int star[2][3] = TOOLBAR_IDR_TWO_STATE(STAR); | 288 int star[2][3] = TOOLBAR_IDR_TWO_STATE(STAR); |
| 294 _starButton = [self newButtonForImageIds:star | 289 _starButton = [self newButtonForImageIds:star |
| 295 commandID:IDC_BOOKMARK_PAGE | 290 commandID:IDC_BOOKMARK_PAGE |
| 296 accessibilityLabelID:IDS_BOOKMARK_ADD_EDITOR_TITLE | 291 accessibilityLabelID:IDS_BOOKMARK_ADD_EDITOR_TITLE |
| 297 automationName:@"Add Bookmark"]; | 292 automationName:@"Add Bookmark"]; |
| 298 | 293 |
| 299 int star_pressed[2][3] = TOOLBAR_IDR_ONE_STATE(STAR_PRESSED); | 294 int star_pressed[2][3] = TOOLBAR_IDR_ONE_STATE(STAR_PRESSED); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 328 |
| 334 [contentView addSubview:_starredButton]; | 329 [contentView addSubview:_starredButton]; |
| 335 [contentView addSubview:_starButton]; | 330 [contentView addSubview:_starButton]; |
| 336 [contentView addSubview:_stopButton]; | 331 [contentView addSubview:_stopButton]; |
| 337 [contentView addSubview:_reloadButton]; | 332 [contentView addSubview:_reloadButton]; |
| 338 [contentView addSubview:_shareButton]; | 333 [contentView addSubview:_shareButton]; |
| 339 | 334 |
| 340 [self addConstraints]; | 335 [self addConstraints]; |
| 341 } | 336 } |
| 342 | 337 |
| 338 - (void)dealloc { |
| 339 base::mac::ReleaseProperties(self); |
| 340 [super dealloc]; |
| 341 } |
| 342 |
| 343 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds | 343 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds |
| 344 commandID:(int)commandID | 344 commandID:(int)commandID |
| 345 accessibilityLabelID:(int)labelID | 345 accessibilityLabelID:(int)labelID |
| 346 automationName:(NSString*)name { | 346 automationName:(NSString*)name { |
| 347 return [self newButtonForImageIds:imageIds | 347 return [self newButtonForImageIds:imageIds |
| 348 commandID:commandID | 348 commandID:commandID |
| 349 accessibilityLabelID:labelID | 349 accessibilityLabelID:labelID |
| 350 automationName:name | 350 automationName:name |
| 351 reverseForRTL:NO]; | 351 reverseForRTL:NO]; |
| 352 } | 352 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 return allButtons; | 440 return allButtons; |
| 441 } | 441 } |
| 442 | 442 |
| 443 @end | 443 @end |
| 444 | 444 |
| 445 // Class Extension for private methods. | 445 // Class Extension for private methods. |
| 446 @interface ToolsMenuViewController ()<UICollectionViewDelegateFlowLayout, | 446 @interface ToolsMenuViewController ()<UICollectionViewDelegateFlowLayout, |
| 447 UICollectionViewDataSource, | 447 UICollectionViewDataSource, |
| 448 ReadingListMenuNotificationDelegate> { | 448 ReadingListMenuNotificationDelegate> { |
| 449 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewController; | |
| 450 BOOL _waitForInk; | 449 BOOL _waitForInk; |
| 451 // Weak pointer to ReadingListMenuNotifier, used to set the starting values | 450 // Weak pointer to ReadingListMenuNotifier, used to set the starting values |
| 452 // for the reading list badge. | 451 // for the reading list badge. |
| 453 base::WeakNSObject<ReadingListMenuNotifier> _readingListMenuNotifier; | 452 base::WeakNSObject<ReadingListMenuNotifier> _readingListMenuNotifier; |
| 454 } | 453 } |
| 455 @property(nonatomic, retain) ToolsMenuCollectionView* menuView; | 454 @property(nonatomic, retain) ToolsMenuCollectionView* menuView; |
| 456 @property(nonatomic, retain) MDCInkView* touchFeedbackView; | 455 @property(nonatomic, retain) MDCInkView* touchFeedbackView; |
| 457 @property(nonatomic, retain) NSMutableArray* menuItems; | 456 @property(nonatomic, retain) NSMutableArray* menuItems; |
| 458 @property(nonatomic, assign) kToolbarType toolbarType; | 457 @property(nonatomic, assign) kToolbarType toolbarType; |
| 459 | 458 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 659 |
| 661 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 660 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 662 self = [super initWithCoder:aDecoder]; | 661 self = [super initWithCoder:aDecoder]; |
| 663 if (self) | 662 if (self) |
| 664 [self commonInitialization]; | 663 [self commonInitialization]; |
| 665 | 664 |
| 666 return self; | 665 return self; |
| 667 } | 666 } |
| 668 | 667 |
| 669 - (void)commonInitialization { | 668 - (void)commonInitialization { |
| 670 _propertyReleaser_ToolsMenuViewController.Init( | |
| 671 self, [ToolsMenuViewController class]); | |
| 672 _readingListMenuNotifier.reset(); | 669 _readingListMenuNotifier.reset(); |
| 673 } | 670 } |
| 674 | 671 |
| 672 - (void)dealloc { |
| 673 base::mac::ReleaseProperties(self); |
| 674 [super dealloc]; |
| 675 } |
| 676 |
| 675 - (void)loadView { | 677 - (void)loadView { |
| 676 [super loadView]; | 678 [super loadView]; |
| 677 | 679 |
| 678 UIView* rootView = [self view]; | 680 UIView* rootView = [self view]; |
| 679 [rootView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | | 681 [rootView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | |
| 680 UIViewAutoresizingFlexibleWidth]; | 682 UIViewAutoresizingFlexibleWidth]; |
| 681 [rootView setBackgroundColor:[UIColor whiteColor]]; | 683 [rootView setBackgroundColor:[UIColor whiteColor]]; |
| 682 | 684 |
| 683 _touchFeedbackView = [[MDCInkView alloc] initWithFrame:CGRectZero]; | 685 _touchFeedbackView = [[MDCInkView alloc] initWithFrame:CGRectZero]; |
| 684 | 686 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 942 |
| 941 - (void)unreadCountChanged:(NSInteger)unreadCount { | 943 - (void)unreadCountChanged:(NSInteger)unreadCount { |
| 942 [[self readingListCell] updateBadgeCount:unreadCount animated:YES]; | 944 [[self readingListCell] updateBadgeCount:unreadCount animated:YES]; |
| 943 } | 945 } |
| 944 | 946 |
| 945 - (void)unseenStateChanged:(BOOL)unseenItemsExist { | 947 - (void)unseenStateChanged:(BOOL)unseenItemsExist { |
| 946 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES]; | 948 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES]; |
| 947 } | 949 } |
| 948 | 950 |
| 949 @end | 951 @end |
| OLD | NEW |