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