OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
11 #include "base/i18n/case_conversion.h" | 11 #include "base/i18n/case_conversion.h" |
12 #include "base/i18n/string_search.h" | 12 #include "base/i18n/string_search.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "chrome/browser/bookmarks/bookmark_model.h" |
19 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 19 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
20 #include "chrome/browser/history/query_parser.h" | 20 #include "chrome/browser/history/query_parser.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
| 25 #include "chrome/browser/ui/browser_tabstrip.h" |
25 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
26 #include "chrome/browser/ui/simple_message_box.h" | 27 #include "chrome/browser/ui/simple_message_box.h" |
27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
28 #include "content/public/browser/page_navigator.h" | 29 #include "content/public/browser/page_navigator.h" |
29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
30 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
31 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
32 #include "grit/ui_strings.h" | 33 #include "grit/ui_strings.h" |
33 #include "net/base/net_util.h" | 34 #include "net/base/net_util.h" |
34 #include "ui/base/dragdrop/drag_drop_types.h" | 35 #include "ui/base/dragdrop/drag_drop_types.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 Profile* profile, | 380 Profile* profile, |
380 PageNavigator* navigator, | 381 PageNavigator* navigator, |
381 const std::vector<const BookmarkNode*>& nodes, | 382 const std::vector<const BookmarkNode*>& nodes, |
382 WindowOpenDisposition initial_disposition) { | 383 WindowOpenDisposition initial_disposition) { |
383 if (!ShouldOpenAll(parent, nodes)) | 384 if (!ShouldOpenAll(parent, nodes)) |
384 return; | 385 return; |
385 | 386 |
386 NewBrowserPageNavigator navigator_impl(profile); | 387 NewBrowserPageNavigator navigator_impl(profile); |
387 if (!navigator) { | 388 if (!navigator) { |
388 Browser* browser = browser::FindTabbedBrowser(profile, false); | 389 Browser* browser = browser::FindTabbedBrowser(profile, false); |
389 if (!browser || !browser->GetActiveWebContents()) { | 390 if (!browser || !chrome::GetActiveWebContents(browser)) { |
390 navigator = &navigator_impl; | 391 navigator = &navigator_impl; |
391 } else { | 392 } else { |
392 if (initial_disposition != NEW_WINDOW && | 393 if (initial_disposition != NEW_WINDOW && |
393 initial_disposition != OFF_THE_RECORD) { | 394 initial_disposition != OFF_THE_RECORD) { |
394 browser->window()->Activate(); | 395 browser->window()->Activate(); |
395 } | 396 } |
396 navigator = browser->GetActiveWebContents(); | 397 navigator = chrome::GetActiveWebContents(browser); |
397 } | 398 } |
398 } | 399 } |
399 | 400 |
400 bool opened_url = false; | 401 bool opened_url = false; |
401 if (initial_disposition == OFF_THE_RECORD) | 402 if (initial_disposition == OFF_THE_RECORD) |
402 profile = profile->GetOffTheRecordProfile(); | 403 profile = profile->GetOffTheRecordProfile(); |
403 | 404 |
404 for (size_t i = 0; i < nodes.size(); ++i) | 405 for (size_t i = 0; i < nodes.size(); ++i) |
405 OpenAllImpl(nodes[i], initial_disposition, &navigator, &opened_url); | 406 OpenAllImpl(nodes[i], initial_disposition, &navigator, &opened_url); |
406 } | 407 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 string16* title) { | 658 string16* title) { |
658 *url = web_contents->GetURL(); | 659 *url = web_contents->GetURL(); |
659 *title = web_contents->GetTitle(); | 660 *title = web_contents->GetTitle(); |
660 } | 661 } |
661 | 662 |
662 void GetURLsForOpenTabs( | 663 void GetURLsForOpenTabs( |
663 Browser* browser, | 664 Browser* browser, |
664 std::vector<std::pair<GURL, string16> >* urls) { | 665 std::vector<std::pair<GURL, string16> >* urls) { |
665 for (int i = 0; i < browser->tab_count(); ++i) { | 666 for (int i = 0; i < browser->tab_count(); ++i) { |
666 std::pair<GURL, string16> entry; | 667 std::pair<GURL, string16> entry; |
667 GetURLAndTitleToBookmark(browser->GetWebContentsAt(i), &(entry.first), | 668 GetURLAndTitleToBookmark( |
668 &(entry.second)); | 669 chrome::GetWebContentsAt(browser, i), &(entry.first), |
| 670 &(entry.second)); |
669 urls->push_back(entry); | 671 urls->push_back(entry); |
670 } | 672 } |
671 } | 673 } |
672 | 674 |
673 const BookmarkNode* GetParentForNewNodes( | 675 const BookmarkNode* GetParentForNewNodes( |
674 const BookmarkNode* parent, | 676 const BookmarkNode* parent, |
675 const std::vector<const BookmarkNode*>& selection, | 677 const std::vector<const BookmarkNode*>& selection, |
676 int* index) { | 678 int* index) { |
677 const BookmarkNode* real_parent = parent; | 679 const BookmarkNode* real_parent = parent; |
678 | 680 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { | 773 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { |
772 g_bookmark_bar_view_animations_disabled = disabled; | 774 g_bookmark_bar_view_animations_disabled = disabled; |
773 } | 775 } |
774 | 776 |
775 bool IsBookmarkBarViewAnimationsDisabled() { | 777 bool IsBookmarkBarViewAnimationsDisabled() { |
776 return g_bookmark_bar_view_animations_disabled; | 778 return g_bookmark_bar_view_animations_disabled; |
777 } | 779 } |
778 #endif | 780 #endif |
779 | 781 |
780 } // namespace bookmark_utils | 782 } // namespace bookmark_utils |
OLD | NEW |