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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_editor_base_controller.h

Issue 865163003: bookmarks: Move BookmarkNode into 'bookmarks' namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enhanced_bookmarks fix Created 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_EDITOR_BASE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_EDITOR_BASE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_EDITOR_BASE_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_EDITOR_BASE_CONTROLLER_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
(...skipping 16 matching lines...) Expand all
27 // implementation, that function will need to be update. 27 // implementation, that function will need to be update.
28 @interface BookmarkEditorBaseController : NSWindowController { 28 @interface BookmarkEditorBaseController : NSWindowController {
29 @private 29 @private
30 IBOutlet NSButton* newFolderButton_; 30 IBOutlet NSButton* newFolderButton_;
31 IBOutlet NSButton* okButton_; // Used for unit testing only. 31 IBOutlet NSButton* okButton_; // Used for unit testing only.
32 IBOutlet NSTreeController* folderTreeController_; 32 IBOutlet NSTreeController* folderTreeController_;
33 IBOutlet NSOutlineView* folderTreeView_; 33 IBOutlet NSOutlineView* folderTreeView_;
34 34
35 NSWindow* parentWindow_; // weak 35 NSWindow* parentWindow_; // weak
36 Profile* profile_; // weak 36 Profile* profile_; // weak
37 const BookmarkNode* parentNode_; // weak; owned by the model 37 const bookmarks::BookmarkNode* parentNode_; // weak; owned by the model
38 GURL url_; // This and title_ are only used for new urls. 38 GURL url_; // This and title_ are only used for new urls.
39 base::string16 title_; 39 base::string16 title_;
40 BookmarkEditor::Configuration configuration_; 40 BookmarkEditor::Configuration configuration_;
41 NSString* initialName_; 41 NSString* initialName_;
42 NSString* displayName_; // Bound to a text field in the dialog. 42 NSString* displayName_; // Bound to a text field in the dialog.
43 BOOL creatingNewFolders_; // True while in createNewFolders. 43 BOOL creatingNewFolders_; // True while in createNewFolders.
44 // An array of BookmarkFolderInfo where each item describes a folder in the 44 // An array of BookmarkFolderInfo where each item describes a folder in the
45 // BookmarkNode structure. 45 // BookmarkNode structure.
46 base::scoped_nsobject<NSArray> folderTreeArray_; 46 base::scoped_nsobject<NSArray> folderTreeArray_;
47 // Bound to the table view giving a path to the current selections, of which 47 // Bound to the table view giving a path to the current selections, of which
48 // there should only ever be one. 48 // there should only ever be one.
49 base::scoped_nsobject<NSArray> tableSelectionPaths_; 49 base::scoped_nsobject<NSArray> tableSelectionPaths_;
50 // C++ bridge object that observes the BookmarkModel for me. 50 // C++ bridge object that observes the BookmarkModel for me.
51 scoped_ptr<BookmarkEditorBaseControllerBridge> observer_; 51 scoped_ptr<BookmarkEditorBaseControllerBridge> observer_;
52 } 52 }
53 53
54 @property(nonatomic, copy) NSString* initialName; 54 @property(nonatomic, copy) NSString* initialName;
55 @property(nonatomic, copy) NSString* displayName; 55 @property(nonatomic, copy) NSString* displayName;
56 @property(nonatomic, retain, readonly) NSArray* folderTreeArray; 56 @property(nonatomic, retain, readonly) NSArray* folderTreeArray;
57 @property(nonatomic, copy) NSArray* tableSelectionPaths; 57 @property(nonatomic, copy) NSArray* tableSelectionPaths;
58 58
59 // Designated initializer. Derived classes should call through to this init. 59 // Designated initializer. Derived classes should call through to this init.
60 // |url| and |title| are only used for BookmarkNode::Type::NEW_URL. 60 // |url| and |title| are only used for BookmarkNode::Type::NEW_URL.
61 - (id)initWithParentWindow:(NSWindow*)parentWindow 61 - (id)initWithParentWindow:(NSWindow*)parentWindow
62 nibName:(NSString*)nibName 62 nibName:(NSString*)nibName
63 profile:(Profile*)profile 63 profile:(Profile*)profile
64 parent:(const BookmarkNode*)parent 64 parent:(const bookmarks::BookmarkNode*)parent
65 url:(const GURL&)url 65 url:(const GURL&)url
66 title:(const base::string16&)title 66 title:(const base::string16&)title
67 configuration:(BookmarkEditor::Configuration)configuration; 67 configuration:(BookmarkEditor::Configuration)configuration;
68 68
69 // Run the bookmark editor as a modal sheet. Does not block. 69 // Run the bookmark editor as a modal sheet. Does not block.
70 - (void)runAsModalSheet; 70 - (void)runAsModalSheet;
71 71
72 // Create a new folder at the end of the selected parent folder, give it 72 // Create a new folder at the end of the selected parent folder, give it
73 // an untitled name, and put it into editing mode. 73 // an untitled name, and put it into editing mode.
74 - (IBAction)newFolder:(id)sender; 74 - (IBAction)newFolder:(id)sender;
(...skipping 15 matching lines...) Expand all
90 // indicating if the operation should be allowed to continue. 90 // indicating if the operation should be allowed to continue.
91 // Note: A derived class should not override the ok: action. 91 // Note: A derived class should not override the ok: action.
92 - (IBAction)ok:(id)sender; 92 - (IBAction)ok:(id)sender;
93 93
94 // Methods for use by derived classes only. 94 // Methods for use by derived classes only.
95 95
96 // Determine and returns the rightmost selected/highlighted element (node) 96 // Determine and returns the rightmost selected/highlighted element (node)
97 // in the bookmark tree view if the tree view is showing, otherwise returns 97 // in the bookmark tree view if the tree view is showing, otherwise returns
98 // the original |parentNode_|. If the tree view is showing but nothing is 98 // the original |parentNode_|. If the tree view is showing but nothing is
99 // selected then the root node is returned. 99 // selected then the root node is returned.
100 - (const BookmarkNode*)selectedNode; 100 - (const bookmarks::BookmarkNode*)selectedNode;
101 101
102 // Expands the set of BookmarkNodes in |nodes|. 102 // Expands the set of BookmarkNodes in |nodes|.
103 - (void)expandNodes:( 103 - (void)expandNodes:(
104 const bookmarks::BookmarkExpandedStateTracker::Nodes&)nodes; 104 const bookmarks::BookmarkExpandedStateTracker::Nodes&)nodes;
105 105
106 // Returns the set of expanded BookmarkNodes. 106 // Returns the set of expanded BookmarkNodes.
107 - (bookmarks::BookmarkExpandedStateTracker::Nodes)getExpandedNodes; 107 - (bookmarks::BookmarkExpandedStateTracker::Nodes)getExpandedNodes;
108 108
109 // Select/highlight the given node within the browser tree view. If the 109 // Select/highlight the given node within the browser tree view. If the
110 // node is nil then select the bookmark bar node. Exposed for unit test. 110 // node is nil then select the bookmark bar node. Exposed for unit test.
111 - (void)selectNodeInBrowser:(const BookmarkNode*)node; 111 - (void)selectNodeInBrowser:(const bookmarks::BookmarkNode*)node;
112 112
113 // Notifications called when the BookmarkModel changes out from under me. 113 // Notifications called when the BookmarkModel changes out from under me.
114 - (void)nodeRemoved:(const BookmarkNode*)node 114 - (void)nodeRemoved:(const bookmarks::BookmarkNode*)node
115 fromParent:(const BookmarkNode*)parent; 115 fromParent:(const bookmarks::BookmarkNode*)parent;
116 - (void)modelChangedPreserveSelection:(BOOL)preserve; 116 - (void)modelChangedPreserveSelection:(BOOL)preserve;
117 117
118 // Determines if the ok button should be enabled, can be overridden. 118 // Determines if the ok button should be enabled, can be overridden.
119 - (BOOL)okEnabled; 119 - (BOOL)okEnabled;
120 120
121 // Accessors 121 // Accessors
122 - (bookmarks::BookmarkModel*)bookmarkModel; 122 - (bookmarks::BookmarkModel*)bookmarkModel;
123 - (Profile*)profile; 123 - (Profile*)profile;
124 - (const BookmarkNode*)parentNode; 124 - (const bookmarks::BookmarkNode*)parentNode;
125 - (const GURL&)url; 125 - (const GURL&)url;
126 - (const base::string16&)title; 126 - (const base::string16&)title;
127 127
128 @end 128 @end
129 129
130 // Describes the profile's bookmark folder structure: the folder name, the 130 // Describes the profile's bookmark folder structure: the folder name, the
131 // original BookmarkNode pointer (if the folder already exists), a BOOL 131 // original BookmarkNode pointer (if the folder already exists), a BOOL
132 // indicating if the folder is new (meaning: created during this session 132 // indicating if the folder is new (meaning: created during this session
133 // but not yet committed to the bookmark structure), and an NSArray of 133 // but not yet committed to the bookmark structure), and an NSArray of
134 // child folder BookmarkFolderInfo's following this same structure. 134 // child folder BookmarkFolderInfo's following this same structure.
135 @interface BookmarkFolderInfo : NSObject { 135 @interface BookmarkFolderInfo : NSObject {
136 @private 136 @private
137 NSString* folderName_; 137 NSString* folderName_;
138 const BookmarkNode* folderNode_; // weak 138 const bookmarks::BookmarkNode* folderNode_; // weak
139 NSMutableArray* children_; 139 NSMutableArray* children_;
140 BOOL newFolder_; 140 BOOL newFolder_;
141 } 141 }
142 142
143 @property(nonatomic, copy) NSString* folderName; 143 @property(nonatomic, copy) NSString* folderName;
144 @property(nonatomic, assign) const BookmarkNode* folderNode; 144 @property(nonatomic, assign) const bookmarks::BookmarkNode* folderNode;
145 @property(nonatomic, retain) NSMutableArray* children; 145 @property(nonatomic, retain) NSMutableArray* children;
146 @property(nonatomic, assign) BOOL newFolder; 146 @property(nonatomic, assign) BOOL newFolder;
147 147
148 // Convenience creator for adding a new folder to the editor's bookmark 148 // Convenience creator for adding a new folder to the editor's bookmark
149 // structure. This folder will be added to the bookmark model when the 149 // structure. This folder will be added to the bookmark model when the
150 // user accepts the dialog. |folderName| must be provided. 150 // user accepts the dialog. |folderName| must be provided.
151 + (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName; 151 + (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName;
152 152
153 // Designated initializer. |folderName| must be provided. For folders which 153 // Designated initializer. |folderName| must be provided. For folders which
154 // already exist in the bookmark model, |folderNode| and |children| (if any 154 // already exist in the bookmark model, |folderNode| and |children| (if any
155 // children are already attached to this folder) must be provided and 155 // children are already attached to this folder) must be provided and
156 // |newFolder| should be NO. For folders which the user has added during 156 // |newFolder| should be NO. For folders which the user has added during
157 // this session and which have not been committed yet, |newFolder| should be 157 // this session and which have not been committed yet, |newFolder| should be
158 // YES and |folderNode| and |children| should be NULL/nil. 158 // YES and |folderNode| and |children| should be NULL/nil.
159 - (id)initWithFolderName:(NSString*)folderName 159 - (id)initWithFolderName:(NSString*)folderName
160 folderNode:(const BookmarkNode*)folderNode 160 folderNode:(const bookmarks::BookmarkNode*)folderNode
161 children:(NSMutableArray*)children 161 children:(NSMutableArray*)children
162 newFolder:(BOOL)newFolder; 162 newFolder:(BOOL)newFolder;
163 163
164 // Convenience creator used during construction of the editor's bookmark 164 // Convenience creator used during construction of the editor's bookmark
165 // structure. |folderName| and |folderNode| must be provided. |children| 165 // structure. |folderName| and |folderNode| must be provided. |children|
166 // is optional. Private: exposed here for unit testing purposes. 166 // is optional. Private: exposed here for unit testing purposes.
167 + (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName 167 + (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName
168 folderNode:(const BookmarkNode*)folderNode 168 folderNode:
169 (const bookmarks::BookmarkNode*)folderNode
169 children:(NSMutableArray*)children; 170 children:(NSMutableArray*)children;
170 171
171 @end 172 @end
172 173
173 @interface BookmarkEditorBaseController(TestingAPI) 174 @interface BookmarkEditorBaseController(TestingAPI)
174 175
175 @property(nonatomic, readonly) BOOL okButtonEnabled; 176 @property(nonatomic, readonly) BOOL okButtonEnabled;
176 177
177 // Create any newly added folders. New folders are nodes in folderTreeArray 178 // Create any newly added folders. New folders are nodes in folderTreeArray
178 // which are marked as being new (i.e. their kFolderTreeNewFolderKey 179 // which are marked as being new (i.e. their kFolderTreeNewFolderKey
179 // dictionary item is YES). This is called by -[ok:]. 180 // dictionary item is YES). This is called by -[ok:].
180 - (void)createNewFolders; 181 - (void)createNewFolders;
181 182
182 // Select the given bookmark node within the tree view. 183 // Select the given bookmark node within the tree view.
183 - (void)selectTestNodeInBrowser:(const BookmarkNode*)node; 184 - (void)selectTestNodeInBrowser:(const bookmarks::BookmarkNode*)node;
184 185
185 // Return the dictionary for the folder selected in the tree. 186 // Return the dictionary for the folder selected in the tree.
186 - (BookmarkFolderInfo*)selectedFolder; 187 - (BookmarkFolderInfo*)selectedFolder;
187 188
188 @end 189 @end
189 190
190 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_EDITOR_BASE_CONTROLLER_H_ 191 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_EDITOR_BASE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698