summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_manager_controller.h
blob: 5c30875667455ee29dd384778e5a06fd0bb51f84 (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
// Copyright (c) 2009 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"
#include "base/scoped_ptr.h"

@class BookmarkItem;
@class BookmarkTreeController;
class BookmarkManagerBridge;
class BookmarkModel;
class BookmarkNode;
@class FakeBookmarkItem;
class Profile;

// Controller for the bookmark manager window. There is at most one instance.
@interface BookmarkManagerController : NSWindowController {
 @private
  IBOutlet NSSearchField* searchField_;
  IBOutlet NSSegmentedControl* addRemoveButton_;
  IBOutlet NSPopUpButton* actionButton_;
  IBOutlet BookmarkTreeController* groupsController_;
  IBOutlet BookmarkTreeController* listController_;

  Profile* profile_;  // weak
  scoped_ptr<BookmarkManagerBridge> bridge_;
  scoped_nsobject<NSMapTable> nodeMap_;
  scoped_nsobject<FakeBookmarkItem> root_;  // Root of tree
  scoped_nsobject<FakeBookmarkItem> searchGroup_;  // Search Results group item
  scoped_nsobject<FakeBookmarkItem> recentGroup_;  // Recently-Added group item
  scoped_nsobject<BookmarkItem> preSearchGroup_;  // Selected before search
}

// Opens the bookmark manager window, or brings it to the front if it's open.
+ (BookmarkManagerController*)showBookmarkManager:(Profile*)profile;

// The user Profile.
@property (readonly) Profile* profile;

// The BookmarkModel of the manager's Profile.
@property (readonly) BookmarkModel* bookmarkModel;

@property (readonly) BookmarkItem* bookmarkBarItem;
@property (readonly) BookmarkItem* otherBookmarksItem;

// Maps C++ BookmarkNode objects to Objective-C BookmarkItems.
- (BookmarkItem*)itemFromNode:(const BookmarkNode*)node;

// Shows a group and its contents.
- (void)showGroup:(BookmarkItem*)group;
// Shows and selects a particular bookmark in its group.
- (BOOL)revealItem:(BookmarkItem*)item;

- (void)setSearchString:(NSString*)string;

// Called by the toolbar search field after the user changes its text.
- (IBAction)searchFieldChanged:(id)sender;
// Called by the toolbar item; forwards to the focused tree controller.
- (IBAction)delete:(id)sender;
// Called by add/remove button.
- (IBAction)segmentedControlClicked:(id)sender;

// Updates the node->item mapping; called only by BookmarkItem itself!
- (void)remapItem:(BookmarkItem*)item forNode:(const BookmarkNode*)node;
@end


// Exposed only for unit tests.
@interface BookmarkManagerController (UnitTesting)

- (void)forgetNode:(const BookmarkNode*)node;
@property (readonly) BookmarkTreeController* groupsController;
@property (readonly) BookmarkTreeController* listController;
@property (readonly) FakeBookmarkItem* searchGroup;
@property (readonly) FakeBookmarkItem* recentGroup;

@end