| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 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 base::string16 original_title_lower = base::i18n::ToLower(*title); |
| 262 for (int i = 0; i < parent->child_count(); i++) { | 263 for (int i = 0; i < parent->child_count(); i++) { |
| 263 const BookmarkNode* node = parent->GetChild(i); | 264 const BookmarkNode* node = parent->GetChild(i); |
| 264 if (node->is_url() && (url == node->url()) && | 265 if (node->is_url() && (url == node->url()) && |
| 265 base::StartsWith(node->GetTitle(), *title, false)) { | 266 base::StartsWith(base::i18n::ToLower(node->GetTitle()), |
| 267 original_title_lower, |
| 268 base::CompareCase::SENSITIVE)) { |
| 266 titles.insert(node->GetTitle()); | 269 titles.insert(node->GetTitle()); |
| 267 } | 270 } |
| 268 } | 271 } |
| 269 | 272 |
| 270 if (titles.find(*title) == titles.end()) | 273 if (titles.find(*title) == titles.end()) |
| 271 return; | 274 return; |
| 272 | 275 |
| 273 for (size_t i = 0; i < titles.size(); i++) { | 276 for (size_t i = 0; i < titles.size(); i++) { |
| 274 const base::string16 new_title(*title + | 277 const base::string16 new_title(*title + |
| 275 base::ASCIIToUTF16(base::StringPrintf( | 278 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, | 549 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list, |
| 547 const BookmarkNode* root) { | 550 const BookmarkNode* root) { |
| 548 for (const BookmarkNode* node : list) { | 551 for (const BookmarkNode* node : list) { |
| 549 if (IsDescendantOf(node, root)) | 552 if (IsDescendantOf(node, root)) |
| 550 return true; | 553 return true; |
| 551 } | 554 } |
| 552 return false; | 555 return false; |
| 553 } | 556 } |
| 554 | 557 |
| 555 } // namespace bookmarks | 558 } // namespace bookmarks |
| OLD | NEW |