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 #ifndef IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_HANDSET_VIEW_CONTROLLER_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_HANDSET_VIEW_CONTROLLER_H_ |
6 #define IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_HANDSET_VIEW_CONTROLLER_H_ | 6 #define IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_HANDSET_VIEW_CONTROLLER_H_ |
7 | 7 |
| 8 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h" |
| 9 |
8 #import <UIKit/UIKit.h> | 10 #import <UIKit/UIKit.h> |
9 | 11 |
10 #include <set> | 12 #include <set> |
11 #include <vector> | 13 #include <vector> |
12 | 14 |
13 @class BookmarkHomeHandsetViewController; | 15 @class BookmarkHomeHandsetViewController; |
14 @class BookmarkCollectionView; | 16 @class BookmarkCollectionView; |
15 class GURL; | 17 class GURL; |
16 @protocol UrlLoader; | 18 @protocol UrlLoader; |
17 | 19 |
18 namespace bookmarks { | 20 namespace bookmarks { |
19 class BookmarkModel; | |
20 class BookmarkNode; | 21 class BookmarkNode; |
21 } // namespace bookmarks | 22 } // namespace bookmarks |
22 | 23 |
23 namespace ios { | |
24 class ChromeBrowserState; | |
25 } // namespace ios | |
26 | |
27 @protocol BookmarkHomeHandsetViewControllerDelegate | 24 @protocol BookmarkHomeHandsetViewControllerDelegate |
28 // The view controller wants to be dismissed. | 25 // The view controller wants to be dismissed. |
29 // If |url| != GURL(), then the user has selected |url| for navigation. | 26 // If |url| != GURL(), then the user has selected |url| for navigation. |
30 - (void)bookmarkHomeHandsetViewControllerWantsDismissal: | 27 - (void)bookmarkHomeHandsetViewControllerWantsDismissal: |
31 (BookmarkHomeHandsetViewController*)controller | 28 (BookmarkHomeHandsetViewController*)controller |
32 navigationToUrl:(const GURL&)url; | 29 navigationToUrl:(const GURL&)url; |
33 @end | 30 @end |
34 | 31 |
35 // Navigate/edit the bookmark hierarchy on a handset. | 32 // Navigate/edit the bookmark hierarchy on a handset. |
36 @interface BookmarkHomeHandsetViewController : UIViewController { | 33 @interface BookmarkHomeHandsetViewController : BookmarkHomeViewController { |
37 @protected | 34 @protected |
38 // The following 2 ivars both represent the set of nodes being edited. | 35 // The following 2 ivars both represent the set of nodes being edited. |
39 // The set is for fast lookup. | 36 // The set is for fast lookup. |
40 // The vector maintains the order that edit nodes were added. | 37 // The vector maintains the order that edit nodes were added. |
41 // Use the relevant instance methods to modify these two ivars in tandem. | 38 // Use the relevant instance methods to modify these two ivars in tandem. |
42 // DO NOT modify these two ivars directly. | 39 // DO NOT modify these two ivars directly. |
43 std::set<const bookmarks::BookmarkNode*> _editNodes; | 40 std::set<const bookmarks::BookmarkNode*> _editNodes; |
44 std::vector<const bookmarks::BookmarkNode*> _editNodesOrdered; | 41 std::vector<const bookmarks::BookmarkNode*> _editNodesOrdered; |
45 } | 42 } |
46 // Designated initializer. | |
47 - (instancetype)initWithLoader:(id<UrlLoader>)loader | |
48 browserState:(ios::ChromeBrowserState*)browserState; | |
49 | 43 |
50 #pragma mark - Properties Relevant To Presenters | 44 #pragma mark - Properties Relevant To Presenters |
51 | 45 |
52 @property(nonatomic, weak) id<BookmarkHomeHandsetViewControllerDelegate> | 46 @property(nonatomic, weak) id<BookmarkHomeHandsetViewControllerDelegate> |
53 delegate; | 47 delegate; |
54 | 48 |
55 #pragma mark - Properties | 49 #pragma mark - Properties |
56 // Whether the view controller is in editing mode. | 50 // Whether the view controller is in editing mode. |
57 @property(nonatomic, assign, readonly) BOOL editing; | 51 @property(nonatomic, assign, readonly) BOOL editing; |
58 // The set of selected index paths for edition. | 52 // The set of selected index paths for edition. |
59 @property(nonatomic, strong, readonly) NSMutableArray* editIndexPaths; | 53 @property(nonatomic, strong, readonly) NSMutableArray* editIndexPaths; |
60 @property(nonatomic, assign, readonly) bookmarks::BookmarkModel* bookmarks; | |
61 @property(nonatomic, weak, readonly) id<UrlLoader> loader; | |
62 @property(nonatomic, assign, readonly) ios::ChromeBrowserState* browserState; | |
63 | 54 |
64 #pragma mark - Relevant Methods | 55 #pragma mark - Relevant Methods |
65 // Replaces |_editNodes| and |_editNodesOrdered| with new container objects. | 56 // Replaces |_editNodes| and |_editNodesOrdered| with new container objects. |
66 - (void)resetEditNodes; | 57 - (void)resetEditNodes; |
67 // Adds |node| and |indexPath| if it isn't already present. | 58 // Adds |node| and |indexPath| if it isn't already present. |
68 - (void)insertEditNode:(const bookmarks::BookmarkNode*)node | 59 - (void)insertEditNode:(const bookmarks::BookmarkNode*)node |
69 atIndexPath:(NSIndexPath*)indexPath; | 60 atIndexPath:(NSIndexPath*)indexPath; |
70 // Removes |node| and |indexPath| if it's present. | 61 // Removes |node| and |indexPath| if it's present. |
71 - (void)removeEditNode:(const bookmarks::BookmarkNode*)node | 62 - (void)removeEditNode:(const bookmarks::BookmarkNode*)node |
72 atIndexPath:(NSIndexPath*)indexPath; | 63 atIndexPath:(NSIndexPath*)indexPath; |
73 | 64 |
74 // This method updates the property, and resets the edit nodes. | 65 // This method updates the property, and resets the edit nodes. |
75 - (void)setEditing:(BOOL)editing animated:(BOOL)animated; | 66 - (void)setEditing:(BOOL)editing animated:(BOOL)animated; |
76 | 67 |
77 // Dismisses any modal interaction elements. The base implementation does | 68 // Dismisses any modal interaction elements. The base implementation does |
78 // nothing. | 69 // nothing. |
79 - (void)dismissModals:(BOOL)animated; | 70 - (void)dismissModals:(BOOL)animated; |
80 | 71 |
81 @end | 72 @end |
82 | 73 |
83 @interface BookmarkHomeHandsetViewController (ExposedForTesting) | 74 @interface BookmarkHomeHandsetViewController (ExposedForTesting) |
84 // Creates the default view to show all bookmarks, if it doesn't already exist. | 75 // Creates the default view to show all bookmarks, if it doesn't already exist. |
85 - (void)ensureAllViewExists; | 76 - (void)ensureAllViewExists; |
86 - (const std::set<const bookmarks::BookmarkNode*>&)editNodes; | 77 - (const std::set<const bookmarks::BookmarkNode*>&)editNodes; |
87 - (void)setEditNodes:(const std::set<const bookmarks::BookmarkNode*>&)editNodes; | 78 - (void)setEditNodes:(const std::set<const bookmarks::BookmarkNode*>&)editNodes; |
88 @end | 79 @end |
89 | 80 |
90 #endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_HANDSET_VIEW_CONTROLLER
_H_ | 81 #endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_HOME_HANDSET_VIEW_CONTROLLER
_H_ |
OLD | NEW |