Home | History | Annotate | Download | only in bookmarks
      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.
      4 
      5 #import <Cocoa/Cocoa.h>
      6 
      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"
     11 
     12 class BookmarkModel;
     13 class BookmarkNode;
     14 @class BookmarkBubbleController;
     15 @class BookmarkSyncPromoController;
     16 
     17 // Controller for the bookmark bubble.  The bookmark bubble is a
     18 // bubble that pops up when clicking on the STAR next to the URL to
     19 // add or remove it as a bookmark.  This bubble allows for editing of
     20 // the bookmark in various ways (name, folder, etc.)
     21 @interface BookmarkBubbleController : BaseBubbleController {
     22  @private
     23   // Both weak; owned by the current browser's profile.
     24   BookmarkModel* model_;  // weak
     25   const BookmarkNode* node_;  // weak
     26 
     27   // The bookmark node whose button we asked to pulse.
     28   const BookmarkNode* pulsingBookmarkNode_;  // weak
     29 
     30   BOOL alreadyBookmarked_;
     31 
     32   // Ping me when the bookmark model changes out from under us.
     33   scoped_ptr<BookmarkModelObserverForCocoa> bookmarkObserver_;
     34 
     35   // Sync promo controller, if the sync promo is displayed.
     36   base::scoped_nsobject<BookmarkSyncPromoController> syncPromoController_;
     37 
     38   IBOutlet NSTextField* bigTitle_;   // "Bookmark" or "Bookmark Added!"
     39   IBOutlet NSTextField* nameTextField_;
     40   IBOutlet NSPopUpButton* folderPopUpButton_;
     41   IBOutlet NSView* syncPromoPlaceholder_;
     42 }
     43 
     44 @property(readonly, nonatomic) const BookmarkNode* node;
     45 
     46 // |node| is the bookmark node we edit in this bubble.
     47 // |alreadyBookmarked| tells us if the node was bookmarked before the
     48 //   user clicked on the star.  (if NO, this is a brand new bookmark).
     49 // The owner of this object is responsible for showing the bubble if
     50 // it desires it to be visible on the screen.  It is not shown by the
     51 // init routine.  Closing of the window happens implicitly on dealloc.
     52 - (id)initWithParentWindow:(NSWindow*)parentWindow
     53                      model:(BookmarkModel*)model
     54                       node:(const BookmarkNode*)node
     55          alreadyBookmarked:(BOOL)alreadyBookmarked;
     56 
     57 // Actions for buttons in the dialog.
     58 - (IBAction)ok:(id)sender;
     59 - (IBAction)remove:(id)sender;
     60 - (IBAction)cancel:(id)sender;
     61 
     62 // These actions send a -editBookmarkNode: action up the responder chain.
     63 - (IBAction)edit:(id)sender;
     64 - (IBAction)folderChanged:(id)sender;
     65 
     66 @end
     67 
     68 
     69 // Exposed only for unit testing.
     70 @interface BookmarkBubbleController (ExposedForUnitTesting)
     71 
     72 @property(nonatomic, readonly) NSView* syncPromoPlaceholder;
     73 
     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