OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/bookmark_editor_controller.h" | 5 #import "chrome/browser/cocoa/bookmark_editor_controller.h" |
6 #include "app/l10n_util.h" | 6 #include "app/l10n_util.h" |
| 7 #include "base/string16.h" |
7 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 | 10 |
10 @interface BookmarkEditorController (Private) | 11 @interface BookmarkEditorController (Private) |
11 | 12 |
12 // Grab the url from the text field and convert. | 13 // Grab the url from the text field and convert. |
13 - (GURL)GURLFromUrlField; | 14 - (GURL)GURLFromUrlField; |
14 | 15 |
15 @end | 16 @end |
16 | 17 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 98 } |
98 | 99 |
99 // The the bookmark's URL is assumed to be valid (otherwise the OK button | 100 // The the bookmark's URL is assumed to be valid (otherwise the OK button |
100 // should not be enabled). Previously existing bookmarks for which the | 101 // should not be enabled). Previously existing bookmarks for which the |
101 // parent has not changed are updated in-place. Those for which the parent | 102 // parent has not changed are updated in-place. Those for which the parent |
102 // has changed are removed with a new node created under the new parent. | 103 // has changed are removed with a new node created under the new parent. |
103 // Called by -[BookmarkEditorBaseController ok:]. | 104 // Called by -[BookmarkEditorBaseController ok:]. |
104 - (NSNumber*)didCommit { | 105 - (NSNumber*)didCommit { |
105 NSString* name = [[self displayName] stringByTrimmingCharactersInSet: | 106 NSString* name = [[self displayName] stringByTrimmingCharactersInSet: |
106 [NSCharacterSet newlineCharacterSet]]; | 107 [NSCharacterSet newlineCharacterSet]]; |
107 std::wstring newTitle = base::SysNSStringToWide(name); | 108 string16 newTitle = base::SysNSStringToUTF16(name); |
108 const BookmarkNode* newParentNode = [self selectedNode]; | 109 const BookmarkNode* newParentNode = [self selectedNode]; |
109 GURL newURL = [self GURLFromUrlField]; | 110 GURL newURL = [self GURLFromUrlField]; |
110 if (!newURL.is_valid()) { | 111 if (!newURL.is_valid()) { |
111 // Shouldn't be reached -- OK button should be disabled if not valid! | 112 // Shouldn't be reached -- OK button should be disabled if not valid! |
112 NOTREACHED(); | 113 NOTREACHED(); |
113 return [NSNumber numberWithBool:NO]; | 114 return [NSNumber numberWithBool:NO]; |
114 } | 115 } |
115 | 116 |
116 // Determine where the new/replacement bookmark is to go. | 117 // Determine where the new/replacement bookmark is to go. |
117 BookmarkModel* model = [self bookmarkModel]; | 118 BookmarkModel* model = [self bookmarkModel]; |
(...skipping 14 matching lines...) Expand all Loading... |
132 } | 133 } |
133 return [NSNumber numberWithBool:YES]; | 134 return [NSNumber numberWithBool:YES]; |
134 } | 135 } |
135 | 136 |
136 - (NSColor *)urlFieldColor { | 137 - (NSColor *)urlFieldColor { |
137 return [urlField_ backgroundColor]; | 138 return [urlField_ backgroundColor]; |
138 } | 139 } |
139 | 140 |
140 @end // BookmarkEditorController | 141 @end // BookmarkEditorController |
141 | 142 |
OLD | NEW |