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
;
20 // 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 // bookmark button or the bookmark bar.
23 @interface BookmarkNameFolderController
: NSWindowController
{
25 IBOutlet NSTextField
* nameField_
;
26 IBOutlet NSButton
* okButton_
;
28 NSWindow
* parentWindow_
; // weak
29 Profile
* profile_
; // weak
31 // 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
34 const bookmarks::BookmarkNode
* node_
;
35 const bookmarks::BookmarkNode
* parent_
;
38 base::scoped_nsobject
<NSString
> initialName_
;
40 // Ping me when things change out from under us.
41 scoped_ptr
<BookmarkModelObserverForCocoa
> observer_
;
44 // Use the 1st initializer for a "rename existing folder" request.
46 // Use the 2nd initializer for an "add folder" request. If creating a
47 // new folder |parent| and |newIndex| specify where to put the new
49 - (id
)initWithParentWindow
:(NSWindow
*)window
50 profile
:(Profile
*)profile
51 node
:(const bookmarks::BookmarkNode
*)node
;
52 - (id
)initWithParentWindow
:(NSWindow
*)window
53 profile
:(Profile
*)profile
54 parent
:(const bookmarks::BookmarkNode
*)parent
55 newIndex
:(int)newIndex
;
56 - (void)runAsModalSheet
;
57 - (IBAction
)cancel
:(id
)sender
;
58 - (IBAction
)ok
:(id
)sender
;
61 @interface
BookmarkNameFolderController(TestingAPI
)
62 - (NSString
*)folderName
;
63 - (void)setFolderName
:(NSString
*)name
;
64 - (NSButton
*)okButton
;
67 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_