OLD | NEW |
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/browser/bookmark_utils.h" | 5 #include "components/bookmarks/browser/bookmark_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Updates |title| such that |url| and |title| pair are unique among the | 255 // Updates |title| such that |url| and |title| pair are unique among the |
256 // children of |parent|. | 256 // children of |parent|. |
257 void MakeTitleUnique(const BookmarkModel* model, | 257 void MakeTitleUnique(const BookmarkModel* model, |
258 const BookmarkNode* parent, | 258 const BookmarkNode* parent, |
259 const GURL& url, | 259 const GURL& url, |
260 base::string16* title) { | 260 base::string16* title) { |
261 base::hash_set<base::string16> titles; | 261 base::hash_set<base::string16> titles; |
262 for (int i = 0; i < parent->child_count(); i++) { | 262 for (int i = 0; i < parent->child_count(); i++) { |
263 const BookmarkNode* node = parent->GetChild(i); | 263 const BookmarkNode* node = parent->GetChild(i); |
264 if (node->is_url() && (url == node->url()) && | 264 if (node->is_url() && (url == node->url()) && |
265 StartsWith(node->GetTitle(), *title, false)) { | 265 base::StartsWith(node->GetTitle(), *title, false)) { |
266 titles.insert(node->GetTitle()); | 266 titles.insert(node->GetTitle()); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 if (titles.find(*title) == titles.end()) | 270 if (titles.find(*title) == titles.end()) |
271 return; | 271 return; |
272 | 272 |
273 for (size_t i = 0; i < titles.size(); i++) { | 273 for (size_t i = 0; i < titles.size(); i++) { |
274 const base::string16 new_title(*title + | 274 const base::string16 new_title(*title + |
275 base::ASCIIToUTF16(base::StringPrintf( | 275 base::ASCIIToUTF16(base::StringPrintf( |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list, | 546 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list, |
547 const BookmarkNode* root) { | 547 const BookmarkNode* root) { |
548 for (const BookmarkNode* node : list) { | 548 for (const BookmarkNode* node : list) { |
549 if (IsDescendantOf(node, root)) | 549 if (IsDescendantOf(node, root)) |
550 return true; | 550 return true; |
551 } | 551 } |
552 return false; | 552 return false; |
553 } | 553 } |
554 | 554 |
555 } // namespace bookmarks | 555 } // namespace bookmarks |
OLD | NEW |