Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.mm

Issue 2706293008: [ios] Creates ToolsMenuModel Class (Closed)
Patch Set: Format Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/tools_menu/tools_menu_model.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_property_releaser.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"
16 #include "components/strings/grit/components_strings.h"
17 #include "ios/chrome/browser/experimental_flags.h"
18 #import "ios/chrome/browser/ui/animation_util.h" 15 #import "ios/chrome/browser/ui/animation_util.h"
19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" 16 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
20 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 17 #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" 18 #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" 19 #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h"
23 #import "ios/chrome/browser/ui/tools_menu/reading_list_menu_view_item.h" 20 #import "ios/chrome/browser/ui/tools_menu/reading_list_menu_view_item.h"
24 #import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h" 21 #import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h"
22 #include "ios/chrome/browser/ui/tools_menu/tools_menu_model.h"
25 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_item.h" 23 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_item.h"
26 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_tools_cell.h" 24 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_tools_cell.h"
27 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" 25 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h"
28 #include "ios/chrome/browser/ui/ui_util.h"
29 #import "ios/chrome/browser/ui/uikit_ui_util.h" 26 #import "ios/chrome/browser/ui/uikit_ui_util.h"
30 #import "ios/chrome/common/material_timing.h" 27 #import "ios/chrome/common/material_timing.h"
31 #include "ios/chrome/grit/ios_strings.h" 28 #include "ios/chrome/grit/ios_strings.h"
32 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
33 #import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider .h"
34 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h" 29 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h"
35 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
36 #include "ui/base/l10n/l10n_util_mac.h" 31 #include "ui/base/l10n/l10n_util_mac.h"
37 32
38 using ios::material::TimingFunction; 33 using ios::material::TimingFunction;
39 34
40 NSString* const kToolsMenuNewTabId = @"kToolsMenuNewTabId";
41 NSString* const kToolsMenuNewIncognitoTabId = @"kToolsMenuNewIncognitoTabId";
42 NSString* const kToolsMenuCloseAllTabsId = @"kToolsMenuCloseAllTabsId";
43 NSString* const kToolsMenuCloseAllIncognitoTabsId =
44 @"kToolsMenuCloseAllIncognitoTabsId";
45 NSString* const kToolsMenuBookmarksId = @"kToolsMenuBookmarksId";
46 NSString* const kToolsMenuReadingListId = @"kToolsMenuReadingListId";
47 NSString* const kToolsMenuOtherDevicesId = @"kToolsMenuOtherDevicesId";
48 NSString* const kToolsMenuHistoryId = @"kToolsMenuHistoryId";
49 NSString* const kToolsMenuReportAnIssueId = @"kToolsMenuReportAnIssueId";
50 NSString* const kToolsMenuFindInPageId = @"kToolsMenuFindInPageId";
51 NSString* const kToolsMenuReaderMode = @"kToolsMenuReaderMode";
52 NSString* const kToolsMenuRequestDesktopId = @"kToolsMenuRequestDesktopId";
53 NSString* const kToolsMenuSettingsId = @"kToolsMenuSettingsId";
54 NSString* const kToolsMenuHelpId = @"kToolsMenuHelpId";
55 NSString* const kToolsMenuSuggestionsId = @"kToolsMenuSuggestionsId";
56
57 namespace { 35 namespace {
58 36
59 // Time for ink to fade into view. 37 // Time for ink to fade into view.
60 static const NSTimeInterval kMDCInkTouchDelayInterval = 0.15; 38 static const NSTimeInterval kMDCInkTouchDelayInterval = 0.15;
61 39
62 static const CGFloat kMenuItemHeight = 48; 40 static const CGFloat kMenuItemHeight = 48;
63 41
64 static NSString* const kToolsItemCellID = @"ToolsItemCellID"; 42 static NSString* const kToolsItemCellID = @"ToolsItemCellID";
65 43
66 // Menu items can be marked as visible or not when Incognito is enabled.
67 // The following bits are used for |visibility| field in |MenuItemInfo|.
68 const NSInteger kVisibleIncognitoOnly = 1 << 0;
69 const NSInteger kVisibleNotIncognitoOnly = 1 << 1;
70
71 // Initialization table for all possible commands to initialize the
72 // tools menu at run time. Data initialized into this structure is not mutable.
73 struct MenuItemInfo {
74 int title_id;
75 NSString* accessibility_id;
76 int command_id;
77 int toolbar_types;
78 // |visibility| is applied if a menu item is included for a given
79 // |toolbar_types|. A value of 0 means the menu item is always visible for
80 // the given |toolbar_types|.
81 int visibility;
82 // Custom class, if any, for the menu item, or |nil|.
83 Class item_class;
84 };
85
86 // Flags for different toolbar types
87 typedef NS_OPTIONS(NSUInteger, kToolbarType) {
88 // clang-format off
89 kToolbarTypeNone = 0,
90 kToolbarTypeWebiPhone = 1 << 0,
91 kToolbarTypeWebiPad = 1 << 1,
92 kToolbarTypeNoTabsiPad = 1 << 2,
93 kToolbarTypeSwitcheriPhone = 1 << 3,
94 kToolbarTypeWebAll = kToolbarTypeWebiPhone | kToolbarTypeWebiPad,
95 kToolbarTypeAll = kToolbarTypeWebAll |
96 kToolbarTypeSwitcheriPhone |
97 kToolbarTypeNoTabsiPad,
98 // clang-format on
99 };
100
101 // Declare all the possible items.
102 static MenuItemInfo itemInfoList[] = {
103 // clang-format off
104 { IDS_IOS_TOOLS_MENU_NEW_TAB, kToolsMenuNewTabId,
105 IDC_NEW_TAB, kToolbarTypeAll,
106 0, nil },
107 { IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB, kToolsMenuNewIncognitoTabId,
108 IDC_NEW_INCOGNITO_TAB, kToolbarTypeAll,
109 0, nil },
110 { IDS_IOS_TOOLS_MENU_CLOSE_ALL_TABS, kToolsMenuCloseAllTabsId,
111 IDC_CLOSE_ALL_TABS, kToolbarTypeSwitcheriPhone,
112 kVisibleNotIncognitoOnly, nil },
113 { IDS_IOS_TOOLS_MENU_CLOSE_ALL_INCOGNITO_TABS,
114 kToolsMenuCloseAllIncognitoTabsId,
115 IDC_CLOSE_ALL_INCOGNITO_TABS, kToolbarTypeSwitcheriPhone,
116 kVisibleIncognitoOnly, nil },
117 { IDS_IOS_TOOLS_MENU_BOOKMARKS, kToolsMenuBookmarksId,
118 IDC_SHOW_BOOKMARK_MANAGER, kToolbarTypeWebAll,
119 0, nil },
120 { IDS_IOS_TOOLS_MENU_READING_LIST, kToolsMenuReadingListId,
121 IDC_SHOW_READING_LIST, kToolbarTypeWebAll,
122 0, [ReadingListMenuViewItem class] },
123 { IDS_IOS_TOOLS_MENU_SUGGESTIONS, kToolsMenuSuggestionsId,
124 IDC_SHOW_SUGGESTIONS, kToolbarTypeWebAll,
125 0, nil },
126 { IDS_IOS_TOOLS_MENU_RECENT_TABS, kToolsMenuOtherDevicesId,
127 IDC_SHOW_OTHER_DEVICES, kToolbarTypeWebAll,
128 kVisibleNotIncognitoOnly, nil },
129 { IDS_HISTORY_SHOW_HISTORY, kToolsMenuHistoryId,
130 IDC_SHOW_HISTORY, kToolbarTypeWebAll,
131 0, nil },
132 { IDS_IOS_OPTIONS_REPORT_AN_ISSUE, kToolsMenuReportAnIssueId,
133 IDC_REPORT_AN_ISSUE, kToolbarTypeAll,
134 0, nil },
135 { IDS_IOS_TOOLS_MENU_FIND_IN_PAGE, kToolsMenuFindInPageId,
136 IDC_FIND, kToolbarTypeWebAll,
137 0, nil },
138 { IDS_IOS_TOOLS_MENU_REQUEST_DESKTOP_SITE, kToolsMenuRequestDesktopId,
139 IDC_REQUEST_DESKTOP_SITE, kToolbarTypeWebAll,
140 0, nil },
141 { IDS_IOS_TOOLS_MENU_READER_MODE, kToolsMenuReaderMode,
142 IDC_READER_MODE, kToolbarTypeWebAll,
143 0, nil },
144 { IDS_IOS_TOOLS_MENU_SETTINGS, kToolsMenuSettingsId,
145 IDC_OPTIONS, kToolbarTypeAll,
146 0, nil },
147 { IDS_IOS_TOOLS_MENU_HELP_MOBILE, kToolsMenuHelpId,
148 IDC_HELP_PAGE_VIA_MENU, kToolbarTypeWebAll,
149 0, nil },
150 // clang-format on
151 };
152
153 NS_INLINE BOOL ItemShouldBeVisible(const MenuItemInfo& item,
154 BOOL incognito,
155 kToolbarType toolbarType) {
156 if (!(item.toolbar_types & toolbarType))
157 return NO;
158
159 if (incognito && (item.visibility & kVisibleNotIncognitoOnly))
160 return NO;
161
162 if (!incognito && (item.visibility & kVisibleIncognitoOnly))
163 return NO;
164
165 if (item.title_id == IDS_IOS_TOOLBAR_SHOW_TABS) {
166 if (!IsIPadIdiom()) {
167 return NO;
168 }
169 }
170
171 if (item.title_id == IDS_IOS_TOOLS_MENU_READER_MODE) {
172 if (!experimental_flags::IsReaderModeEnabled()) {
173 return NO;
174 }
175 }
176
177 if (item.title_id == IDS_IOS_TOOLS_MENU_READING_LIST) {
178 if (!reading_list::switches::IsReadingListEnabled()) {
179 return NO;
180 }
181 }
182
183 if (item.title_id == IDS_IOS_TOOLS_MENU_SUGGESTIONS) {
184 if (!experimental_flags::IsSuggestionsUIEnabled()) {
185 return NO;
186 }
187 }
188
189 if (item.title_id == IDS_IOS_OPTIONS_REPORT_AN_ISSUE) {
190 if (!ios::GetChromeBrowserProvider()
191 ->GetUserFeedbackProvider()
192 ->IsUserFeedbackEnabled()) {
193 return NO;
194 }
195 }
196
197 return YES;
198 }
199
200 NS_INLINE void AnimateInViews(NSArray* views, 44 NS_INLINE void AnimateInViews(NSArray* views,
201 CGFloat initialX, 45 CGFloat initialX,
202 CGFloat initialY) { 46 CGFloat initialY) {
203 [views enumerateObjectsUsingBlock:^(UIView* view, NSUInteger index, 47 [views enumerateObjectsUsingBlock:^(UIView* view, NSUInteger index,
204 BOOL* stop) { 48 BOOL* stop) {
205 CGFloat beginTime = index * .035; 49 CGFloat beginTime = index * .035;
206 CABasicAnimation* transformAnimation = 50 CABasicAnimation* transformAnimation =
207 [CABasicAnimation animationWithKeyPath:@"transform"]; 51 [CABasicAnimation animationWithKeyPath:@"transform"];
208 [transformAnimation 52 [transformAnimation
209 setFromValue:[NSValue 53 setFromValue:[NSValue
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 ReadingListMenuNotificationDelegate> { 99 ReadingListMenuNotificationDelegate> {
256 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewController; 100 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewController;
257 BOOL _waitForInk; 101 BOOL _waitForInk;
258 // Weak pointer to ReadingListMenuNotifier, used to set the starting values 102 // Weak pointer to ReadingListMenuNotifier, used to set the starting values
259 // for the reading list badge. 103 // for the reading list badge.
260 base::WeakNSObject<ReadingListMenuNotifier> _readingListMenuNotifier; 104 base::WeakNSObject<ReadingListMenuNotifier> _readingListMenuNotifier;
261 } 105 }
262 @property(nonatomic, retain) ToolsMenuCollectionView* menuView; 106 @property(nonatomic, retain) ToolsMenuCollectionView* menuView;
263 @property(nonatomic, retain) MDCInkView* touchFeedbackView; 107 @property(nonatomic, retain) MDCInkView* touchFeedbackView;
264 @property(nonatomic, retain) NSMutableArray* menuItems; 108 @property(nonatomic, retain) NSMutableArray* menuItems;
265 @property(nonatomic, assign) kToolbarType toolbarType; 109 @property(nonatomic, assign) ToolbarType toolbarType;
266 110
267 // Get the reading list cell. 111 // Get the reading list cell.
268 - (ReadingListMenuViewCell*)readingListCell; 112 - (ReadingListMenuViewCell*)readingListCell;
269 @end 113 @end
270 114
271 @implementation ToolsMenuViewController 115 @implementation ToolsMenuViewController
272 116
273 @synthesize menuView = _menuView; 117 @synthesize menuView = _menuView;
274 @synthesize isCurrentPageBookmarked = _isCurrentPageBookmarked; 118 @synthesize isCurrentPageBookmarked = _isCurrentPageBookmarked;
275 @synthesize touchFeedbackView = _touchFeedbackView; 119 @synthesize touchFeedbackView = _touchFeedbackView;
276 @synthesize isTabLoading = _isTabLoading; 120 @synthesize isTabLoading = _isTabLoading;
277 @synthesize toolbarType = _toolbarType; 121 @synthesize toolbarType = _toolbarType;
278 @synthesize menuItems = _menuItems; 122 @synthesize menuItems = _menuItems;
279 @synthesize delegate = _delegate; 123 @synthesize delegate = _delegate;
280 124
281 #pragma mark Public methods 125 #pragma mark Public methods
282 126
283 - (CGFloat)optimalHeight:(CGFloat)suggestedHeight { 127 - (CGFloat)optimalHeight:(CGFloat)suggestedHeight {
284 NSInteger numberOfItems = [self.menuItems count]; 128 NSInteger numberOfItems = [self.menuItems count];
285 if (_toolbarType == kToolbarTypeWebiPhone) { 129 if (_toolbarType == ToolbarTypeWebiPhone) {
286 // Account for the height of the first row, not included in |menuItems|. 130 // Account for the height of the first row, not included in |menuItems|.
287 numberOfItems++; 131 numberOfItems++;
288 } 132 }
289 CGFloat maxItems = suggestedHeight / kMenuItemHeight; 133 CGFloat maxItems = suggestedHeight / kMenuItemHeight;
290 if (maxItems >= numberOfItems) { 134 if (maxItems >= numberOfItems) {
291 return numberOfItems * kMenuItemHeight; 135 return numberOfItems * kMenuItemHeight;
292 } else { 136 } else {
293 const CGFloat halfHeight = kMenuItemHeight / 2; 137 const CGFloat halfHeight = kMenuItemHeight / 2;
294 return round(maxItems) * kMenuItemHeight - halfHeight; 138 return round(maxItems) * kMenuItemHeight - halfHeight;
295 } 139 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 [[toolsCell reloadButton] setHidden:isTabLoading]; 205 [[toolsCell reloadButton] setHidden:isTabLoading];
362 } 206 }
363 207
364 - (void)initializeMenu:(ToolsMenuContext*)context { 208 - (void)initializeMenu:(ToolsMenuContext*)context {
365 if (context.readingListMenuNotifier) { 209 if (context.readingListMenuNotifier) {
366 _readingListMenuNotifier.reset(context.readingListMenuNotifier); 210 _readingListMenuNotifier.reset(context.readingListMenuNotifier);
367 [context.readingListMenuNotifier setDelegate:self]; 211 [context.readingListMenuNotifier setDelegate:self];
368 } 212 }
369 213
370 if (IsIPadIdiom()) { 214 if (IsIPadIdiom()) {
371 _toolbarType = context.hasNoOpenedTabs 215 _toolbarType =
372 ? kToolbarTypeNoTabsiPad 216 context.hasNoOpenedTabs
373 : (!IsCompactTablet() ? kToolbarTypeWebiPad 217 ? ToolbarTypeNoTabsiPad
374 : kToolbarTypeWebiPhone); 218 : (!IsCompactTablet() ? ToolbarTypeWebiPad : ToolbarTypeWebiPhone);
375 } else { 219 } else {
376 // kOptionInTabSwitcher option must be enabled on iPhone with 220 // kOptionInTabSwitcher option must be enabled on iPhone with
377 // no opened tabs. 221 // no opened tabs.
378 DCHECK(!context.hasNoOpenedTabs || context.isInTabSwitcher); 222 DCHECK(!context.hasNoOpenedTabs || context.isInTabSwitcher);
379 _toolbarType = context.isInTabSwitcher ? kToolbarTypeSwitcheriPhone 223 _toolbarType = context.isInTabSwitcher ? ToolbarTypeSwitcheriPhone
380 : kToolbarTypeWebiPhone; 224 : ToolbarTypeWebiPhone;
381 } 225 }
382 226
383 // Build the menu, adding all relevant items. 227 // Build the menu, adding all relevant items.
384 NSMutableArray* menu = [NSMutableArray array]; 228 NSMutableArray* menu = [NSMutableArray array];
385 229
386 for (size_t i = 0; i < arraysize(itemInfoList); ++i) { 230 for (size_t i = 0; i < arraysize(itemInfoList); ++i) {
387 const MenuItemInfo& item = itemInfoList[i]; 231 const MenuItemInfo& item = itemInfoList[i];
388 if (!ItemShouldBeVisible(item, context.isInIncognito, _toolbarType)) 232 if (!ToolsMenuItemShouldBeVisible(item, context.isInIncognito,
233 _toolbarType))
389 continue; 234 continue;
390 235
391 NSString* title = l10n_util::GetNSStringWithFixup(item.title_id); 236 NSString* title = l10n_util::GetNSStringWithFixup(item.title_id);
392 Class itemClass = 237 Class itemClass =
393 item.item_class ? item.item_class : [ToolsMenuViewItem class]; 238 item.item_class ? item.item_class : [ToolsMenuViewItem class];
394 // Sanity check that the class is a useful one. 239 // Sanity check that the class is a useful one.
395 DCHECK([itemClass respondsToSelector:@selector(menuItemWithTitle: 240 DCHECK([itemClass respondsToSelector:@selector(menuItemWithTitle:
396 accessibilityIdentifier: 241 accessibilityIdentifier:
397 command:)]); 242 command:)]);
398 [menu addObject:[itemClass menuItemWithTitle:title 243 [menu addObject:[itemClass menuItemWithTitle:title
399 accessibilityIdentifier:item.accessibility_id 244 accessibilityIdentifier:item.accessibility_id
400 command:item.command_id]]; 245 command:item.command_id]];
401 } 246 }
402 247
403 #if !defined(NDEBUG) 248 #if !defined(NDEBUG)
404 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; 249 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
405 if ((_toolbarType & kToolbarTypeWebAll) && 250 if ((_toolbarType & ToolbarTypeWebAll) &&
406 [standardDefaults boolForKey:@"DevViewSource"]) { 251 [standardDefaults boolForKey:@"DevViewSource"]) {
407 // Debug menu, not localized, only visible if turned on by a default. 252 // Debug menu, not localized, only visible if turned on by a default.
408 [menu addObject:[self createViewSourceItem]]; 253 [menu addObject:[self createViewSourceItem]];
409 } 254 }
410 #endif // !defined(NDEBUG) 255 #endif // !defined(NDEBUG)
411 256
412 [self setMenuItems:menu]; 257 [self setMenuItems:menu];
413 258
414 // Disable IDC_CLOSE_ALL_TABS menu item if on phone with no tabs. 259 // Disable IDC_CLOSE_ALL_TABS menu item if on phone with no tabs.
415 if (!IsIPadIdiom()) { 260 if (!IsIPadIdiom()) {
(...skipping 25 matching lines...) Expand all
441 if ([visibleCell isKindOfClass:[ReadingListMenuViewCell class]]) 286 if ([visibleCell isKindOfClass:[ReadingListMenuViewCell class]])
442 return visibleCell; 287 return visibleCell;
443 } 288 }
444 289
445 return nil; 290 return nil;
446 } 291 }
447 292
448 - (NSInteger)dataIndexForIndexPath:(NSIndexPath*)path { 293 - (NSInteger)dataIndexForIndexPath:(NSIndexPath*)path {
449 NSInteger item = [path item]; 294 NSInteger item = [path item];
450 295
451 if (_toolbarType == kToolbarTypeWebiPhone) 296 if (_toolbarType == ToolbarTypeWebiPhone)
452 --item; 297 --item;
453 298
454 return item; 299 return item;
455 } 300 }
456 301
457 #pragma mark - UIViewController Overrides 302 #pragma mark - UIViewController Overrides
458 303
459 - (instancetype)initWithNibName:(NSString*)nibNameOrNil 304 - (instancetype)initWithNibName:(NSString*)nibNameOrNil
460 bundle:(NSBundle*)nibBundleOrNil { 305 bundle:(NSBundle*)nibBundleOrNil {
461 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 306 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 if (center1.y < center2.y) 396 if (center1.y < center2.y)
552 return NSOrderedAscending; 397 return NSOrderedAscending;
553 398
554 if (center1.y > center2.y) 399 if (center1.y > center2.y)
555 return NSOrderedDescending; 400 return NSOrderedDescending;
556 401
557 return NSOrderedSame; 402 return NSOrderedSame;
558 }]; 403 }];
559 404
560 ToolsMenuViewToolsCell* toolsCell = nil; 405 ToolsMenuViewToolsCell* toolsCell = nil;
561 if (_toolbarType == kToolbarTypeWebiPhone) { 406 if (_toolbarType == ToolbarTypeWebiPhone) {
562 toolsCell = [visibleCells firstObject]; 407 toolsCell = [visibleCells firstObject];
563 if ([toolsCell isKindOfClass:[ToolsMenuViewToolsCell class]]) { 408 if ([toolsCell isKindOfClass:[ToolsMenuViewToolsCell class]]) {
564 visibleCells = [visibleCells 409 visibleCells = [visibleCells
565 subarrayWithRange:NSMakeRange(1, [visibleCells count] - 1)]; 410 subarrayWithRange:NSMakeRange(1, [visibleCells count] - 1)];
566 } else { 411 } else {
567 toolsCell = nil; 412 toolsCell = nil;
568 } 413 }
569 } 414 }
570 415
571 [CATransaction begin]; 416 [CATransaction begin];
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 [_delegate commandWasSelected:[menuItem tag]]; 536 [_delegate commandWasSelected:[menuItem tag]];
692 [self chromeExecuteCommand:menuItem]; 537 [self chromeExecuteCommand:menuItem];
693 }); 538 });
694 } 539 }
695 540
696 #pragma mark - UICollectionViewDataSource Implementation 541 #pragma mark - UICollectionViewDataSource Implementation
697 542
698 - (NSInteger)collectionView:(UICollectionView*)view 543 - (NSInteger)collectionView:(UICollectionView*)view
699 numberOfItemsInSection:(NSInteger)section { 544 numberOfItemsInSection:(NSInteger)section {
700 NSInteger numberOfItems = [_menuItems count]; 545 NSInteger numberOfItems = [_menuItems count];
701 if (_toolbarType == kToolbarTypeWebiPhone) 546 if (_toolbarType == ToolbarTypeWebiPhone)
702 ++numberOfItems; 547 ++numberOfItems;
703 548
704 return numberOfItems; 549 return numberOfItems;
705 } 550 }
706 551
707 - (UICollectionViewCell*)collectionView:(UICollectionView*)view 552 - (UICollectionViewCell*)collectionView:(UICollectionView*)view
708 cellForItemAtIndexPath:(NSIndexPath*)path { 553 cellForItemAtIndexPath:(NSIndexPath*)path {
709 NSInteger item = [self dataIndexForIndexPath:path]; 554 NSInteger item = [self dataIndexForIndexPath:path];
710 if (item < 0) { 555 if (item < 0) {
711 ToolsMenuViewToolsCell* cell = 556 ToolsMenuViewToolsCell* cell =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 592
748 - (void)unreadCountChanged:(NSInteger)unreadCount { 593 - (void)unreadCountChanged:(NSInteger)unreadCount {
749 [[self readingListCell] updateBadgeCount:unreadCount animated:YES]; 594 [[self readingListCell] updateBadgeCount:unreadCount animated:YES];
750 } 595 }
751 596
752 - (void)unseenStateChanged:(BOOL)unseenItemsExist { 597 - (void)unseenStateChanged:(BOOL)unseenItemsExist {
753 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES]; 598 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES];
754 } 599 }
755 600
756 @end 601 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/tools_menu/tools_menu_model.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698