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