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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h

Issue 2929993002: Refactoring bookmark viewcontrollers (Closed)
Patch Set: Created 3 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_VIEW_CONTROLLER_H_
6 #define IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_VIEW_CONTROLLER_H_
7
8 #import "ios/chrome/browser/ui/ntp/new_tab_page_panel_protocol.h"
9
10 #include <set>
11 #include <vector>
12
13 @class BookmarkCollectionView;
14 class GURL;
15 @protocol UrlLoader;
16
17 namespace bookmarks {
18 class BookmarkModel;
19 class BookmarkNode;
20 } // namespace bookmarks
21
22 namespace ios {
23 class ChromeBrowserState;
24 } // namespace ios
25
26 @class BookmarkHomeViewController;
27 @protocol BookmarkHomeViewControllerDelegate
28 // The view controller wants to be dismissed.
29 // If |url| != GURL(), then the user has selected |url| for navigation.
30 - (void)bookmarkHomeViewControllerWantsDismissal:
31 (BookmarkHomeViewController*)controller
32 navigationToUrl:(const GURL&)url;
33 @end
34
35 // Full screen view controller for browsing the bookmark hierarchy, batch
36 // editing bookmarks, and navigating to a single bookmark.
37 // Abstracty base class that provides common, non-UI functionality.
38 @interface BookmarkHomeViewController : UIViewController {
39 @protected
40 // The following 2 ivars both represent the set of nodes being edited.
41 // The set is for fast lookup.
42 // The vector maintains the order that edit nodes were added.
43 // Use the relevant instance methods to modify these two ivars in tandem.
44 // DO NOT modify these two ivars directly.
45 std::set<const bookmarks::BookmarkNode*> _editNodes;
46 std::vector<const bookmarks::BookmarkNode*> _editNodesOrdered;
47 }
48 // Designated initializer.
49 - (instancetype)initWithLoader:(id<UrlLoader>)loader
50 browserState:(ios::ChromeBrowserState*)browserState;
51
52 #pragma mark - Properties Relevant To Presenters
53
54 @property(nonatomic, weak) id<BookmarkHomeViewControllerDelegate> delegate;
55
56 #pragma mark - Properties Relevant To Subclasses
57
58 // Whether the view controller is in editing mode.
59 @property(nonatomic, assign, readonly) BOOL editing;
60 // The set of selected index paths for edition.
61 @property(nonatomic, strong, readonly) NSMutableArray* editIndexPaths;
62 @property(nonatomic, assign, readonly) bookmarks::BookmarkModel* bookmarks;
63 @property(nonatomic, weak, readonly) id<UrlLoader> loader;
64 @property(nonatomic, assign, readonly) ios::ChromeBrowserState* browserState;
65
66 #pragma mark - Relevant Methods
67 // Replaces |_editNodes| and |_editNodesOrdered| with new container objects.
68 - (void)resetEditNodes;
69 // Adds |node| and |indexPath| if it isn't already present.
70 - (void)insertEditNode:(const bookmarks::BookmarkNode*)node
71 atIndexPath:(NSIndexPath*)indexPath;
72 // Removes |node| and |indexPath| if it's present.
73 - (void)removeEditNode:(const bookmarks::BookmarkNode*)node
74 atIndexPath:(NSIndexPath*)indexPath;
75
76 #pragma mark - Methods Intended For Subclass Override
77
78 // Subclasses must call the super class implementation.
79 // This method updates the property, and resets the edit nodes.
80 - (void)setEditing:(BOOL)editing animated:(BOOL)animated;
81
82 // Dismisses any modal interaction elements. The base implementation does
83 // nothing.
84 - (void)dismissModals:(BOOL)animated;
85
86 @end
87
88 @interface BookmarkHomeViewController (PrivateAPIExposedForTesting)
89 - (const std::set<const bookmarks::BookmarkNode*>&)editNodes;
90 - (void)setEditNodes:(const std::set<const bookmarks::BookmarkNode*>&)editNodes;
91 @end
92
93 #endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698