| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 9 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" |
| 11 | 11 |
| 12 @class BookmarkBubbleController; | 12 @class BookmarkBubbleController; |
| 13 @class BookmarkSyncPromoController; | 13 @class BookmarkSyncPromoController; |
| 14 | 14 |
| 15 namespace bookmarks { | 15 namespace bookmarks { |
| 16 class BookmarkBubbleObserver; |
| 16 class BookmarkModel; | 17 class BookmarkModel; |
| 17 class BookmarkNode; | 18 class BookmarkNode; |
| 18 class ManagedBookmarkService; | 19 class ManagedBookmarkService; |
| 19 } | 20 } |
| 20 | 21 |
| 21 // Controller for the bookmark bubble. The bookmark bubble is a | 22 // 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 // 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 // add or remove it as a bookmark. This bubble allows for editing of |
| 24 // the bookmark in various ways (name, folder, etc.) | 25 // the bookmark in various ways (name, folder, etc.) |
| 25 @interface BookmarkBubbleController : BaseBubbleController { | 26 @interface BookmarkBubbleController : BaseBubbleController { |
| 26 @private | 27 @private |
| 27 // |managed_|, |model_| and |node_| are weak and owned by the current | 28 // |managed_|, |model_| and |node_| are weak and owned by the current |
| 28 // browser's profile. | 29 // browser's profile. |
| 29 bookmarks::ManagedBookmarkService* managedBookmarkService_; // weak | 30 bookmarks::ManagedBookmarkService* managedBookmarkService_; // weak |
| 30 bookmarks::BookmarkModel* model_; // weak | 31 bookmarks::BookmarkModel* model_; // weak |
| 31 const bookmarks::BookmarkNode* node_; // weak | 32 const bookmarks::BookmarkNode* node_; // weak |
| 32 | 33 |
| 33 // The bookmark node whose button we asked to pulse. | 34 // Inform the observer when the bubble is shown or closed. |
| 34 const bookmarks::BookmarkNode* pulsingBookmarkNode_; // weak | 35 bookmarks::BookmarkBubbleObserver* bookmarkBubbleObserver_; // weak |
| 35 | 36 |
| 36 BOOL alreadyBookmarked_; | 37 BOOL alreadyBookmarked_; |
| 37 | 38 |
| 38 // Ping me when the bookmark model changes out from under us. | 39 // Ping me when the bookmark model changes out from under us. |
| 39 scoped_ptr<BookmarkModelObserverForCocoa> bookmarkObserver_; | 40 scoped_ptr<BookmarkModelObserverForCocoa> bookmarkObserver_; |
| 40 | 41 |
| 41 // Sync promo controller, if the sync promo is displayed. | 42 // Sync promo controller, if the sync promo is displayed. |
| 42 base::scoped_nsobject<BookmarkSyncPromoController> syncPromoController_; | 43 base::scoped_nsobject<BookmarkSyncPromoController> syncPromoController_; |
| 43 | 44 |
| 44 IBOutlet NSTextField* bigTitle_; // "Bookmark" or "Bookmark Added!" | 45 IBOutlet NSTextField* bigTitle_; // "Bookmark" or "Bookmark Added!" |
| 45 IBOutlet NSTextField* nameTextField_; | 46 IBOutlet NSTextField* nameTextField_; |
| 46 IBOutlet NSPopUpButton* folderPopUpButton_; | 47 IBOutlet NSPopUpButton* folderPopUpButton_; |
| 47 IBOutlet NSView* syncPromoPlaceholder_; | 48 IBOutlet NSView* syncPromoPlaceholder_; |
| 48 } | 49 } |
| 49 | 50 |
| 50 @property(readonly, nonatomic) const bookmarks::BookmarkNode* node; | 51 @property(readonly, nonatomic) const bookmarks::BookmarkNode* node; |
| 51 | 52 |
| 52 // |node| is the bookmark node we edit in this bubble. | 53 // |node| is the bookmark node we edit in this bubble. |
| 53 // |alreadyBookmarked| tells us if the node was bookmarked before the | 54 // |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 // 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 // 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 // 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 // init routine. Closing of the window happens implicitly on dealloc. |
| 58 - (id)initWithParentWindow:(NSWindow*)parentWindow | 59 - (id)initWithParentWindow:(NSWindow*)parentWindow |
| 60 bubbleObserver:(bookmarks::BookmarkBubbleObserver*)bubbleObserver |
| 59 managed:(bookmarks::ManagedBookmarkService*)managed | 61 managed:(bookmarks::ManagedBookmarkService*)managed |
| 60 model:(bookmarks::BookmarkModel*)model | 62 model:(bookmarks::BookmarkModel*)model |
| 61 node:(const bookmarks::BookmarkNode*)node | 63 node:(const bookmarks::BookmarkNode*)node |
| 62 alreadyBookmarked:(BOOL)alreadyBookmarked; | 64 alreadyBookmarked:(BOOL)alreadyBookmarked; |
| 63 | 65 |
| 64 // Actions for buttons in the dialog. | 66 // Actions for buttons in the dialog. |
| 65 - (IBAction)ok:(id)sender; | 67 - (IBAction)ok:(id)sender; |
| 66 - (IBAction)remove:(id)sender; | 68 - (IBAction)remove:(id)sender; |
| 67 - (IBAction)cancel:(id)sender; | 69 - (IBAction)cancel:(id)sender; |
| 68 | 70 |
| 69 // These actions send a -editBookmarkNode: action up the responder chain. | 71 // These actions send a -editBookmarkNode: action up the responder chain. |
| 70 - (IBAction)edit:(id)sender; | 72 - (IBAction)edit:(id)sender; |
| 71 - (IBAction)folderChanged:(id)sender; | 73 - (IBAction)folderChanged:(id)sender; |
| 72 | 74 |
| 73 @end | 75 @end |
| 74 | 76 |
| 75 | 77 |
| 76 // Exposed only for unit testing. | 78 // Exposed only for unit testing. |
| 77 @interface BookmarkBubbleController (ExposedForUnitTesting) | 79 @interface BookmarkBubbleController (ExposedForUnitTesting) |
| 78 | 80 |
| 79 @property(nonatomic, readonly) NSView* syncPromoPlaceholder; | 81 @property(nonatomic, readonly) NSView* syncPromoPlaceholder; |
| 82 @property(nonatomic, readonly) |
| 83 bookmarks::BookmarkBubbleObserver* bookmarkBubbleObserver; |
| 80 | 84 |
| 81 - (void)addFolderNodes:(const bookmarks::BookmarkNode*)parent | 85 - (void)addFolderNodes:(const bookmarks::BookmarkNode*)parent |
| 82 toPopUpButton:(NSPopUpButton*)button | 86 toPopUpButton:(NSPopUpButton*)button |
| 83 indentation:(int)indentation; | 87 indentation:(int)indentation; |
| 84 - (void)setTitle:(NSString*)title | 88 - (void)setTitle:(NSString*)title |
| 85 parentFolder:(const bookmarks::BookmarkNode*)parent; | 89 parentFolder:(const bookmarks::BookmarkNode*)parent; |
| 86 - (void)setParentFolderSelection:(const bookmarks::BookmarkNode*)parent; | 90 - (void)setParentFolderSelection:(const bookmarks::BookmarkNode*)parent; |
| 87 + (NSString*)chooseAnotherFolderString; | 91 + (NSString*)chooseAnotherFolderString; |
| 88 - (NSPopUpButton*)folderPopUpButton; | 92 - (NSPopUpButton*)folderPopUpButton; |
| 89 @end | 93 @end |
| OLD | NEW |