| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/idle_timer.h" | 8 #include "base/idle_timer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 const std::vector<TabNavigation>& navigations, | 529 const std::vector<TabNavigation>& navigations, |
| 530 int selected_navigation) { | 530 int selected_navigation) { |
| 531 NavigationController* restored_controller = | 531 NavigationController* restored_controller = |
| 532 BuildRestoredNavigationController(navigations, selected_navigation); | 532 BuildRestoredNavigationController(navigations, selected_navigation); |
| 533 | 533 |
| 534 tabstrip_model_.ReplaceNavigationControllerAt( | 534 tabstrip_model_.ReplaceNavigationControllerAt( |
| 535 tabstrip_model_.selected_index(), | 535 tabstrip_model_.selected_index(), |
| 536 restored_controller); | 536 restored_controller); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void Browser::ShowNativeUITab(const GURL& url) { | 539 void Browser::ShowSingleDOMUITab(const GURL& url) { |
| 540 int i, c; | 540 int i, c; |
| 541 TabContents* tc; | 541 TabContents* tc; |
| 542 for (i = 0, c = tabstrip_model_.count(); i < c; ++i) { | 542 for (i = 0, c = tabstrip_model_.count(); i < c; ++i) { |
| 543 tc = tabstrip_model_.GetTabContentsAt(i); | 543 tc = tabstrip_model_.GetTabContentsAt(i); |
| 544 if (tc->type() == TAB_CONTENTS_NATIVE_UI && | 544 if (tc->type() == TAB_CONTENTS_DOM_UI && |
| 545 tc->GetURL() == url) { | 545 tc->GetURL() == url) { |
| 546 tabstrip_model_.SelectTabContentsAt(i, false); | 546 tabstrip_model_.SelectTabContentsAt(i, false); |
| 547 return; | 547 return; |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 | 550 AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, true, NULL); |
| 551 TabContents* contents = CreateTabContentsForURL(url, GURL(), profile_, | |
| 552 PageTransition::LINK, false, | |
| 553 NULL); | |
| 554 AddNewContents(NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), true); | |
| 555 } | 551 } |
| 556 | 552 |
| 557 /////////////////////////////////////////////////////////////////////////////// | 553 /////////////////////////////////////////////////////////////////////////////// |
| 558 // Browser, Assorted browser commands: | 554 // Browser, Assorted browser commands: |
| 559 | 555 |
| 560 void Browser::GoBack() { | 556 void Browser::GoBack() { |
| 561 UserMetrics::RecordAction(L"Back", profile_); | 557 UserMetrics::RecordAction(L"Back", profile_); |
| 562 | 558 |
| 563 // If we are showing an interstitial, just hide it. | 559 // If we are showing an interstitial, just hide it. |
| 564 TabContents* current_tab = GetSelectedTabContents(); | 560 TabContents* current_tab = GetSelectedTabContents(); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 window_->ShowReportBugDialog(); | 960 window_->ShowReportBugDialog(); |
| 965 } | 961 } |
| 966 | 962 |
| 967 void Browser::ToggleBookmarkBar() { | 963 void Browser::ToggleBookmarkBar() { |
| 968 UserMetrics::RecordAction(L"ShowBookmarksBar", profile_); | 964 UserMetrics::RecordAction(L"ShowBookmarksBar", profile_); |
| 969 window_->ToggleBookmarkBar(); | 965 window_->ToggleBookmarkBar(); |
| 970 } | 966 } |
| 971 | 967 |
| 972 void Browser::ShowHistoryTab() { | 968 void Browser::ShowHistoryTab() { |
| 973 UserMetrics::RecordAction(L"ShowHistory", profile_); | 969 UserMetrics::RecordAction(L"ShowHistory", profile_); |
| 974 GURL downloads_url = HistoryUI::GetBaseURL(); | 970 ShowSingleDOMUITab(HistoryUI::GetBaseURL()); |
| 975 AddTabWithURL(downloads_url, GURL(), PageTransition::AUTO_BOOKMARK, true, | |
| 976 NULL); | |
| 977 } | 971 } |
| 978 | 972 |
| 979 void Browser::OpenBookmarkManager() { | 973 void Browser::OpenBookmarkManager() { |
| 980 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_); | 974 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_); |
| 981 window_->ShowBookmarkManager(); | 975 window_->ShowBookmarkManager(); |
| 982 } | 976 } |
| 983 | 977 |
| 984 void Browser::ShowDownloadsTab() { | 978 void Browser::ShowDownloadsTab() { |
| 985 UserMetrics::RecordAction(L"ShowDownloads", profile_); | 979 UserMetrics::RecordAction(L"ShowDownloads", profile_); |
| 986 GURL downloads_url = DownloadsUI::GetBaseURL(); | 980 ShowSingleDOMUITab(DownloadsUI::GetBaseURL()); |
| 987 AddTabWithURL(downloads_url, GURL(), PageTransition::AUTO_BOOKMARK, true, | |
| 988 NULL); | |
| 989 } | 981 } |
| 990 | 982 |
| 991 void Browser::OpenClearBrowsingDataDialog() { | 983 void Browser::OpenClearBrowsingDataDialog() { |
| 992 UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_); | 984 UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_); |
| 993 window_->ShowClearBrowsingDataDialog(); | 985 window_->ShowClearBrowsingDataDialog(); |
| 994 } | 986 } |
| 995 | 987 |
| 996 void Browser::OpenImportSettingsDialog() { | 988 void Browser::OpenImportSettingsDialog() { |
| 997 UserMetrics::RecordAction(L"Import_ShowDlg", profile_); | 989 UserMetrics::RecordAction(L"Import_ShowDlg", profile_); |
| 998 window_->ShowImportDialog(); | 990 window_->ShowImportDialog(); |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 | 2441 |
| 2450 // We need to register the window position pref. | 2442 // We need to register the window position pref. |
| 2451 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2443 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2452 window_pref.append(L"_"); | 2444 window_pref.append(L"_"); |
| 2453 window_pref.append(app_name); | 2445 window_pref.append(app_name); |
| 2454 PrefService* prefs = g_browser_process->local_state(); | 2446 PrefService* prefs = g_browser_process->local_state(); |
| 2455 DCHECK(prefs); | 2447 DCHECK(prefs); |
| 2456 | 2448 |
| 2457 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2449 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2458 } | 2450 } |
| OLD | NEW |