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"
13 class BookmarkModelObserverForCocoa
;
17 // A controller for dialog to let the user create a new folder or
18 // rename an existing folder. Accessible from a context menu on a
19 // bookmark button or the bookmark bar.
20 @interface BookmarkNameFolderController
: NSWindowController
{
22 IBOutlet NSTextField
* nameField_
;
23 IBOutlet NSButton
* okButton_
;
25 NSWindow
* parentWindow_
; // weak
26 Profile
* profile_
; // weak
28 // Weak; owned by the model. Can be NULL (see below). Either node_
29 // is non-NULL (renaming a folder), or parent_ is non-NULL (adding a
31 const BookmarkNode
* node_
;
32 const BookmarkNode
* parent_
;
35 base::scoped_nsobject
<NSString
> initialName_
;
37 // Ping me when things change out from under us.
38 scoped_ptr
<BookmarkModelObserverForCocoa
> observer_
;
41 // Use the 1st initializer for a "rename existing folder" request.
43 // Use the 2nd initializer for an "add folder" request. If creating a
44 // new folder |parent| and |newIndex| specify where to put the new
46 - (id
)initWithParentWindow
:(NSWindow
*)window
47 profile
:(Profile
*)profile
48 node
:(const BookmarkNode
*)node
;
49 - (id
)initWithParentWindow
:(NSWindow
*)window
50 profile
:(Profile
*)profile
51 parent
:(const BookmarkNode
*)parent
52 newIndex
:(int)newIndex
;
53 - (void)runAsModalSheet
;
54 - (IBAction
)cancel
:(id
)sender
;
55 - (IBAction
)ok
:(id
)sender
;
58 @interface
BookmarkNameFolderController(TestingAPI
)
59 - (NSString
*)folderName
;
60 - (void)setFolderName
:(NSString
*)name
;
61 - (NSButton
*)okButton
;
64 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_