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
3 // found in the LICENSE file.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h"
9 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h"
12 @
class BookmarkBubbleController
;
13 @
class BookmarkSyncPromoController
;
16 class BookmarkBubbleObserver
;
19 class ManagedBookmarkService
;
22 // Controller for the bookmark bubble. The bookmark bubble is a
23 // bubble that pops up when clicking on the STAR next to the URL to
24 // add or remove it as a bookmark. This bubble allows for editing of
25 // the bookmark in various ways (name, folder, etc.)
26 @interface BookmarkBubbleController
: BaseBubbleController
{
28 // |managed_|, |model_| and |node_| are weak and owned by the current
30 bookmarks::ManagedBookmarkService
* managedBookmarkService_
; // weak
31 bookmarks::BookmarkModel
* model_
; // weak
32 const bookmarks::BookmarkNode
* node_
; // weak
34 // Inform the observer when the bubble is shown or closed.
35 bookmarks::BookmarkBubbleObserver
* bookmarkBubbleObserver_
; // weak
37 BOOL alreadyBookmarked_
;
39 // Ping me when the bookmark model changes out from under us.
40 scoped_ptr
<BookmarkModelObserverForCocoa
> bookmarkObserver_
;
42 // Sync promo controller, if the sync promo is displayed.
43 base::scoped_nsobject
<BookmarkSyncPromoController
> syncPromoController_
;
45 IBOutlet NSTextField
* bigTitle_
; // "Bookmark" or "Bookmark Added!"
46 IBOutlet NSTextField
* nameTextField_
;
47 IBOutlet NSPopUpButton
* folderPopUpButton_
;
48 IBOutlet NSView
* syncPromoPlaceholder_
;
51 @
property(readonly
, nonatomic
) const bookmarks::BookmarkNode
* node
;
53 // |node| is the bookmark node we edit in this bubble.
54 // |alreadyBookmarked| tells us if the node was bookmarked before the
55 // user clicked on the star. (if NO, this is a brand new bookmark).
56 // The owner of this object is responsible for showing the bubble if
57 // it desires it to be visible on the screen. It is not shown by the
58 // init routine. Closing of the window happens implicitly on dealloc.
59 - (id
)initWithParentWindow
:(NSWindow
*)parentWindow
60 bubbleObserver
:(bookmarks::BookmarkBubbleObserver
*)bubbleObserver
61 managed
:(bookmarks::ManagedBookmarkService
*)managed
62 model
:(bookmarks::BookmarkModel
*)model
63 node
:(const bookmarks::BookmarkNode
*)node
64 alreadyBookmarked
:(BOOL
)alreadyBookmarked
;
66 // Actions for buttons in the dialog.
67 - (IBAction
)ok
:(id
)sender
;
68 - (IBAction
)remove
:(id
)sender
;
69 - (IBAction
)cancel
:(id
)sender
;
71 // These actions send a -editBookmarkNode: action up the responder chain.
72 - (IBAction
)edit
:(id
)sender
;
73 - (IBAction
)folderChanged
:(id
)sender
;
78 // Exposed only for unit testing.
79 @interface
BookmarkBubbleController (ExposedForUnitTesting
)
81 @
property(nonatomic
, readonly
) NSView
* syncPromoPlaceholder
;
82 @
property(nonatomic
, readonly
)
83 bookmarks::BookmarkBubbleObserver
* bookmarkBubbleObserver
;
85 - (void)addFolderNodes
:(const bookmarks::BookmarkNode
*)parent
86 toPopUpButton
:(NSPopUpButton
*)button
87 indentation
:(int)indentation
;
88 - (void)setTitle
:(NSString
*)title
89 parentFolder
:(const bookmarks::BookmarkNode
*)parent
;
90 - (void)setParentFolderSelection
:(const bookmarks::BookmarkNode
*)parent
;
91 + (NSString
*)chooseAnotherFolderString
;
92 - (NSPopUpButton
*)folderPopUpButton
;