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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <vector> 6 #include <vector>
7 #import "chrome/browser/ui/cocoa/draggable_button.h" 7 #import "chrome/browser/ui/cocoa/draggable_button.h"
8 #import "chrome/browser/ui/cocoa/themed_window.h" 8 #import "chrome/browser/ui/cocoa/themed_window.h"
9 #include "ui/base/window_open_disposition.h" 9 #include "ui/base/window_open_disposition.h"
10 10
11 @class BookmarkBarFolderController; 11 @class BookmarkBarFolderController;
12 @class BookmarkButton; 12 @class BookmarkButton;
13 class BookmarkNode;
14 @class BrowserWindowController; 13 @class BrowserWindowController;
15 class ThemeService; 14 class ThemeService;
16 15
17 namespace bookmarks { 16 namespace bookmarks {
18 class BookmarkModel; 17 class BookmarkModel;
18 class BookmarkNode;
19 } 19 }
20 20
21 // Protocol for a BookmarkButton's delegate, responsible for doing 21 // Protocol for a BookmarkButton's delegate, responsible for doing
22 // things on behalf of a bookmark button. 22 // things on behalf of a bookmark button.
23 @protocol BookmarkButtonDelegate 23 @protocol BookmarkButtonDelegate
24 24
25 // Fill the given pasteboard with appropriate data when the given button is 25 // Fill the given pasteboard with appropriate data when the given button is
26 // dragged. Since the delegate has no way of providing pasteboard data later, 26 // dragged. Since the delegate has no way of providing pasteboard data later,
27 // all data must actually be put into the pasteboard and not merely promised. 27 // all data must actually be put into the pasteboard and not merely promised.
28 - (void)fillPasteboard:(NSPasteboard*)pboard 28 - (void)fillPasteboard:(NSPasteboard*)pboard
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 to:(NSPoint)point 100 to:(NSPoint)point
101 copy:(BOOL)copy; 101 copy:(BOOL)copy;
102 102
103 // Determine if the pasteboard from |info| has dragging data containing 103 // Determine if the pasteboard from |info| has dragging data containing
104 // bookmark(s) and perform the drag and return YES, otherwise return NO. 104 // bookmark(s) and perform the drag and return YES, otherwise return NO.
105 - (BOOL)dragBookmarkData:(id<NSDraggingInfo>)info; 105 - (BOOL)dragBookmarkData:(id<NSDraggingInfo>)info;
106 106
107 // Determine if the drag pasteboard has any drag data of type 107 // Determine if the drag pasteboard has any drag data of type
108 // kBookmarkDictionaryListPboardType and, if so, return those elements 108 // kBookmarkDictionaryListPboardType and, if so, return those elements
109 // otherwise return an empty vector. 109 // otherwise return an empty vector.
110 - (std::vector<const BookmarkNode*>)retrieveBookmarkNodeData; 110 - (std::vector<const bookmarks::BookmarkNode*>)retrieveBookmarkNodeData;
111 111
112 // Return YES if we should show the drop indicator, else NO. In some 112 // Return YES if we should show the drop indicator, else NO. In some
113 // cases (e.g. hover open) we don't want to show the drop indicator. 113 // cases (e.g. hover open) we don't want to show the drop indicator.
114 // |point| is in the base coordinate system of the destination window; 114 // |point| is in the base coordinate system of the destination window;
115 // |it comes from an id<NSDraggingInfo>. 115 // |it comes from an id<NSDraggingInfo>.
116 - (BOOL)shouldShowIndicatorShownForPoint:(NSPoint)point; 116 - (BOOL)shouldShowIndicatorShownForPoint:(NSPoint)point;
117 117
118 // The x or y coordinate of (the middle of) the indicator to draw for 118 // The x or y coordinate of (the middle of) the indicator to draw for
119 // a drag of the source button to the given point (given in window 119 // a drag of the source button to the given point (given in window
120 // coordinates). 120 // coordinates).
(...skipping 19 matching lines...) Expand all
140 - (void)childFolderWillClose:(id<BookmarkButtonControllerProtocol>)child; 140 - (void)childFolderWillClose:(id<BookmarkButtonControllerProtocol>)child;
141 141
142 // Return a controller's folder controller for a subfolder, or nil. 142 // Return a controller's folder controller for a subfolder, or nil.
143 - (BookmarkBarFolderController*)folderController; 143 - (BookmarkBarFolderController*)folderController;
144 144
145 // Add a new folder controller as triggered by the given folder button. 145 // Add a new folder controller as triggered by the given folder button.
146 // If there is a current folder controller, close it. 146 // If there is a current folder controller, close it.
147 - (void)addNewFolderControllerWithParentButton:(BookmarkButton*)parentButton; 147 - (void)addNewFolderControllerWithParentButton:(BookmarkButton*)parentButton;
148 148
149 // Open all of the nodes for the given node with disposition. 149 // Open all of the nodes for the given node with disposition.
150 - (void)openAll:(const BookmarkNode*)node 150 - (void)openAll:(const bookmarks::BookmarkNode*)node
151 disposition:(WindowOpenDisposition)disposition; 151 disposition:(WindowOpenDisposition)disposition;
152 152
153 // There are several operations which may affect the contents of a bookmark 153 // There are several operations which may affect the contents of a bookmark
154 // button controller after it has been created, primary of which are 154 // button controller after it has been created, primary of which are
155 // cut/paste/delete and drag/drop. Such changes may involve coordinating 155 // cut/paste/delete and drag/drop. Such changes may involve coordinating
156 // the bookmark button contents of two controllers (such as when a bookmark is 156 // the bookmark button contents of two controllers (such as when a bookmark is
157 // dragged from one folder to another). The bookmark bar controller 157 // dragged from one folder to another). The bookmark bar controller
158 // coordinates in response to notifications propagated by the bookmark model 158 // coordinates in response to notifications propagated by the bookmark model
159 // through BookmarkBarBridge calls. The following three functions are 159 // through BookmarkBarBridge calls. The following three functions are
160 // implemented by the controllers and are dispatched by the bookmark bar 160 // implemented by the controllers and are dispatched by the bookmark bar
161 // controller in response to notifications coming in from the BookmarkBarBridge. 161 // controller in response to notifications coming in from the BookmarkBarBridge.
162 162
163 // Add a button for the given node to the bar or folder menu. This is safe 163 // Add a button for the given node to the bar or folder menu. This is safe
164 // to call when a folder menu window is open as that window will be updated. 164 // to call when a folder menu window is open as that window will be updated.
165 // And index of -1 means to append to the end (bottom). 165 // And index of -1 means to append to the end (bottom).
166 - (void)addButtonForNode:(const BookmarkNode*)node 166 - (void)addButtonForNode:(const bookmarks::BookmarkNode*)node
167 atIndex:(NSInteger)buttonIndex; 167 atIndex:(NSInteger)buttonIndex;
168 168
169 // Given a list or |urls| and |titles|, create new bookmark nodes and add 169 // Given a list or |urls| and |titles|, create new bookmark nodes and add
170 // them to the bookmark model such that they will be 1) added to the folder 170 // them to the bookmark model such that they will be 1) added to the folder
171 // represented by the button at |point| if it is a folder, or 2) inserted 171 // represented by the button at |point| if it is a folder, or 2) inserted
172 // into the parent of the non-folder bookmark at |point| in front of that 172 // into the parent of the non-folder bookmark at |point| in front of that
173 // button. Returns YES if at least one bookmark was added. 173 // button. Returns YES if at least one bookmark was added.
174 - (BOOL)addURLs:(NSArray*)urls withTitles:(NSArray*)titles at:(NSPoint)point; 174 - (BOOL)addURLs:(NSArray*)urls withTitles:(NSArray*)titles at:(NSPoint)point;
175 175
176 // Move a button from one place in the menu to another. This is safe 176 // Move a button from one place in the menu to another. This is safe
177 // to call when a folder menu window is open as that window will be updated. 177 // to call when a folder menu window is open as that window will be updated.
178 - (void)moveButtonFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex; 178 - (void)moveButtonFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex;
179 179
180 // Remove the bookmark button at the given index. Show the poof animation 180 // Remove the bookmark button at the given index. Show the poof animation
181 // if |animate:| is YES. It may be obvious, but this is safe 181 // if |animate:| is YES. It may be obvious, but this is safe
182 // to call when a folder menu window is open as that window will be updated. 182 // to call when a folder menu window is open as that window will be updated.
183 - (void)removeButton:(NSInteger)buttonIndex animate:(BOOL)poof; 183 - (void)removeButton:(NSInteger)buttonIndex animate:(BOOL)poof;
184 184
185 // Determine the controller containing the button representing |node|, if any. 185 // Determine the controller containing the button representing |node|, if any.
186 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 186 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
187 (const BookmarkNode*)node; 187 (const bookmarks::BookmarkNode*)node;
188 188
189 @end // @protocol BookmarkButtonControllerProtocol 189 @end // @protocol BookmarkButtonControllerProtocol
190 190
191 191
192 // Class for bookmark bar buttons that can be drag sources. 192 // Class for bookmark bar buttons that can be drag sources.
193 @interface BookmarkButton : DraggableButton<ThemedWindowDrawing> { 193 @interface BookmarkButton : DraggableButton<ThemedWindowDrawing> {
194 @private 194 @private
195 IBOutlet NSObject<BookmarkButtonDelegate>* delegate_; // Weak. 195 IBOutlet NSObject<BookmarkButtonDelegate>* delegate_; // Weak.
196 196
197 // Saved pointer to the BWC for the browser window that contains this button. 197 // Saved pointer to the BWC for the browser window that contains this button.
198 // Used to lock and release bar visibility during a drag. The pointer is 198 // Used to lock and release bar visibility during a drag. The pointer is
199 // saved because the bookmark button is no longer a part of a window at the 199 // saved because the bookmark button is no longer a part of a window at the
200 // end of a drag operation (or, in fact, can be dragged to a completely 200 // end of a drag operation (or, in fact, can be dragged to a completely
201 // different window), so there is no way to retrieve the same BWC object after 201 // different window), so there is no way to retrieve the same BWC object after
202 // a drag. 202 // a drag.
203 BrowserWindowController* visibilityDelegate_; // weak 203 BrowserWindowController* visibilityDelegate_; // weak
204 204
205 NSPoint dragMouseOffset_; 205 NSPoint dragMouseOffset_;
206 NSPoint dragEndScreenLocation_; 206 NSPoint dragEndScreenLocation_;
207 BOOL dragPending_; 207 BOOL dragPending_;
208 BOOL acceptsTrackIn_; 208 BOOL acceptsTrackIn_;
209 NSTrackingArea* area_; 209 NSTrackingArea* area_;
210 } 210 }
211 211
212 @property(assign, nonatomic) NSObject<BookmarkButtonDelegate>* delegate; 212 @property(assign, nonatomic) NSObject<BookmarkButtonDelegate>* delegate;
213 @property(assign, nonatomic) BOOL acceptsTrackIn; 213 @property(assign, nonatomic) BOOL acceptsTrackIn;
214 214
215 // Return the bookmark node associated with this button, or NULL. 215 // Return the bookmark node associated with this button, or NULL.
216 - (const BookmarkNode*)bookmarkNode; 216 - (const bookmarks::BookmarkNode*)bookmarkNode;
217 217
218 // Return YES if this is a folder button (the node has subnodes). 218 // Return YES if this is a folder button (the node has subnodes).
219 - (BOOL)isFolder; 219 - (BOOL)isFolder;
220 220
221 - (void)mouseDragged:(NSEvent*)theEvent; 221 - (void)mouseDragged:(NSEvent*)theEvent;
222 222
223 - (BOOL)acceptsTrackInFrom:(id)sender; 223 - (BOOL)acceptsTrackInFrom:(id)sender;
224 224
225 // At this time we represent an empty folder (e.g. the string 225 // At this time we represent an empty folder (e.g. the string
226 // '(empty)') as a disabled button with no associated node. 226 // '(empty)') as a disabled button with no associated node.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 // Key for userInfo dict of a kPulseBookmarkButtonNotification. 260 // Key for userInfo dict of a kPulseBookmarkButtonNotification.
261 // Value is a [NSValue valueWithPointer:]; pointer is a (const BookmarkNode*). 261 // Value is a [NSValue valueWithPointer:]; pointer is a (const BookmarkNode*).
262 extern NSString* const kBookmarkKey; 262 extern NSString* const kBookmarkKey;
263 263
264 // Key for userInfo dict of a kPulseBookmarkButtonNotification. 264 // Key for userInfo dict of a kPulseBookmarkButtonNotification.
265 // Value is a [NSNumber numberWithBool:] to turn pulsing on or off. 265 // Value is a [NSNumber numberWithBool:] to turn pulsing on or off.
266 extern NSString* const kBookmarkPulseFlagKey; 266 extern NSString* const kBookmarkPulseFlagKey;
267 267
268 }; 268 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698