| 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 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUBBLE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUBBLE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUBBLE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUBBLE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" | 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa.h" |
| 14 #import "chrome/browser/ui/cocoa/has_weak_browser_pointer.h" | 14 #import "chrome/browser/ui/cocoa/has_weak_browser_pointer.h" |
| 15 #import "chrome/browser/ui/cocoa/omnibox_decoration_bubble_controller.h" | 15 #import "chrome/browser/ui/cocoa/omnibox_decoration_bubble_controller.h" |
| 16 #import "ui/base/cocoa/touch_bar_forward_declarations.h" |
| 16 | 17 |
| 17 @class BookmarkBubbleController; | 18 @class BookmarkBubbleController; |
| 18 @class BubbleSyncPromoController; | 19 @class BubbleSyncPromoController; |
| 20 @class DialogTextFieldEditor; |
| 19 | 21 |
| 20 namespace bookmarks { | 22 namespace bookmarks { |
| 21 class BookmarkBubbleObserver; | 23 class BookmarkBubbleObserver; |
| 22 class BookmarkModel; | 24 class BookmarkModel; |
| 23 class BookmarkNode; | 25 class BookmarkNode; |
| 24 class ManagedBookmarkService; | 26 class ManagedBookmarkService; |
| 25 } | 27 } |
| 26 | 28 |
| 27 // Controller for the bookmark bubble. The bookmark bubble is a | 29 // Controller for the bookmark bubble. The bookmark bubble is a |
| 28 // bubble that pops up when clicking on the STAR next to the URL to | 30 // bubble that pops up when clicking on the STAR next to the URL to |
| 29 // add or remove it as a bookmark. This bubble allows for editing of | 31 // add or remove it as a bookmark. This bubble allows for editing of |
| 30 // the bookmark in various ways (name, folder, etc.) | 32 // the bookmark in various ways (name, folder, etc.) |
| 31 @interface BookmarkBubbleController | 33 @interface BookmarkBubbleController |
| 32 : OmniboxDecorationBubbleController<HasWeakBrowserPointer> { | 34 : OmniboxDecorationBubbleController<NSTouchBarDelegate, |
| 35 HasWeakBrowserPointer> { |
| 33 @private | 36 @private |
| 34 // |managed_|, |model_| and |node_| are weak and owned by the current | 37 // |managed_|, |model_| and |node_| are weak and owned by the current |
| 35 // browser's profile. | 38 // browser's profile. |
| 36 bookmarks::ManagedBookmarkService* managedBookmarkService_; // weak | 39 bookmarks::ManagedBookmarkService* managedBookmarkService_; // weak |
| 37 bookmarks::BookmarkModel* model_; // weak | 40 bookmarks::BookmarkModel* model_; // weak |
| 38 const bookmarks::BookmarkNode* node_; // weak | 41 const bookmarks::BookmarkNode* node_; // weak |
| 39 | 42 |
| 40 // Inform the observer when the bubble is shown or closed. | 43 // Inform the observer when the bubble is shown or closed. |
| 41 bookmarks::BookmarkBubbleObserver* bookmarkBubbleObserver_; // weak | 44 bookmarks::BookmarkBubbleObserver* bookmarkBubbleObserver_; // weak |
| 42 | 45 |
| 43 BOOL alreadyBookmarked_; | 46 BOOL alreadyBookmarked_; |
| 44 | 47 |
| 45 // Ping me when the bookmark model changes out from under us. | 48 // Ping me when the bookmark model changes out from under us. |
| 46 std::unique_ptr<BookmarkModelObserverForCocoa> bookmarkObserver_; | 49 std::unique_ptr<BookmarkModelObserverForCocoa> bookmarkObserver_; |
| 47 | 50 |
| 48 // Sync promo controller, if the sync promo is displayed. | 51 // Sync promo controller, if the sync promo is displayed. |
| 49 base::scoped_nsobject<BubbleSyncPromoController> syncPromoController_; | 52 base::scoped_nsobject<BubbleSyncPromoController> syncPromoController_; |
| 50 | 53 |
| 54 // Field editor for |nameTextField_|. |
| 55 base::scoped_nsobject<DialogTextFieldEditor> textFieldEditor_; |
| 56 |
| 51 IBOutlet NSTextField* bigTitle_; // "Bookmark" or "Bookmark Added!" | 57 IBOutlet NSTextField* bigTitle_; // "Bookmark" or "Bookmark Added!" |
| 52 IBOutlet NSTextField* nameTextField_; | 58 IBOutlet NSTextField* nameTextField_; |
| 53 IBOutlet NSPopUpButton* folderPopUpButton_; | 59 IBOutlet NSPopUpButton* folderPopUpButton_; |
| 54 IBOutlet NSView* syncPromoPlaceholder_; | 60 IBOutlet NSView* syncPromoPlaceholder_; |
| 55 IBOutlet NSView* fieldLabelsContainer_; | 61 IBOutlet NSView* fieldLabelsContainer_; |
| 56 IBOutlet NSView* trailingButtonContainer_; | 62 IBOutlet NSView* trailingButtonContainer_; |
| 57 } | 63 } |
| 58 | 64 |
| 59 @property(readonly, nonatomic) const bookmarks::BookmarkNode* node; | 65 @property(readonly, nonatomic) const bookmarks::BookmarkNode* node; |
| 60 | 66 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 | 79 |
| 74 // Actions for buttons in the dialog. | 80 // Actions for buttons in the dialog. |
| 75 - (IBAction)ok:(id)sender; | 81 - (IBAction)ok:(id)sender; |
| 76 - (IBAction)remove:(id)sender; | 82 - (IBAction)remove:(id)sender; |
| 77 - (IBAction)cancel:(id)sender; | 83 - (IBAction)cancel:(id)sender; |
| 78 | 84 |
| 79 // These actions send a -editBookmarkNode: action up the responder chain. | 85 // These actions send a -editBookmarkNode: action up the responder chain. |
| 80 - (IBAction)edit:(id)sender; | 86 - (IBAction)edit:(id)sender; |
| 81 - (IBAction)folderChanged:(id)sender; | 87 - (IBAction)folderChanged:(id)sender; |
| 82 | 88 |
| 89 // Overridden to customize the touch bar. |
| 90 - (NSTouchBar*)makeTouchBar; |
| 91 |
| 83 @end | 92 @end |
| 84 | 93 |
| 85 | 94 |
| 86 // Exposed only for unit testing. | 95 // Exposed only for unit testing. |
| 87 @interface BookmarkBubbleController (ExposedForUnitTesting) | 96 @interface BookmarkBubbleController (ExposedForUnitTesting) |
| 88 | 97 |
| 89 @property(nonatomic, readonly) NSView* syncPromoPlaceholder; | 98 @property(nonatomic, readonly) NSView* syncPromoPlaceholder; |
| 90 @property(nonatomic, readonly) | 99 @property(nonatomic, readonly) |
| 91 bookmarks::BookmarkBubbleObserver* bookmarkBubbleObserver; | 100 bookmarks::BookmarkBubbleObserver* bookmarkBubbleObserver; |
| 92 | 101 |
| 93 - (void)addFolderNodes:(const bookmarks::BookmarkNode*)parent | 102 - (void)addFolderNodes:(const bookmarks::BookmarkNode*)parent |
| 94 toPopUpButton:(NSPopUpButton*)button | 103 toPopUpButton:(NSPopUpButton*)button |
| 95 indentation:(int)indentation; | 104 indentation:(int)indentation; |
| 96 - (void)setTitle:(NSString*)title | 105 - (void)setTitle:(NSString*)title |
| 97 parentFolder:(const bookmarks::BookmarkNode*)parent; | 106 parentFolder:(const bookmarks::BookmarkNode*)parent; |
| 98 - (void)setParentFolderSelection:(const bookmarks::BookmarkNode*)parent; | 107 - (void)setParentFolderSelection:(const bookmarks::BookmarkNode*)parent; |
| 99 + (NSString*)chooseAnotherFolderString; | 108 + (NSString*)chooseAnotherFolderString; |
| 100 - (NSPopUpButton*)folderPopUpButton; | 109 - (NSPopUpButton*)folderPopUpButton; |
| 101 @end | 110 @end |
| 102 | 111 |
| 103 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUBBLE_CONTROLLER_H_ | 112 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUBBLE_CONTROLLER_H_ |
| OLD | NEW |