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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // Comparison function that compares based on date modified of the two nodes. | 173 // Comparison function that compares based on date modified of the two nodes. |
174 bool MoreRecentlyModified(const BookmarkNode* n1, const BookmarkNode* n2) { | 174 bool MoreRecentlyModified(const BookmarkNode* n1, const BookmarkNode* n2) { |
175 return n1->date_group_modified() > n2->date_group_modified(); | 175 return n1->date_group_modified() > n2->date_group_modified(); |
176 } | 176 } |
177 | 177 |
178 // Returns true if |text| contains each string in |words|. This is used when | 178 // Returns true if |text| contains each string in |words|. This is used when |
179 // searching for bookmarks. | 179 // searching for bookmarks. |
180 bool DoesBookmarkTextContainWords(const string16& text, | 180 bool DoesBookmarkTextContainWords(const string16& text, |
181 const std::vector<string16>& words) { | 181 const std::vector<string16>& words) { |
182 for (size_t i = 0; i < words.size(); ++i) { | 182 for (size_t i = 0; i < words.size(); ++i) { |
183 if (text.find(words[i]) == std::wstring::npos) | 183 if (text.find(words[i]) == string16::npos) |
184 return false; | 184 return false; |
185 } | 185 } |
186 return true; | 186 return true; |
187 } | 187 } |
188 | 188 |
189 // Returns true if |node|s title or url contains the strings in |words|. | 189 // Returns true if |node|s title or url contains the strings in |words|. |
190 // |languages| argument is user's accept-language setting to decode IDN. | 190 // |languages| argument is user's accept-language setting to decode IDN. |
191 bool DoesBookmarkContainWords(const BookmarkNode* node, | 191 bool DoesBookmarkContainWords(const BookmarkNode* node, |
192 const std::vector<string16>& words, | 192 const std::vector<string16>& words, |
193 const std::wstring& languages) { | 193 const std::wstring& languages) { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 source, | 609 source, |
610 NotificationService::NoDetails()); | 610 NotificationService::NoDetails()); |
611 } | 611 } |
612 | 612 |
613 void RegisterUserPrefs(PrefService* prefs) { | 613 void RegisterUserPrefs(PrefService* prefs) { |
614 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, false); | 614 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, false); |
615 } | 615 } |
616 | 616 |
617 void GetURLAndTitleToBookmark(TabContents* tab_contents, | 617 void GetURLAndTitleToBookmark(TabContents* tab_contents, |
618 GURL* url, | 618 GURL* url, |
619 std::wstring* title) { | 619 string16* title) { |
620 *url = tab_contents->GetURL(); | 620 *url = tab_contents->GetURL(); |
621 *title = UTF16ToWideHack(tab_contents->GetTitle()); | 621 *title = tab_contents->GetTitle(); |
622 } | 622 } |
623 | 623 |
624 void GetURLsForOpenTabs(Browser* browser, | 624 void GetURLsForOpenTabs(Browser* browser, |
625 std::vector<std::pair<GURL, std::wstring> >* urls) { | 625 std::vector<std::pair<GURL, string16> >* urls) { |
626 for (int i = 0; i < browser->tab_count(); ++i) { | 626 for (int i = 0; i < browser->tab_count(); ++i) { |
627 std::pair<GURL, std::wstring> entry; | 627 std::pair<GURL, string16> entry; |
628 GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &(entry.first), | 628 GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &(entry.first), |
629 &(entry.second)); | 629 &(entry.second)); |
630 urls->push_back(entry); | 630 urls->push_back(entry); |
631 } | 631 } |
632 } | 632 } |
633 | 633 |
634 const BookmarkNode* GetParentForNewNodes( | 634 const BookmarkNode* GetParentForNewNodes( |
635 const BookmarkNode* parent, | 635 const BookmarkNode* parent, |
636 const std::vector<const BookmarkNode*>& selection, | 636 const std::vector<const BookmarkNode*>& selection, |
637 int* index) { | 637 int* index) { |
(...skipping 12 matching lines...) Expand all 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 |