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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.mm

Issue 2721553004: Remove auto raw pointer deduction from non-linux specific code. (Closed)
Patch Set: rebase Created 3 years, 9 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 const NodeVector& vector, 401 const NodeVector& vector,
402 std::vector<std::unique_ptr<NodesSection>>& nodesSectionVector) { 402 std::vector<std::unique_ptr<NodesSection>>& nodesSectionVector) {
403 nodesSectionVector.clear(); 403 nodesSectionVector.clear();
404 404
405 // Make a localized date formatter. 405 // Make a localized date formatter.
406 base::scoped_nsobject<NSDateFormatter> formatter( 406 base::scoped_nsobject<NSDateFormatter> formatter(
407 [[NSDateFormatter alloc] init]); 407 [[NSDateFormatter alloc] init]);
408 [formatter setDateFormat:@"MMMM yyyy"]; 408 [formatter setDateFormat:@"MMMM yyyy"];
409 // Segregate nodes by creation date. 409 // Segregate nodes by creation date.
410 // Nodes that were created in the same month are grouped together. 410 // Nodes that were created in the same month are grouped together.
411 for (auto node : vector) { 411 for (auto* node : vector) {
412 base::mac::ScopedNSAutoreleasePool pool; 412 base::mac::ScopedNSAutoreleasePool pool;
413 base::Time dateAdded = node->date_added(); 413 base::Time dateAdded = node->date_added();
414 base::TimeDelta delta = dateAdded - base::Time::UnixEpoch(); 414 base::TimeDelta delta = dateAdded - base::Time::UnixEpoch();
415 base::scoped_nsobject<NSDate> date( 415 base::scoped_nsobject<NSDate> date(
416 [[NSDate alloc] initWithTimeIntervalSince1970:delta.InSeconds()]); 416 [[NSDate alloc] initWithTimeIntervalSince1970:delta.InSeconds()]);
417 NSString* dateString = [formatter stringFromDate:date]; 417 NSString* dateString = [formatter stringFromDate:date];
418 const std::string timeRepresentation = base::SysNSStringToUTF8(dateString); 418 const std::string timeRepresentation = base::SysNSStringToUTF8(dateString);
419 419
420 BOOL found = NO; 420 BOOL found = NO;
421 for (const auto& nodesSection : nodesSectionVector) { 421 for (const auto& nodesSection : nodesSectionVector) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 524 }
525 525
526 bookmark_utils_ios::SortFolders(&directDescendants); 526 bookmark_utils_ios::SortFolders(&directDescendants);
527 527
528 auto it = std::find(results->begin(), results->end(), folder); 528 auto it = std::find(results->begin(), results->end(), folder);
529 DCHECK(it != results->end()); 529 DCHECK(it != results->end());
530 ++it; 530 ++it;
531 results->insert(it, directDescendants.begin(), directDescendants.end()); 531 results->insert(it, directDescendants.begin(), directDescendants.end());
532 532
533 // Recursively perform the operation on each direct descendant. 533 // Recursively perform the operation on each direct descendant.
534 for (auto node : directDescendants) 534 for (auto* node : directDescendants)
535 UpdateFoldersFromNode(node, results, obstructions); 535 UpdateFoldersFromNode(node, results, obstructions);
536 } 536 }
537 537
538 void SortFolders(NodeVector* vector) { 538 void SortFolders(NodeVector* vector) {
539 UErrorCode error = U_ZERO_ERROR; 539 UErrorCode error = U_ZERO_ERROR;
540 std::unique_ptr<icu::Collator> collator(icu::Collator::createInstance(error)); 540 std::unique_ptr<icu::Collator> collator(icu::Collator::createInstance(error));
541 if (U_FAILURE(error)) 541 if (U_FAILURE(error))
542 collator.reset(NULL); 542 collator.reset(NULL);
543 std::sort(vector->begin(), vector->end(), 543 std::sort(vector->begin(), vector->end(),
544 FolderNodeComparator(collator.get())); 544 FolderNodeComparator(collator.get()));
545 } 545 }
546 546
547 NodeVector VisibleNonDescendantNodes(const NodeSet& obstructions, 547 NodeVector VisibleNonDescendantNodes(const NodeSet& obstructions,
548 bookmarks::BookmarkModel* model) { 548 bookmarks::BookmarkModel* model) {
549 NodeVector results; 549 NodeVector results;
550 550
551 NodeVector primaryNodes = PrimaryPermanentNodes(model); 551 NodeVector primaryNodes = PrimaryPermanentNodes(model);
552 NodeVector filteredPrimaryNodes; 552 NodeVector filteredPrimaryNodes;
553 for (auto node : primaryNodes) { 553 for (auto* node : primaryNodes) {
554 if (IsObstructed(node, obstructions)) 554 if (IsObstructed(node, obstructions))
555 continue; 555 continue;
556 556
557 filteredPrimaryNodes.push_back(node); 557 filteredPrimaryNodes.push_back(node);
558 } 558 }
559 559
560 // Copy the results over. 560 // Copy the results over.
561 results = filteredPrimaryNodes; 561 results = filteredPrimaryNodes;
562 562
563 // Iterate over a static copy of the filtered, root folders. 563 // Iterate over a static copy of the filtered, root folders.
564 for (auto node : filteredPrimaryNodes) 564 for (auto* node : filteredPrimaryNodes)
565 UpdateFoldersFromNode(node, &results, obstructions); 565 UpdateFoldersFromNode(node, &results, obstructions);
566 566
567 return results; 567 return results;
568 } 568 }
569 569
570 // Whether |vector1| contains only elements of |vector2| in the same order. 570 // Whether |vector1| contains only elements of |vector2| in the same order.
571 BOOL IsSubvectorOfNodes(const NodeVector& vector1, const NodeVector& vector2) { 571 BOOL IsSubvectorOfNodes(const NodeVector& vector1, const NodeVector& vector2) {
572 NodeVector::const_iterator it = vector2.begin(); 572 NodeVector::const_iterator it = vector2.begin();
573 // Scan the first vector. 573 // Scan the first vector.
574 for (const auto& node : vector1) { 574 for (const auto* node : vector1) {
575 // Look for a match in the rest of the second vector. When found, advance 575 // Look for a match in the rest of the second vector. When found, advance
576 // the iterator on vector2 to only focus on the remaining part of vector2, 576 // the iterator on vector2 to only focus on the remaining part of vector2,
577 // so that ordering is verified. 577 // so that ordering is verified.
578 it = std::find(it, vector2.end(), node); 578 it = std::find(it, vector2.end(), node);
579 if (it == vector2.end()) 579 if (it == vector2.end())
580 return NO; 580 return NO;
581 // If found in vector2, advance the iterator so that the match is only 581 // If found in vector2, advance the iterator so that the match is only
582 // matched once. 582 // matched once.
583 it++; 583 it++;
584 } 584 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 675
676 *position = cache.position; 676 *position = cache.position;
677 return YES; 677 return YES;
678 } 678 }
679 679
680 void ClearPositionCache() { 680 void ClearPositionCache() {
681 [[NSUserDefaults standardUserDefaults] removeObjectForKey:kPositionCacheKey]; 681 [[NSUserDefaults standardUserDefaults] removeObjectForKey:kPositionCacheKey];
682 } 682 }
683 683
684 } // namespace bookmark_utils_ios 684 } // namespace bookmark_utils_ios
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_menu_view.mm ('k') | ios/chrome/browser/ui/browser_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698