Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1072)

Side by Side Diff: chrome/browser/cocoa/bookmark_editor_controller.mm

Issue 393006: Change the folder presentation in the Bookmark Editor and the Bookmark All Ta... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #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/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 9
10 @interface BookmarkEditorController (Private) 10 @interface BookmarkEditorController (Private)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 GURL newURL = [self GURLFromUrlField]; 80 GURL newURL = [self GURLFromUrlField];
81 okEnabled = (newURL.is_valid()) ? YES : NO; 81 okEnabled = (newURL.is_valid()) ? YES : NO;
82 } 82 }
83 return okEnabled; 83 return okEnabled;
84 } 84 }
85 85
86 // The the bookmark's URL is assumed to be valid (otherwise the OK button 86 // The the bookmark's URL is assumed to be valid (otherwise the OK button
87 // should not be enabled). If the bookmark previously existed then it is 87 // should not be enabled). If the bookmark previously existed then it is
88 // removed from its old folder. The bookmark is then added to its new 88 // removed from its old folder. The bookmark is then added to its new
89 // folder. If the folder has not changed then the bookmark stays in its 89 // folder. If the folder has not changed then the bookmark stays in its
90 // original position (index) otherwise it is added to the end of the new folder. 90 // original position (index) otherwise it is added to the end of the new
91 - (IBAction)ok:(id)sender { 91 // folder. Called by -[BookmarkEditorBaseController ok:].
92 - (NSNumber*)didCommit {
92 NSString* name = [[self displayName] stringByTrimmingCharactersInSet: 93 NSString* name = [[self displayName] stringByTrimmingCharactersInSet:
93 [NSCharacterSet newlineCharacterSet]]; 94 [NSCharacterSet newlineCharacterSet]];
94 std::wstring newTitle = base::SysNSStringToWide(name); 95 std::wstring newTitle = base::SysNSStringToWide(name);
95 const BookmarkNode* newParentNode = [self selectedNode]; 96 const BookmarkNode* newParentNode = [self selectedNode];
96 BookmarkModel* model = [self bookmarkModel]; 97 BookmarkModel* model = [self bookmarkModel];
97 int newIndex = newParentNode->GetChildCount(); 98 int newIndex = newParentNode->GetChildCount();
98 GURL newURL = [self GURLFromUrlField]; 99 GURL newURL = [self GURLFromUrlField];
99 if (!newURL.is_valid()) { 100 if (!newURL.is_valid()) {
100 // Shouldn't be reached -- OK button disabled if not valid! 101 // Shouldn't be reached -- OK button should be disabled if not valid!
101 NOTREACHED(); 102 NOTREACHED();
102 return; 103 return [NSNumber numberWithBool:NO];
103 } 104 }
104 105
105 // Determine where the new/replacement bookmark is to go. 106 // Determine where the new/replacement bookmark is to go.
106 const BookmarkNode* parentNode = [self parentNode]; 107 const BookmarkNode* parentNode = [self parentNode];
107 if (node_ && parentNode) { 108 if (node_ && parentNode) {
108 // Replace the old bookmark with the updated bookmark. 109 // Replace the old bookmark with the updated bookmark.
109 int oldIndex = parentNode->IndexOfChild(node_); 110 int oldIndex = parentNode->IndexOfChild(node_);
110 if (oldIndex >= 0) 111 if (oldIndex >= 0)
111 model->Remove(parentNode, oldIndex); 112 model->Remove(parentNode, oldIndex);
112 if (parentNode == newParentNode) 113 if (parentNode == newParentNode)
113 newIndex = oldIndex; 114 newIndex = oldIndex;
114 } 115 }
115 // Add bookmark as new node at the end of the newly selected folder. 116 // Add bookmark as new node at the end of the newly selected folder.
116 const BookmarkNode* node = model->AddURL(newParentNode, newIndex, 117 const BookmarkNode* node = model->AddURL(newParentNode, newIndex,
117 newTitle, newURL); 118 newTitle, newURL);
118 // Honor handler semantics: callback on node creation. 119 // Honor handler semantics: callback on node creation.
119 [self NotifyHandlerCreatedNode:node]; 120 [self notifyHandlerCreatedNode:node];
120 [super ok:sender]; 121 return [NSNumber numberWithBool:YES];
121 } 122 }
122 123
123 @end // BookmarkEditorController 124 @end // BookmarkEditorController
124 125
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_editor_controller.h ('k') | chrome/browser/cocoa/bookmark_editor_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698