blob: 63e90978429cd7a63d5d48a63f104ae32c14b875 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
#include "base/scoped_nsobject.h"
@class BookmarkManagerController;
class BookmarkNode;
// Cocoa object that stands in for a C++ BookmarkNode.
@interface BookmarkItem : NSObject {
@private
const BookmarkNode* node_; // weak
BookmarkManagerController* manager_; // weak
@protected
scoped_nsobject<NSImage> icon_;
}
- (id)initWithBookmarkNode:(const BookmarkNode*)node
manager:(BookmarkManagerController*)manager;
// The item's underlying C++ node (nil for fake items).
@property (readonly) const BookmarkNode* node;
// The item's title.
@property (copy) NSString* title;
// The item's URL as a plain string (nil for folders).
@property (copy) NSString* URLString;
// The item's parent in the real bookmark tree.
@property (readonly) BookmarkItem* parent;
// The user-visible path to the item (slash-delimited).
@property (readonly) NSString* folderPath;
// Is this a FakeBookmarkItem?
@property (readonly) BOOL isFake;
// Fixed items (Bookmarks Bar, Other, fake) cannot be renamed, moved or deleted.
@property (readonly) BOOL isFixed;
// The bookmark's favicon (a folder icon for folders.)
@property (readonly) NSImage* icon;
// The bookmark node's persistent ID.
@property (readonly) id persistentID;
// Finds a descendant with the given persistent ID.
- (BookmarkItem*)itemWithPersistentID:(id)persistentID;
// Is this item a folder/group?
@property (readonly) BOOL isFolder;
// The number of direct children of a folder.
@property (readonly) NSUInteger numberOfChildren;
// The child at a given zero-based index.
- (BookmarkItem*)childAtIndex:(NSUInteger)index;
// The index of a direct child, or NSNotFound.
- (NSUInteger)indexOfChild:(BookmarkItem*)child;
// Is the item an indirect descendant of the receiver?
- (BOOL)hasDescendant:(BookmarkItem*)item;
// The number of direct children that are themselves folders.
@property (readonly) NSUInteger numberOfChildFolders;
// The index'th child folder.
- (BookmarkItem*)childFolderAtIndex:(NSUInteger)index;
// The index, by counting child folders, of the given folder.
- (NSUInteger)indexOfChildFolder:(BookmarkItem*)child;
// Moves an existing item into this folder at the given index.
- (void)moveItem:(BookmarkItem*)item toIndex:(int)index;
// Adds a child bookmark. Receiver must be a folder.
- (BookmarkItem*) addBookmarkWithTitle:(NSString*)title
URL:(NSString*)urlString
atIndex:(int)index;
// Adds a child folder. Receiver must be a folder.
- (BookmarkItem*) addFolderWithTitle:(NSString*)title
atIndex:(int)index;
// Removes a child bookmark; returns YES on success, NO on failure.
- (BOOL) removeChild:(BookmarkItem*)child;
// Open a bookmark in a tab.
- (BOOL)open;
// Called to tell the object that its underlying BookmarkNode has changed.
- (void)nodeChanged;
// The default bookmark favicon.
+ (NSImage*)defaultIcon;
// The default folder favicon.
+ (NSImage*)folderIcon;
@end
// A subclass of BookmarkItem for folders that don't actually exist in the tree.
@interface FakeBookmarkItem : BookmarkItem {
NSString* title_;
BookmarkItem* parent_;
NSArray* children_;
}
- (id)initWithTitle:(NSString*)title
icon:(NSImage*)icon
manager:(BookmarkManagerController*)manager;
// Parent is settable.
@property (readwrite, assign) BookmarkItem* parent;
// Children are settable.
@property (readwrite, copy) NSArray* children;
@end
|