OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/bookmarks/bookmark_utils.h" | 5 #include "chrome/browser/bookmarks/bookmark_utils.h" |
6 | 6 |
7 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/tree_node_iterator.h" | 9 #include "app/tree_node_iterator.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 494 } |
495 } | 495 } |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 bool MoreRecentlyAdded(const BookmarkNode* n1, const BookmarkNode* n2) { | 499 bool MoreRecentlyAdded(const BookmarkNode* n1, const BookmarkNode* n2) { |
500 return n1->date_added() > n2->date_added(); | 500 return n1->date_added() > n2->date_added(); |
501 } | 501 } |
502 | 502 |
503 void GetBookmarksContainingText(BookmarkModel* model, | 503 void GetBookmarksContainingText(BookmarkModel* model, |
504 const std::wstring& text, | 504 const string16& text, |
505 size_t max_count, | 505 size_t max_count, |
506 const std::wstring& languages, | 506 const std::wstring& languages, |
507 std::vector<const BookmarkNode*>* nodes) { | 507 std::vector<const BookmarkNode*>* nodes) { |
508 std::vector<string16> words; | 508 std::vector<string16> words; |
509 QueryParser parser; | 509 QueryParser parser; |
510 parser.ExtractQueryWords(l10n_util::ToLower(WideToUTF16(text)), &words); | 510 parser.ExtractQueryWords(l10n_util::ToLower(text), &words); |
511 if (words.empty()) | 511 if (words.empty()) |
512 return; | 512 return; |
513 | 513 |
514 TreeNodeIterator<const BookmarkNode> iterator(model->root_node()); | 514 TreeNodeIterator<const BookmarkNode> iterator(model->root_node()); |
515 while (iterator.has_next()) { | 515 while (iterator.has_next()) { |
516 const BookmarkNode* node = iterator.Next(); | 516 const BookmarkNode* node = iterator.Next(); |
517 if (node->is_url() && DoesBookmarkContainWords(node, words, languages)) { | 517 if (node->is_url() && DoesBookmarkContainWords(node, words, languages)) { |
518 nodes->push_back(node); | 518 nodes->push_back(node); |
519 if (nodes->size() == max_count) | 519 if (nodes->size() == max_count) |
520 return; | 520 return; |
521 } | 521 } |
522 } | 522 } |
523 } | 523 } |
524 | 524 |
525 bool DoesBookmarkContainText(const BookmarkNode* node, | 525 bool DoesBookmarkContainText(const BookmarkNode* node, |
526 const std::wstring& text, | 526 const string16& text, |
527 const std::wstring& languages) { | 527 const std::wstring& languages) { |
528 std::vector<string16> words; | 528 std::vector<string16> words; |
529 QueryParser parser; | 529 QueryParser parser; |
530 parser.ExtractQueryWords(l10n_util::ToLower(WideToUTF16(text)), &words); | 530 parser.ExtractQueryWords(l10n_util::ToLower(text), &words); |
531 if (words.empty()) | 531 if (words.empty()) |
532 return false; | 532 return false; |
533 | 533 |
534 return (node->is_url() && DoesBookmarkContainWords(node, words, languages)); | 534 return (node->is_url() && DoesBookmarkContainWords(node, words, languages)); |
535 } | 535 } |
536 | 536 |
537 static const BookmarkNode* CreateNewNode(BookmarkModel* model, | 537 static const BookmarkNode* CreateNewNode(BookmarkModel* model, |
538 const BookmarkNode* parent, const BookmarkEditor::EditDetails& details, | 538 const BookmarkNode* parent, const BookmarkEditor::EditDetails& details, |
539 const string16& new_title, const GURL& new_url) { | 539 const string16& new_title, const GURL& new_url) { |
540 const BookmarkNode* node; | 540 const BookmarkNode* node; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 } | 650 } |
651 } else { | 651 } else { |
652 *index = real_parent->GetChildCount(); | 652 *index = real_parent->GetChildCount(); |
653 } | 653 } |
654 } | 654 } |
655 | 655 |
656 return real_parent; | 656 return real_parent; |
657 } | 657 } |
658 | 658 |
659 } // namespace bookmark_utils | 659 } // namespace bookmark_utils |
OLD | NEW |