[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 1 | // Copyright (c) 2009 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_COCOA_BOOKMARK_EDITOR_CONTROLLER_H_ | ||||
6 | #define CHROME_BROWSER_COCOA_BOOKMARK_EDITOR_CONTROLLER_H_ | ||||
7 | |||||
8 | #import <Cocoa/Cocoa.h> | ||||
9 | |||||
[email protected] | e798e192 | 2009-09-17 20:43:06 | [diff] [blame] | 10 | #import "base/cocoa_protocols_mac.h" |
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 11 | #include "base/scoped_ptr.h" |
12 | #include "base/scoped_nsobject.h" | ||||
13 | #include "chrome/browser/bookmarks/bookmark_editor.h" | ||||
14 | |||||
[email protected] | fbc93b36 | 2009-10-29 22:10:32 | [diff] [blame^] | 15 | @class BookmarkTreeBrowserCell; |
16 | |||||
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 17 | // A controller for the bookmark editor, opened with Edit... from the |
18 | // context menu of a bookmark button. | ||||
[email protected] | e798e192 | 2009-09-17 20:43:06 | [diff] [blame] | 19 | @interface BookmarkEditorController : NSWindowController<NSTextFieldDelegate> { |
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 20 | @private |
21 | IBOutlet NSTextField* nameField_; | ||||
22 | IBOutlet NSTextField* urlField_; | ||||
[email protected] | fbc93b36 | 2009-10-29 22:10:32 | [diff] [blame^] | 23 | IBOutlet NSBrowser* folderBrowser_; |
[email protected] | 12e25ac | 2009-08-05 17:28:39 | [diff] [blame] | 24 | IBOutlet NSButton* okButton_; |
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 25 | IBOutlet NSButton* newFolderButton_; |
26 | |||||
27 | NSWindow* parentWindow_; | ||||
28 | Profile* profile_; // weak | ||||
29 | const BookmarkNode* parentNode_; // weak; owned by the model | ||||
30 | const BookmarkNode* node_; // weak; owned by the model | ||||
31 | BookmarkEditor::Configuration configuration_; | ||||
32 | scoped_ptr<BookmarkEditor::Handler> handler_; // we take ownership | ||||
33 | |||||
34 | scoped_nsobject<NSString> initialName_; | ||||
35 | scoped_nsobject<NSString> initialUrl_; | ||||
[email protected] | fbc93b36 | 2009-10-29 22:10:32 | [diff] [blame^] | 36 | scoped_nsobject<BookmarkTreeBrowserCell> currentEditCell_; |
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 37 | } |
38 | |||||
39 | - (id)initWithParentWindow:(NSWindow*)parentWindow | ||||
40 | profile:(Profile*)profile | ||||
41 | parent:(const BookmarkNode*)parent | ||||
42 | node:(const BookmarkNode*)node | ||||
43 | configuration:(BookmarkEditor::Configuration)configuration | ||||
44 | handler:(BookmarkEditor::Handler*)handler; | ||||
45 | |||||
[email protected] | 7b2b994 | 2009-08-20 21:24:29 | [diff] [blame] | 46 | // Run the bookmark editor as a modal sheet. Does not block. |
47 | - (void)runAsModalSheet; | ||||
48 | |||||
[email protected] | fbc93b36 | 2009-10-29 22:10:32 | [diff] [blame^] | 49 | // Create a new folder at the end of the selected parent folder, give it |
50 | // an untitled name, and put it into editing mode. | ||||
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 51 | - (IBAction)newFolder:(id)sender; |
[email protected] | fbc93b36 | 2009-10-29 22:10:32 | [diff] [blame^] | 52 | |
53 | // Actions for the buttons at the bottom of the window. | ||||
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 54 | - (IBAction)cancel:(id)sender; |
55 | - (IBAction)ok:(id)sender; | ||||
56 | @end | ||||
57 | |||||
58 | @interface BookmarkEditorController(TestingAPI) | ||||
59 | @property (assign) NSString* displayName; | ||||
60 | @property (assign) NSString* displayURL; | ||||
[email protected] | 12e25ac | 2009-08-05 17:28:39 | [diff] [blame] | 61 | @property (readonly) BOOL okButtonEnabled; |
[email protected] | 9912cd8 | 2009-10-22 17:59:08 | [diff] [blame] | 62 | - (void)selectTestNodeInBrowser:(const BookmarkNode*)node; |
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 63 | @end |
64 | |||||
[email protected] | ee01535e | 2009-07-21 23:57:19 | [diff] [blame] | 65 | #endif /* CHROME_BROWSER_COCOA_BOOKMARK_EDITOR_CONTROLLER_H_ */ |