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