| 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 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 | 13 |
| 13 class BookmarkModelObserverForCocoa; | 14 class BookmarkModelObserverForCocoa; |
| 14 class Profile; | 15 class Profile; |
| 15 | 16 |
| 16 namespace bookmarks { | 17 namespace bookmarks { |
| 17 class BookmarkNode; | 18 class BookmarkNode; |
| 18 } | 19 } |
| 19 | 20 |
| 20 // A controller for dialog to let the user create a new folder or | 21 // A controller for dialog to let the user create a new folder or |
| 21 // rename an existing folder. Accessible from a context menu on a | 22 // rename an existing folder. Accessible from a context menu on a |
| 22 // bookmark button or the bookmark bar. | 23 // bookmark button or the bookmark bar. |
| 23 @interface BookmarkNameFolderController : NSWindowController { | 24 @interface BookmarkNameFolderController : NSWindowController { |
| 24 @private | 25 @private |
| 25 IBOutlet NSTextField* nameField_; | 26 IBOutlet NSTextField* nameField_; |
| 26 IBOutlet NSButton* okButton_; | 27 IBOutlet NSButton* okButton_; |
| 27 | 28 |
| 28 NSWindow* parentWindow_; // weak | 29 NSWindow* parentWindow_; // weak |
| 29 Profile* profile_; // weak | 30 Profile* profile_; // weak |
| 30 | 31 |
| 31 // Weak; owned by the model. Can be NULL (see below). Either node_ | 32 // Weak; owned by the model. Can be NULL (see below). Either node_ |
| 32 // is non-NULL (renaming a folder), or parent_ is non-NULL (adding a | 33 // is non-NULL (renaming a folder), or parent_ is non-NULL (adding a |
| 33 // new one). | 34 // new one). |
| 34 const bookmarks::BookmarkNode* node_; | 35 const bookmarks::BookmarkNode* node_; |
| 35 const bookmarks::BookmarkNode* parent_; | 36 const bookmarks::BookmarkNode* parent_; |
| 36 int newIndex_; | 37 int newIndex_; |
| 37 | 38 |
| 38 base::scoped_nsobject<NSString> initialName_; | 39 base::scoped_nsobject<NSString> initialName_; |
| 39 | 40 |
| 40 // Ping me when things change out from under us. | 41 // Ping me when things change out from under us. |
| 41 scoped_ptr<BookmarkModelObserverForCocoa> observer_; | 42 std::unique_ptr<BookmarkModelObserverForCocoa> observer_; |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Use the 1st initializer for a "rename existing folder" request. | 45 // Use the 1st initializer for a "rename existing folder" request. |
| 45 // | 46 // |
| 46 // Use the 2nd initializer for an "add folder" request. If creating a | 47 // Use the 2nd initializer for an "add folder" request. If creating a |
| 47 // new folder |parent| and |newIndex| specify where to put the new | 48 // new folder |parent| and |newIndex| specify where to put the new |
| 48 // node. | 49 // node. |
| 49 - (id)initWithParentWindow:(NSWindow*)window | 50 - (id)initWithParentWindow:(NSWindow*)window |
| 50 profile:(Profile*)profile | 51 profile:(Profile*)profile |
| 51 node:(const bookmarks::BookmarkNode*)node; | 52 node:(const bookmarks::BookmarkNode*)node; |
| 52 - (id)initWithParentWindow:(NSWindow*)window | 53 - (id)initWithParentWindow:(NSWindow*)window |
| 53 profile:(Profile*)profile | 54 profile:(Profile*)profile |
| 54 parent:(const bookmarks::BookmarkNode*)parent | 55 parent:(const bookmarks::BookmarkNode*)parent |
| 55 newIndex:(int)newIndex; | 56 newIndex:(int)newIndex; |
| 56 - (void)runAsModalSheet; | 57 - (void)runAsModalSheet; |
| 57 - (IBAction)cancel:(id)sender; | 58 - (IBAction)cancel:(id)sender; |
| 58 - (IBAction)ok:(id)sender; | 59 - (IBAction)ok:(id)sender; |
| 59 @end | 60 @end |
| 60 | 61 |
| 61 @interface BookmarkNameFolderController(TestingAPI) | 62 @interface BookmarkNameFolderController(TestingAPI) |
| 62 - (NSString*)folderName; | 63 - (NSString*)folderName; |
| 63 - (void)setFolderName:(NSString*)name; | 64 - (void)setFolderName:(NSString*)name; |
| 64 - (NSButton*)okButton; | 65 - (NSButton*)okButton; |
| 65 @end | 66 @end |
| 66 | 67 |
| 67 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_ | 68 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_ |
| OLD | NEW |