OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_name_folder_controller.h" |
6 | 6 |
7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 [nameField_ setStringValue:initialName_.get()]; | 75 [nameField_ setStringValue:initialName_.get()]; |
76 [[nameField_ cell] setUsesSingleLineMode:YES]; | 76 [[nameField_ cell] setUsesSingleLineMode:YES]; |
77 | 77 |
78 [okButton_ setTitle:l10n_util::GetNSStringWithFixup(node_ ? IDS_SAVE : | 78 [okButton_ setTitle:l10n_util::GetNSStringWithFixup(node_ ? IDS_SAVE : |
79 IDS_ADD)]; | 79 IDS_ADD)]; |
80 } | 80 } |
81 | 81 |
82 - (void)runAsModalSheet { | 82 - (void)runAsModalSheet { |
83 // Ping me when things change out from under us. | 83 // Ping me when things change out from under us. |
84 observer_.reset(new BookmarkModelObserverForCocoa( | 84 observer_.reset(new BookmarkModelObserverForCocoa( |
85 BookmarkModelFactory::GetForProfile(profile_), ^() { | 85 BookmarkModelFactory::GetForBrowserContext(profile_), ^() { |
86 [self cancel:nil]; | 86 [self cancel:nil]; |
87 })); | 87 })); |
88 observer_->StartObservingNode(node_); | 88 observer_->StartObservingNode(node_); |
89 [NSApp beginSheet:[self window] | 89 [NSApp beginSheet:[self window] |
90 modalForWindow:parentWindow_ | 90 modalForWindow:parentWindow_ |
91 modalDelegate:self | 91 modalDelegate:self |
92 didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) | 92 didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) |
93 contextInfo:nil]; | 93 contextInfo:nil]; |
94 } | 94 } |
95 | 95 |
96 - (IBAction)cancel:(id)sender { | 96 - (IBAction)cancel:(id)sender { |
97 [NSApp endSheet:[self window]]; | 97 [NSApp endSheet:[self window]]; |
98 } | 98 } |
99 | 99 |
100 - (IBAction)ok:(id)sender { | 100 - (IBAction)ok:(id)sender { |
101 NSString* name = [nameField_ stringValue]; | 101 NSString* name = [nameField_ stringValue]; |
102 if ([name length] == 0) | 102 if ([name length] == 0) |
103 name = l10n_util::GetNSStringWithFixup(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME); | 103 name = l10n_util::GetNSStringWithFixup(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME); |
104 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); | 104 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile_); |
105 if (node_) { | 105 if (node_) { |
106 model->SetTitle(node_, base::SysNSStringToUTF16(name)); | 106 model->SetTitle(node_, base::SysNSStringToUTF16(name)); |
107 } else { | 107 } else { |
108 model->AddFolder(parent_, | 108 model->AddFolder(parent_, |
109 newIndex_, | 109 newIndex_, |
110 base::SysNSStringToUTF16(name)); | 110 base::SysNSStringToUTF16(name)); |
111 } | 111 } |
112 [NSApp endSheet:[self window]]; | 112 [NSApp endSheet:[self window]]; |
113 } | 113 } |
114 | 114 |
(...skipping 11 matching lines...) Expand all Loading... |
126 | 126 |
127 - (void)setFolderName:(NSString*)name { | 127 - (void)setFolderName:(NSString*)name { |
128 [nameField_ setStringValue:name]; | 128 [nameField_ setStringValue:name]; |
129 } | 129 } |
130 | 130 |
131 - (NSButton*)okButton { | 131 - (NSButton*)okButton { |
132 return okButton_; | 132 return okButton_; |
133 } | 133 } |
134 | 134 |
135 @end // BookmarkNameFolderController | 135 @end // BookmarkNameFolderController |
OLD | NEW |