| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 disposition = initial_disposition; | 150 disposition = initial_disposition; |
| 151 (*navigator)->OpenURL(OpenURLParams(node->url(), content::Referrer(), | 151 (*navigator)->OpenURL(OpenURLParams(node->url(), content::Referrer(), |
| 152 disposition, content::PAGE_TRANSITION_AUTO_BOOKMARK, | 152 disposition, content::PAGE_TRANSITION_AUTO_BOOKMARK, |
| 153 false)); | 153 false)); |
| 154 if (!*opened_url) { | 154 if (!*opened_url) { |
| 155 *opened_url = true; | 155 *opened_url = true; |
| 156 // We opened the first URL which may have opened a new window or clobbered | 156 // We opened the first URL which may have opened a new window or clobbered |
| 157 // the current page, reset the navigator just to be sure. | 157 // the current page, reset the navigator just to be sure. |
| 158 Browser* new_browser = BrowserList::GetLastActiveWithProfile(profile); | 158 Browser* new_browser = BrowserList::GetLastActiveWithProfile(profile); |
| 159 if (new_browser) { | 159 if (new_browser) { |
| 160 TabContents* current_tab = new_browser->GetSelectedTabContents(); | 160 WebContents* current_tab = new_browser->GetSelectedWebContents(); |
| 161 DCHECK(new_browser && current_tab); | 161 DCHECK(new_browser && current_tab); |
| 162 if (new_browser && current_tab) | 162 if (new_browser && current_tab) |
| 163 *navigator = current_tab; | 163 *navigator = current_tab; |
| 164 } // else, new_browser == NULL, which happens during testing. | 164 } // else, new_browser == NULL, which happens during testing. |
| 165 } | 165 } |
| 166 } else { | 166 } else { |
| 167 // For folders only open direct children. | 167 // For folders only open direct children. |
| 168 for (int i = 0; i < node->child_count(); ++i) { | 168 for (int i = 0; i < node->child_count(); ++i) { |
| 169 const BookmarkNode* child_node = node->GetChild(i); | 169 const BookmarkNode* child_node = node->GetChild(i); |
| 170 if (child_node->is_url()) | 170 if (child_node->is_url()) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 Profile* profile, | 378 Profile* profile, |
| 379 PageNavigator* navigator, | 379 PageNavigator* navigator, |
| 380 const std::vector<const BookmarkNode*>& nodes, | 380 const std::vector<const BookmarkNode*>& nodes, |
| 381 WindowOpenDisposition initial_disposition) { | 381 WindowOpenDisposition initial_disposition) { |
| 382 if (!ShouldOpenAll(parent, nodes)) | 382 if (!ShouldOpenAll(parent, nodes)) |
| 383 return; | 383 return; |
| 384 | 384 |
| 385 NewBrowserPageNavigator navigator_impl(profile); | 385 NewBrowserPageNavigator navigator_impl(profile); |
| 386 if (!navigator) { | 386 if (!navigator) { |
| 387 Browser* browser = BrowserList::FindTabbedBrowser(profile, false); | 387 Browser* browser = BrowserList::FindTabbedBrowser(profile, false); |
| 388 if (!browser || !browser->GetSelectedTabContents()) { | 388 if (!browser || !browser->GetSelectedWebContents()) { |
| 389 navigator = &navigator_impl; | 389 navigator = &navigator_impl; |
| 390 } else { | 390 } else { |
| 391 if (initial_disposition != NEW_WINDOW && | 391 if (initial_disposition != NEW_WINDOW && |
| 392 initial_disposition != OFF_THE_RECORD) { | 392 initial_disposition != OFF_THE_RECORD) { |
| 393 browser->window()->Activate(); | 393 browser->window()->Activate(); |
| 394 } | 394 } |
| 395 navigator = browser->GetSelectedTabContents(); | 395 navigator = browser->GetSelectedWebContents(); |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 bool opened_url = false; | 399 bool opened_url = false; |
| 400 if (initial_disposition == OFF_THE_RECORD) | 400 if (initial_disposition == OFF_THE_RECORD) |
| 401 profile = profile->GetOffTheRecordProfile(); | 401 profile = profile->GetOffTheRecordProfile(); |
| 402 | 402 |
| 403 for (size_t i = 0; i < nodes.size(); ++i) | 403 for (size_t i = 0; i < nodes.size(); ++i) |
| 404 OpenAllImpl(nodes[i], initial_disposition, &navigator, profile, | 404 OpenAllImpl(nodes[i], initial_disposition, &navigator, profile, |
| 405 &opened_url); | 405 &opened_url); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 645 |
| 646 void RegisterUserPrefs(PrefService* prefs) { | 646 void RegisterUserPrefs(PrefService* prefs) { |
| 647 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, | 647 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, |
| 648 false, | 648 false, |
| 649 PrefService::SYNCABLE_PREF); | 649 PrefService::SYNCABLE_PREF); |
| 650 prefs->RegisterBooleanPref(prefs::kEditBookmarksEnabled, | 650 prefs->RegisterBooleanPref(prefs::kEditBookmarksEnabled, |
| 651 true, | 651 true, |
| 652 PrefService::UNSYNCABLE_PREF); | 652 PrefService::UNSYNCABLE_PREF); |
| 653 } | 653 } |
| 654 | 654 |
| 655 void GetURLAndTitleToBookmark(TabContents* tab_contents, | 655 void GetURLAndTitleToBookmark(WebContents* web_contents, |
| 656 GURL* url, | 656 GURL* url, |
| 657 string16* title) { | 657 string16* title) { |
| 658 *url = tab_contents->GetURL(); | 658 *url = web_contents->GetURL(); |
| 659 *title = tab_contents->GetTitle(); | 659 *title = web_contents->GetTitle(); |
| 660 } | 660 } |
| 661 | 661 |
| 662 void GetURLAndTitleToBookmarkFromCurrentTab(Profile* profile, | 662 void GetURLAndTitleToBookmarkFromCurrentTab(Profile* profile, |
| 663 GURL* url, | 663 GURL* url, |
| 664 string16* title) { | 664 string16* title) { |
| 665 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 665 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
| 666 TabContents* tab_contents = browser ? browser->GetSelectedTabContents() | 666 WebContents* web_contents = browser ? browser->GetSelectedWebContents() |
| 667 : NULL; | 667 : NULL; |
| 668 if (tab_contents) | 668 if (web_contents) |
| 669 GetURLAndTitleToBookmark(tab_contents, url, title); | 669 GetURLAndTitleToBookmark(web_contents, url, title); |
| 670 } | 670 } |
| 671 | 671 |
| 672 void GetURLsForOpenTabs( | 672 void GetURLsForOpenTabs( |
| 673 Browser* browser, | 673 Browser* browser, |
| 674 std::vector<std::pair<GURL, string16> >* urls) { | 674 std::vector<std::pair<GURL, string16> >* urls) { |
| 675 for (int i = 0; i < browser->tab_count(); ++i) { | 675 for (int i = 0; i < browser->tab_count(); ++i) { |
| 676 std::pair<GURL, string16> entry; | 676 std::pair<GURL, string16> entry; |
| 677 GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &(entry.first), | 677 GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &(entry.first), |
| 678 &(entry.second)); | 678 &(entry.second)); |
| 679 urls->push_back(entry); | 679 urls->push_back(entry); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 void RecordBookmarkLaunch(BookmarkLaunchLocation location) { | 770 void RecordBookmarkLaunch(BookmarkLaunchLocation location) { |
| 771 #if defined(OS_WIN) | 771 #if defined(OS_WIN) |
| 772 // TODO(estade): do this on other platforms too. For now it's compiled out | 772 // TODO(estade): do this on other platforms too. For now it's compiled out |
| 773 // so that stats from platforms for which this is incompletely implemented | 773 // so that stats from platforms for which this is incompletely implemented |
| 774 // don't mix in with Windows, where it should be implemented exhaustively. | 774 // don't mix in with Windows, where it should be implemented exhaustively. |
| 775 UMA_HISTOGRAM_ENUMERATION("Bookmarks.LaunchLocation", location, LAUNCH_LIMIT); | 775 UMA_HISTOGRAM_ENUMERATION("Bookmarks.LaunchLocation", location, LAUNCH_LIMIT); |
| 776 #endif | 776 #endif |
| 777 } | 777 } |
| 778 | 778 |
| 779 } // namespace bookmark_utils | 779 } // namespace bookmark_utils |
| OLD | NEW |