| 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" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 352 } |
| 353 | 353 |
| 354 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds | 354 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds |
| 355 commandID:(int)commandID | 355 commandID:(int)commandID |
| 356 accessibilityLabelID:(int)labelID | 356 accessibilityLabelID:(int)labelID |
| 357 automationName:(NSString*)name | 357 automationName:(NSString*)name |
| 358 reverseForRTL:(BOOL)reverseForRTL { | 358 reverseForRTL:(BOOL)reverseForRTL { |
| 359 ToolsMenuButton* button = [[ToolsMenuButton alloc] initWithFrame:CGRectZero]; | 359 ToolsMenuButton* button = [[ToolsMenuButton alloc] initWithFrame:CGRectZero]; |
| 360 [button setTranslatesAutoresizingMaskIntoConstraints:NO]; | 360 [button setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 361 | 361 |
| 362 [button setImage:NativeReversableImage(imageIds[0][0], reverseForRTL) | 362 if (imageIds[0][0]) { |
| 363 forState:UIControlStateNormal]; | 363 [button setImage:NativeReversableImage(imageIds[0][0], reverseForRTL) |
| 364 forState:UIControlStateNormal]; |
| 365 } |
| 364 [[button imageView] setContentMode:UIViewContentModeCenter]; | 366 [[button imageView] setContentMode:UIViewContentModeCenter]; |
| 365 [button setBackgroundColor:[self backgroundColor]]; | 367 [button setBackgroundColor:[self backgroundColor]]; |
| 366 [button setTag:commandID]; | 368 [button setTag:commandID]; |
| 367 [button setOpaque:YES]; | 369 [button setOpaque:YES]; |
| 368 | 370 |
| 369 SetA11yLabelAndUiAutomationName(button, labelID, name); | 371 SetA11yLabelAndUiAutomationName(button, labelID, name); |
| 370 | 372 |
| 371 UIImage* pressedImage = NativeReversableImage(imageIds[0][1], reverseForRTL); | 373 if (imageIds[0][1]) { |
| 372 if (pressedImage) { | 374 UIImage* pressedImage = |
| 373 [button setImage:pressedImage forState:UIControlStateHighlighted]; | 375 NativeReversableImage(imageIds[0][1], reverseForRTL); |
| 376 if (pressedImage) { |
| 377 [button setImage:pressedImage forState:UIControlStateHighlighted]; |
| 378 } |
| 374 } | 379 } |
| 375 | 380 |
| 376 UIImage* disabledImage = NativeReversableImage(imageIds[0][2], reverseForRTL); | 381 if (imageIds[0][2]) { |
| 377 if (disabledImage) { | 382 UIImage* disabledImage = |
| 378 [button setImage:disabledImage forState:UIControlStateDisabled]; | 383 NativeReversableImage(imageIds[0][2], reverseForRTL); |
| 384 if (disabledImage) { |
| 385 [button setImage:disabledImage forState:UIControlStateDisabled]; |
| 386 } |
| 379 } | 387 } |
| 380 | 388 |
| 381 return button; | 389 return button; |
| 382 } | 390 } |
| 383 | 391 |
| 384 - (void)addConstraints { | 392 - (void)addConstraints { |
| 385 UIView* contentView = [self contentView]; | 393 UIView* contentView = [self contentView]; |
| 386 | 394 |
| 387 for (UIButton* button in [self allButtons]) { | 395 for (UIButton* button in [self allButtons]) { |
| 388 NSDictionary* view = @{ @"button" : button }; | 396 NSDictionary* view = @{ @"button" : button }; |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 | 940 |
| 933 - (void)unreadCountChanged:(NSInteger)unreadCount { | 941 - (void)unreadCountChanged:(NSInteger)unreadCount { |
| 934 [[self readingListCell] updateBadgeCount:unreadCount animated:YES]; | 942 [[self readingListCell] updateBadgeCount:unreadCount animated:YES]; |
| 935 } | 943 } |
| 936 | 944 |
| 937 - (void)unseenStateChanged:(BOOL)unseenItemsExist { | 945 - (void)unseenStateChanged:(BOOL)unseenItemsExist { |
| 938 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES]; | 946 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES]; |
| 939 } | 947 } |
| 940 | 948 |
| 941 @end | 949 @end |
| OLD | NEW |