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

Side by Side Diff: components/bookmarks/managed/managed_bookmarks_tracker.cc

Issue 2379863002: Fix object ownership in ui/base/models. (Closed)
Patch Set: fix Created 4 years, 2 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/bookmarks/managed/managed_bookmarks_tracker.h" 5 #include "components/bookmarks/managed/managed_bookmarks_tracker.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const base::ListValue* list, 53 const base::ListValue* list,
54 int64_t next_node_id) { 54 int64_t next_node_id) {
55 for (size_t i = 0; i < list->GetSize(); ++i) { 55 for (size_t i = 0; i < list->GetSize(); ++i) {
56 // Extract the data for the next bookmark from the |list|. 56 // Extract the data for the next bookmark from the |list|.
57 base::string16 title; 57 base::string16 title;
58 GURL url; 58 GURL url;
59 const base::ListValue* children = NULL; 59 const base::ListValue* children = NULL;
60 if (!LoadBookmark(list, i, &title, &url, &children)) 60 if (!LoadBookmark(list, i, &title, &url, &children))
61 continue; 61 continue;
62 62
63 BookmarkNode* child = new BookmarkNode(next_node_id++, url); 63 BookmarkNode* child =
64 folder->Add(base::MakeUnique<BookmarkNode>(next_node_id++, url),
65 folder->child_count());
64 child->SetTitle(title); 66 child->SetTitle(title);
65 folder->Add(child, folder->child_count());
66 if (children) { 67 if (children) {
67 child->set_type(BookmarkNode::FOLDER); 68 child->set_type(BookmarkNode::FOLDER);
68 child->set_date_folder_modified(base::Time::Now()); 69 child->set_date_folder_modified(base::Time::Now());
69 next_node_id = LoadInitial(child, children, next_node_id); 70 next_node_id = LoadInitial(child, children, next_node_id);
70 } else { 71 } else {
71 child->set_type(BookmarkNode::URL); 72 child->set_type(BookmarkNode::URL);
72 child->set_date_added(base::Time::Now()); 73 child->set_date_added(base::Time::Now());
73 } 74 }
74 } 75 }
75 76
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return false; 207 return false;
207 } 208 }
208 if (!*children) { 209 if (!*children) {
209 *url = GURL(spec); 210 *url = GURL(spec);
210 DCHECK(url->is_valid()); 211 DCHECK(url->is_valid());
211 } 212 }
212 return true; 213 return true;
213 } 214 }
214 215
215 } // namespace policy 216 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698