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