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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_menu_view.mm

Issue 2662473003: Removing "All Bookmarks" (Closed)
Patch Set: feedback Created 3 years, 10 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
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/bookmarks/bookmark_menu_view.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_menu_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/mac/objc_property_releaser.h" 10 #include "base/mac/objc_property_releaser.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 const BookmarkNode* mobileBookmarks = self.bookmarkModel->mobile_node(); 131 const BookmarkNode* mobileBookmarks = self.bookmarkModel->mobile_node();
132 const BookmarkNode* bookmarkBar = self.bookmarkModel->bookmark_bar_node(); 132 const BookmarkNode* bookmarkBar = self.bookmarkModel->bookmark_bar_node();
133 const BookmarkNode* otherBookmarks = self.bookmarkModel->other_node(); 133 const BookmarkNode* otherBookmarks = self.bookmarkModel->other_node();
134 134
135 // The first section is always visible. 135 // The first section is always visible.
136 base::scoped_nsobject<NSMutableArray> topSection( 136 base::scoped_nsobject<NSMutableArray> topSection(
137 [[NSMutableArray alloc] init]); 137 [[NSMutableArray alloc] init]);
138 [self.menuItems addObject:topSection]; 138 [self.menuItems addObject:topSection];
139 139
140 if (experimental_flags::IsAllBookmarksEnabled()) { 140 // Mobile bookmark is shown even if empty.
141 // All Items is always visible. 141 [topSection
142 [topSection addObject:[BookmarkMenuItem allMenuItem]]; 142 addObject:[BookmarkMenuItem folderMenuItemForNode:mobileBookmarks
143 } 143 rootAncestor:mobileBookmarks]];
144 // Bookmarks Bar, Mobile Bookmarks and Other Bookmarks are special folders and 144 // Bookmarks Bar and Other Bookmarks are special folders and are shown at the
145 // are shown at the top if they contain anything. 145 // top if they contain anything.
146 if (!mobileBookmarks->empty() ||
147 !experimental_flags::IsAllBookmarksEnabled()) {
148 [topSection
149 addObject:[BookmarkMenuItem folderMenuItemForNode:mobileBookmarks
150 rootAncestor:mobileBookmarks]];
151 }
152 if (!bookmarkBar->empty()) { 146 if (!bookmarkBar->empty()) {
153 [topSection addObject:[BookmarkMenuItem folderMenuItemForNode:bookmarkBar 147 [topSection addObject:[BookmarkMenuItem folderMenuItemForNode:bookmarkBar
154 rootAncestor:bookmarkBar]]; 148 rootAncestor:bookmarkBar]];
155 } 149 }
156 if (!otherBookmarks->empty()) { 150 if (!otherBookmarks->empty()) {
157 [topSection 151 [topSection
158 addObject:[BookmarkMenuItem folderMenuItemForNode:otherBookmarks 152 addObject:[BookmarkMenuItem folderMenuItemForNode:otherBookmarks
159 rootAncestor:otherBookmarks]]; 153 rootAncestor:otherBookmarks]];
160 } 154 }
161 155
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return; 255 return;
262 } 256 }
263 257
264 if (parentFolder == self.primaryMenuItem.folder || !node->is_folder()) { 258 if (parentFolder == self.primaryMenuItem.folder || !node->is_folder()) {
265 // A child of the selected folder has been deleted or a url not visible in 259 // A child of the selected folder has been deleted or a url not visible in
266 // the UI right now has been deleted. Nothing to do as the menu itself needs 260 // the UI right now has been deleted. Nothing to do as the menu itself needs
267 // no change. 261 // no change.
268 return; 262 return;
269 } 263 }
270 264
271 if (node == self.primaryMenuItem.rootAncestor) {
272 // The deleted node is the root node of the current selected folder. Move to
273 // all items.
274 self.primaryMenuItem = [BookmarkMenuItem allMenuItem];
275 [self.delegate bookmarkMenuView:self selectedMenuItem:self.primaryMenuItem];
276 [self reloadData];
277 return;
278 }
279
280 const BookmarkNode* root = 265 const BookmarkNode* root =
281 RootLevelFolderForNode(parentFolder, self.bookmarkModel); 266 RootLevelFolderForNode(parentFolder, self.bookmarkModel);
282 267
283 if (root != self.primaryMenuItem.rootAncestor) { 268 if (root != self.primaryMenuItem.rootAncestor) {
284 // The deleted folder is not in the same hierarchy as the current selected 269 // The deleted folder is not in the same hierarchy as the current selected
285 // folder, there is nothing to reload unless the deleted folder is a root 270 // folder, there is nothing to reload unless the deleted folder is a root
286 // node. 271 // node.
287 if (!root) 272 if (!root)
288 [self reloadData]; 273 [self reloadData];
289 return; 274 return;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 viewForFooterInSection:(NSInteger)section { 378 viewForFooterInSection:(NSInteger)section {
394 return [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; 379 return [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
395 } 380 }
396 381
397 #pragma mark MDCInkTouchControllerDelegate 382 #pragma mark MDCInkTouchControllerDelegate
398 383
399 - (BOOL)inkTouchController:(MDCInkTouchController*)inkTouchController 384 - (BOOL)inkTouchController:(MDCInkTouchController*)inkTouchController
400 shouldProcessInkTouchesAtTouchLocation:(CGPoint)location { 385 shouldProcessInkTouchesAtTouchLocation:(CGPoint)location {
401 NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:location]; 386 NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:location];
402 BookmarkMenuItem* menuItem = [self menuItemAtIndexPath:indexPath]; 387 BookmarkMenuItem* menuItem = [self menuItemAtIndexPath:indexPath];
403 return menuItem.type == bookmarks::MenuItemAll || 388 return menuItem.type == bookmarks::MenuItemFolder;
404 menuItem.type == bookmarks::MenuItemFolder;
405 } 389 }
406 390
407 - (MDCInkView*)inkTouchController:(MDCInkTouchController*)inkTouchController 391 - (MDCInkView*)inkTouchController:(MDCInkTouchController*)inkTouchController
408 inkViewAtTouchLocation:(CGPoint)location { 392 inkViewAtTouchLocation:(CGPoint)location {
409 NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:location]; 393 NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:location];
410 BookmarkMenuCell* cell = base::mac::ObjCCastStrict<BookmarkMenuCell>( 394 BookmarkMenuCell* cell = base::mac::ObjCCastStrict<BookmarkMenuCell>(
411 [self.tableView cellForRowAtIndexPath:indexPath]); 395 [self.tableView cellForRowAtIndexPath:indexPath]);
412 return cell.inkView; 396 return cell.inkView;
413 } 397 }
414 398
415 #pragma mark Public Methods 399 #pragma mark Public Methods
416 400
417 - (void)updatePrimaryMenuItem:(BookmarkMenuItem*)menuItem { 401 - (void)updatePrimaryMenuItem:(BookmarkMenuItem*)menuItem {
418 if ([self.primaryMenuItem isEqual:menuItem]) 402 if ([self.primaryMenuItem isEqual:menuItem])
419 return; 403 return;
420 404
421 self.primaryMenuItem = menuItem; 405 self.primaryMenuItem = menuItem;
422 [self.tableView reloadData]; 406 [self.tableView reloadData];
423 } 407 }
424 408
425 - (void)setScrollsToTop:(BOOL)scrollsToTop { 409 - (void)setScrollsToTop:(BOOL)scrollsToTop {
426 self.tableView.scrollsToTop = scrollsToTop; 410 self.tableView.scrollsToTop = scrollsToTop;
427 } 411 }
428 412
429 @end 413 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_menu_item.mm ('k') | ios/chrome/browser/ui/bookmarks/bookmark_position_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698