| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/mac_util.h" | 6 #include "base/mac_util.h" |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_editor.h" | 8 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #import "chrome/browser/cocoa/bookmark_editor_controller.h" | 11 #import "chrome/browser/cocoa/bookmark_editor_controller.h" |
| 12 | 12 |
| 13 @interface BookmarkEditorController(Private) | |
| 14 // Run the bookmark editor as a modal sheet. Does not block. | |
| 15 - (void)runModal; | |
| 16 @end | |
| 17 | |
| 18 // static; implemented for each platform. | 13 // static; implemented for each platform. |
| 19 void BookmarkEditor::Show(gfx::NativeView parent_hwnd, | 14 void BookmarkEditor::Show(gfx::NativeView parent_hwnd, |
| 20 Profile* profile, | 15 Profile* profile, |
| 21 const BookmarkNode* parent, | 16 const BookmarkNode* parent, |
| 22 const BookmarkNode* node, | 17 const BookmarkNode* node, |
| 23 Configuration configuration, | 18 Configuration configuration, |
| 24 Handler* handler) { | 19 Handler* handler) { |
| 25 NSWindow* window = [parent_hwnd window]; | 20 NSWindow* window = [parent_hwnd window]; |
| 26 BookmarkEditorController* controller = [[BookmarkEditorController alloc] | 21 BookmarkEditorController* controller = [[BookmarkEditorController alloc] |
| 27 initWithParentWindow:window | 22 initWithParentWindow:window |
| 28 profile:profile | 23 profile:profile |
| 29 parent:parent | 24 parent:parent |
| 30 node:node | 25 node:node |
| 31 configuration:configuration | 26 configuration:configuration |
| 32 handler:handler]; | 27 handler:handler]; |
| 33 [controller runModal]; | 28 [controller runAsModalSheet]; |
| 34 } | 29 } |
| 35 | 30 |
| 36 | 31 |
| 37 @implementation BookmarkEditorController | 32 @implementation BookmarkEditorController |
| 38 | 33 |
| 39 - (id)initWithParentWindow:(NSWindow*)parentWindow | 34 - (id)initWithParentWindow:(NSWindow*)parentWindow |
| 40 profile:(Profile*)profile | 35 profile:(Profile*)profile |
| 41 parent:(const BookmarkNode*)parent | 36 parent:(const BookmarkNode*)parent |
| 42 node:(const BookmarkNode*)node | 37 node:(const BookmarkNode*)node |
| 43 configuration:(BookmarkEditor::Configuration)configuration | 38 configuration:(BookmarkEditor::Configuration)configuration |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // somewhere other than at the top of the window. NOTE: this means | 95 // somewhere other than at the top of the window. NOTE: this means |
| 101 // that I, the controller, am also the window's delegate. | 96 // that I, the controller, am also the window's delegate. |
| 102 - (NSRect)window:(NSWindow*)window willPositionSheet:(NSWindow*)sheet | 97 - (NSRect)window:(NSWindow*)window willPositionSheet:(NSWindow*)sheet |
| 103 usingRect:(NSRect)rect { | 98 usingRect:(NSRect)rect { |
| 104 // adjust rect.origin.y to be the bottom of the toolbar | 99 // adjust rect.origin.y to be the bottom of the toolbar |
| 105 return rect; | 100 return rect; |
| 106 } | 101 } |
| 107 */ | 102 */ |
| 108 | 103 |
| 109 // TODO(jrg): consider NSModalSession. | 104 // TODO(jrg): consider NSModalSession. |
| 110 - (void)runModal { | 105 - (void)runAsModalSheet { |
| 111 [NSApp beginSheet:[self window] | 106 [NSApp beginSheet:[self window] |
| 112 modalForWindow:parentWindow_ | 107 modalForWindow:parentWindow_ |
| 113 modalDelegate:self | 108 modalDelegate:self |
| 114 didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) | 109 didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) |
| 115 contextInfo:nil]; | 110 contextInfo:nil]; |
| 116 } | 111 } |
| 117 | 112 |
| 118 // TODO(jrg) | 113 // TODO(jrg) |
| 119 - (IBAction)newFolder:(id)sender { | 114 - (IBAction)newFolder:(id)sender { |
| 120 NOTIMPLEMENTED(); | 115 NOTIMPLEMENTED(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 [urlField_ setStringValue:name]; | 208 [urlField_ setStringValue:name]; |
| 214 [self controlTextDidChange:nil]; | 209 [self controlTextDidChange:nil]; |
| 215 } | 210 } |
| 216 | 211 |
| 217 - (BOOL)okButtonEnabled { | 212 - (BOOL)okButtonEnabled { |
| 218 return [okButton_ isEnabled]; | 213 return [okButton_ isEnabled]; |
| 219 } | 214 } |
| 220 | 215 |
| 221 @end // BookmarkEditorController | 216 @end // BookmarkEditorController |
| 222 | 217 |
| OLD | NEW |