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

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

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