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

Side by Side Diff: components/bookmarks/browser/bookmark_utils.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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/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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698