- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / bookmarks / bookmark_name_folder_controller.h
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
8 #import <Cocoa/Cocoa.h>
9
10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h"
13
14 class BookmarkModelObserverForCocoa;
15
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 {
20  @private
21   IBOutlet NSTextField* nameField_;
22   IBOutlet NSButton* okButton_;
23
24   NSWindow* parentWindow_;  // weak
25   Profile* profile_;  // weak
26
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
29   // new one).
30   const BookmarkNode* node_;
31   const BookmarkNode* parent_;
32   int newIndex_;
33
34   base::scoped_nsobject<NSString> initialName_;
35
36   // Ping me when things change out from under us.
37   scoped_ptr<BookmarkModelObserverForCocoa> observer_;
38 }
39
40 // Use the 1st initializer for a "rename existing folder" request.
41 //
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
44 // node.
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;
55 @end
56
57 @interface BookmarkNameFolderController(TestingAPI)
58 - (NSString*)folderName;
59 - (void)setFolderName:(NSString*)name;
60 - (NSButton*)okButton;
61 @end
62
63 #endif  // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_NAME_FOLDER_CONTROLLER_H_