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.
4
5#ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_
6#define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_
7#pragma once
8
9#import <Cocoa/Cocoa.h>
10
11#include "base/memory/scoped_nsobject.h"
12#include "base/memory/scoped_ptr.h"
13#include "chrome/browser/bookmarks/bookmark_model.h"
14
15class BookmarkModelObserverForCocoa;
16
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 {
21 @private
22  IBOutlet NSTextField* nameField_;
23  IBOutlet NSButton* okButton_;
24
25  NSWindow* parentWindow_;  // weak
26  Profile* profile_;  // weak
27
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
30  // new one).
31  const BookmarkNode* node_;
32  const BookmarkNode* parent_;
33  int newIndex_;
34
35  scoped_nsobject<NSString> initialName_;
36
37  // Ping me when things change out from under us.
38  scoped_ptr<BookmarkModelObserverForCocoa> observer_;
39}
40
41// Use the 1st initializer for a "rename existing folder" request.
42//
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
45// node.
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;
56@end
57
58@interface BookmarkNameFolderController(TestingAPI)
59- (NSString*)folderName;
60- (void)setFolderName:(NSString*)name;
61- (NSButton*)okButton;
62@end
63
64#endif  // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_
65