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_model.h" | 5 #include "components/bookmarks/browser/bookmark_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 std::vector<const BookmarkNode*>* nodes) { | 500 std::vector<const BookmarkNode*>* nodes) { |
501 base::AutoLock url_lock(url_lock_); | 501 base::AutoLock url_lock(url_lock_); |
502 BookmarkNode tmp_node(url); | 502 BookmarkNode tmp_node(url); |
503 NodesOrderedByURLSet::iterator i = nodes_ordered_by_url_set_.find(&tmp_node); | 503 NodesOrderedByURLSet::iterator i = nodes_ordered_by_url_set_.find(&tmp_node); |
504 while (i != nodes_ordered_by_url_set_.end() && (*i)->url() == url) { | 504 while (i != nodes_ordered_by_url_set_.end() && (*i)->url() == url) { |
505 nodes->push_back(*i); | 505 nodes->push_back(*i); |
506 ++i; | 506 ++i; |
507 } | 507 } |
508 } | 508 } |
509 | 509 |
510 void BookmarkModel::GetNodesByURLAndTitle( | |
sky
2014/08/18 16:15:21
There is no reason for this in BookmarkModel.
Deepak
2014/08/19 11:42:19
we need this function so that I can make vector of
sky
2014/08/19 16:38:31
This function is only useful in one place and does
| |
511 const GURL& url, | |
512 const base::string16& title, | |
513 const BookmarkNode* parent, | |
514 std::vector<const BookmarkNode*>* nodes, | |
515 std::vector<base::string16>* titles) { | |
516 base::AutoLock url_lock(url_lock_); | |
517 BookmarkNode tmp_node(url); | |
518 NodesOrderedByURLSet::iterator i = nodes_ordered_by_url_set_.find(&tmp_node); | |
519 while (i != nodes_ordered_by_url_set_.end() && (*i)->url() == url) { | |
520 if ((parent == (*i)->parent()) && | |
521 (title == (*i)->GetTitle() || | |
522 StartsWith((*i)->GetTitle(), title, false))) { | |
sky
2014/08/19 16:38:31
The StartsWith logic makes no sense here.
| |
523 titles->push_back((*i)->GetTitle()); | |
524 nodes->push_back(*i); | |
525 } | |
526 ++i; | |
527 } | |
528 } | |
529 | |
510 const BookmarkNode* BookmarkModel::GetMostRecentlyAddedUserNodeForURL( | 530 const BookmarkNode* BookmarkModel::GetMostRecentlyAddedUserNodeForURL( |
511 const GURL& url) { | 531 const GURL& url) { |
512 std::vector<const BookmarkNode*> nodes; | 532 std::vector<const BookmarkNode*> nodes; |
513 GetNodesByURL(url, &nodes); | 533 GetNodesByURL(url, &nodes); |
514 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); | 534 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); |
515 | 535 |
516 // Look for the first node that the user can edit. | 536 // Look for the first node that the user can edit. |
517 for (size_t i = 0; i < nodes.size(); ++i) { | 537 for (size_t i = 0; i < nodes.size(); ++i) { |
518 if (client_->CanBeEditedByUser(nodes[i])) | 538 if (client_->CanBeEditedByUser(nodes[i])) |
519 return nodes[i]; | 539 return nodes[i]; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 BookmarkPermanentNode* mobile_node = | 1028 BookmarkPermanentNode* mobile_node = |
1009 CreatePermanentNode(BookmarkNode::MOBILE); | 1029 CreatePermanentNode(BookmarkNode::MOBILE); |
1010 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( | 1030 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( |
1011 bb_node, | 1031 bb_node, |
1012 other_node, | 1032 other_node, |
1013 mobile_node, | 1033 mobile_node, |
1014 client_->GetLoadExtraNodesCallback(), | 1034 client_->GetLoadExtraNodesCallback(), |
1015 new BookmarkIndex(client_, index_urls_, accept_languages), | 1035 new BookmarkIndex(client_, index_urls_, accept_languages), |
1016 next_node_id_)); | 1036 next_node_id_)); |
1017 } | 1037 } |
OLD | NEW |