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
;
18 class ManagedBookmarkService
;
21 // Controller for the bookmark bubble. The bookmark bubble is a
22 // bubble that pops up when clicking on the STAR next to the URL to
23 // add or remove it as a bookmark. This bubble allows for editing of
24 // the bookmark in various ways (name, folder, etc.)
25 @interface BookmarkBubbleController
: BaseBubbleController
{
27 // |managed_|, |model_| and |node_| are weak and owned by the current
29 bookmarks::ManagedBookmarkService
* managedBookmarkService_
; // weak
30 bookmarks::BookmarkModel
* model_
; // weak
31 const bookmarks::BookmarkNode
* node_
; // weak
33 // The bookmark node whose button we asked to pulse.
34 const bookmarks::BookmarkNode
* pulsingBookmarkNode_
; // weak
36 BOOL alreadyBookmarked_
;
38 // Ping me when the bookmark model changes out from under us.
39 scoped_ptr
<BookmarkModelObserverForCocoa
> bookmarkObserver_
;
41 // Sync promo controller, if the sync promo is displayed.
42 base::scoped_nsobject
<BookmarkSyncPromoController
> syncPromoController_
;
44 IBOutlet NSTextField
* bigTitle_
; // "Bookmark" or "Bookmark Added!"
45 IBOutlet NSTextField
* nameTextField_
;
46 IBOutlet NSPopUpButton
* folderPopUpButton_
;
47 IBOutlet NSView
* syncPromoPlaceholder_
;
50 @
property(readonly
, nonatomic
) const bookmarks::BookmarkNode
* node
;
52 // |node| is the bookmark node we edit in this bubble.
53 // |alreadyBookmarked| tells us if the node was bookmarked before the
54 // user clicked on the star. (if NO, this is a brand new bookmark).
55 // The owner of this object is responsible for showing the bubble if
56 // it desires it to be visible on the screen. It is not shown by the
57 // init routine. Closing of the window happens implicitly on dealloc.
58 - (id
)initWithParentWindow
:(NSWindow
*)parentWindow
59 managed
:(bookmarks::ManagedBookmarkService
*)managed
60 model
:(bookmarks::BookmarkModel
*)model
61 node
:(const bookmarks::BookmarkNode
*)node
62 alreadyBookmarked
:(BOOL
)alreadyBookmarked
;
64 // Actions for buttons in the dialog.
65 - (IBAction
)ok
:(id
)sender
;
66 - (IBAction
)remove
:(id
)sender
;
67 - (IBAction
)cancel
:(id
)sender
;
69 // These actions send a -editBookmarkNode: action up the responder chain.
70 - (IBAction
)edit
:(id
)sender
;
71 - (IBAction
)folderChanged
:(id
)sender
;
76 // Exposed only for unit testing.
77 @interface
BookmarkBubbleController (ExposedForUnitTesting
)
79 @
property(nonatomic
, readonly
) NSView
* syncPromoPlaceholder
;
81 - (void)addFolderNodes
:(const bookmarks::BookmarkNode
*)parent
82 toPopUpButton
:(NSPopUpButton
*)button
83 indentation
:(int)indentation
;
84 - (void)setTitle
:(NSString
*)title
85 parentFolder
:(const bookmarks::BookmarkNode
*)parent
;
86 - (void)setParentFolderSelection
:(const bookmarks::BookmarkNode
*)parent
;
87 + (NSString
*)chooseAnotherFolderString
;
88 - (NSPopUpButton
*)folderPopUpButton
;