OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 PrefService::UNSYNCABLE_PREF); | 639 PrefService::UNSYNCABLE_PREF); |
640 } | 640 } |
641 | 641 |
642 void GetURLAndTitleToBookmark(TabContents* tab_contents, | 642 void GetURLAndTitleToBookmark(TabContents* tab_contents, |
643 GURL* url, | 643 GURL* url, |
644 string16* title) { | 644 string16* title) { |
645 *url = tab_contents->GetURL(); | 645 *url = tab_contents->GetURL(); |
646 *title = tab_contents->GetTitle(); | 646 *title = tab_contents->GetTitle(); |
647 } | 647 } |
648 | 648 |
| 649 void GetURLAndTitleToBookmarkFromCurrentTab(Profile* profile, |
| 650 GURL* url, |
| 651 string16* title) { |
| 652 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
| 653 TabContents* tab_contents = browser ? browser->GetSelectedTabContents() |
| 654 : NULL; |
| 655 if (tab_contents) |
| 656 GetURLAndTitleToBookmark(tab_contents, url, title); |
| 657 } |
| 658 |
649 void GetURLsForOpenTabs(Browser* browser, | 659 void GetURLsForOpenTabs(Browser* browser, |
650 std::vector<std::pair<GURL, string16> >* urls) { | 660 std::vector<std::pair<GURL, string16> >* urls) { |
651 for (int i = 0; i < browser->tab_count(); ++i) { | 661 for (int i = 0; i < browser->tab_count(); ++i) { |
652 std::pair<GURL, string16> entry; | 662 std::pair<GURL, string16> entry; |
653 GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &(entry.first), | 663 GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &(entry.first), |
654 &(entry.second)); | 664 &(entry.second)); |
655 urls->push_back(entry); | 665 urls->push_back(entry); |
656 } | 666 } |
657 } | 667 } |
658 | 668 |
(...skipping 29 matching lines...) Expand all Loading... |
688 return true; | 698 return true; |
689 | 699 |
690 for (int i = 0; i < node->child_count(); ++i) { | 700 for (int i = 0; i < node->child_count(); ++i) { |
691 if (NodeHasURLs(node->GetChild(i))) | 701 if (NodeHasURLs(node->GetChild(i))) |
692 return true; | 702 return true; |
693 } | 703 } |
694 return false; | 704 return false; |
695 } | 705 } |
696 | 706 |
697 } // namespace bookmark_utils | 707 } // namespace bookmark_utils |
OLD | NEW |