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 3 // found in the LICENSE file. 4 5 #import <Cocoa/Cocoa.h> 6 7 #import "base/mac/cocoa_protocols.h" 8 #include "base/memory/scoped_ptr.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" 10 11 class BookmarkBubbleNotificationBridge; 12 class BookmarkModel; 13 class BookmarkNode; 14 @class BookmarkBubbleController; 15 @class InfoBubbleView; 16 17 18 // Controller for the bookmark bubble. The bookmark bubble is a 19 // bubble that pops up when clicking on the STAR next to the URL to 20 // add or remove it as a bookmark. This bubble allows for editing of 21 // the bookmark in various ways (name, folder, etc.) 22 @interface BookmarkBubbleController : NSWindowController<NSWindowDelegate> { 23 @private 24 NSWindow* parentWindow_; // weak 25 26 // Both weak; owned by the current browser's profile 27 BookmarkModel* model_; // weak 28 const BookmarkNode* node_; // weak 29 30 // The bookmark node whose button we asked to pulse. 31 const BookmarkNode* pulsingBookmarkNode_; // weak 32 33 BOOL alreadyBookmarked_; 34 35 // Ping me when the bookmark model changes out from under us. 36 scoped_ptr<BookmarkModelObserverForCocoa> bookmark_observer_; 37 38 // Ping me when other Chrome things change out from under us. 39 scoped_ptr<BookmarkBubbleNotificationBridge> chrome_observer_; 40 41 IBOutlet NSTextField* bigTitle_; // "Bookmark" or "Bookmark Added!" 42 IBOutlet NSTextField* nameTextField_; 43 IBOutlet NSPopUpButton* folderPopUpButton_; 44 IBOutlet InfoBubbleView* bubble_; // to set arrow position 45 } 46 47 @property(readonly, nonatomic) const BookmarkNode* node; 48 49 // |node| is the bookmark node we edit in this bubble. 50 // |alreadyBookmarked| tells us if the node was bookmarked before the 51 // user clicked on the star. (if NO, this is a brand new bookmark). 52 // The owner of this object is responsible for showing the bubble if 53 // it desires it to be visible on the screen. It is not shown by the 54 // init routine. Closing of the window happens implicitly on dealloc. 55 - (id)initWithParentWindow:(NSWindow*)parentWindow 56 model:(BookmarkModel*)model 57 node:(const BookmarkNode*)node 58 alreadyBookmarked:(BOOL)alreadyBookmarked; 59 60 // Actions for buttons in the dialog. 61 - (IBAction)ok:(id)sender; 62 - (IBAction)remove:(id)sender; 63 - (IBAction)cancel:(id)sender; 64 65 // These actions send a -editBookmarkNode: action up the responder chain. 66 - (IBAction)edit:(id)sender; 67 - (IBAction)folderChanged:(id)sender; 68 69 @end 70 71 72 // Exposed only for unit testing. 73 @interface BookmarkBubbleController(ExposedForUnitTesting) 74 - (void)addFolderNodes:(const BookmarkNode*)parent 75 toPopUpButton:(NSPopUpButton*)button 76 indentation:(int)indentation; 77 - (void)setTitle:(NSString*)title parentFolder:(const BookmarkNode*)parent; 78 - (void)setParentFolderSelection:(const BookmarkNode*)parent; 79 + (NSString*)chooseAnotherFolderString; 80 - (NSPopUpButton*)folderPopUpButton; 81 @end 82