| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/animation.h" | 7 #include "app/animation.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/keyboard_codes.h" | 10 #include "base/keyboard_codes.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 void Browser::ToolbarSizeChanged(bool is_animating) { | 584 void Browser::ToolbarSizeChanged(bool is_animating) { |
| 585 ToolbarSizeChanged(NULL, is_animating); | 585 ToolbarSizeChanged(NULL, is_animating); |
| 586 } | 586 } |
| 587 | 587 |
| 588 TabContents* Browser::AddRestoredTab( | 588 TabContents* Browser::AddRestoredTab( |
| 589 const std::vector<TabNavigation>& navigations, | 589 const std::vector<TabNavigation>& navigations, |
| 590 int tab_index, | 590 int tab_index, |
| 591 int selected_navigation, | 591 int selected_navigation, |
| 592 bool select, | 592 bool select, |
| 593 bool pin) { | 593 bool pin, |
| 594 bool from_last_session) { |
| 594 TabContents* new_tab = new TabContents(profile(), NULL, | 595 TabContents* new_tab = new TabContents(profile(), NULL, |
| 595 MSG_ROUTING_NONE, tabstrip_model_.GetSelectedTabContents()); | 596 MSG_ROUTING_NONE, tabstrip_model_.GetSelectedTabContents()); |
| 596 new_tab->controller().RestoreFromState(navigations, selected_navigation); | 597 new_tab->controller().RestoreFromState(navigations, selected_navigation, |
| 598 from_last_session); |
| 597 | 599 |
| 598 bool really_pin = | 600 bool really_pin = |
| 599 (pin && tab_index == tabstrip_model()->IndexOfFirstNonPinnedTab()); | 601 (pin && tab_index == tabstrip_model()->IndexOfFirstNonPinnedTab()); |
| 600 tabstrip_model_.InsertTabContentsAt(tab_index, new_tab, select, false); | 602 tabstrip_model_.InsertTabContentsAt(tab_index, new_tab, select, false); |
| 601 if (really_pin) | 603 if (really_pin) |
| 602 tabstrip_model_.SetTabPinned(tab_index, true); | 604 tabstrip_model_.SetTabPinned(tab_index, true); |
| 603 if (select) | 605 if (select) |
| 604 window_->Activate(); | 606 window_->Activate(); |
| 605 if (profile_->HasSessionService()) { | 607 if (profile_->HasSessionService()) { |
| 606 SessionService* session_service = profile_->GetSessionService(); | 608 SessionService* session_service = profile_->GetSessionService(); |
| 607 if (session_service) | 609 if (session_service) |
| 608 session_service->TabRestored(&new_tab->controller(), really_pin); | 610 session_service->TabRestored(&new_tab->controller(), really_pin); |
| 609 } | 611 } |
| 610 return new_tab; | 612 return new_tab; |
| 611 } | 613 } |
| 612 | 614 |
| 613 void Browser::ReplaceRestoredTab( | 615 void Browser::ReplaceRestoredTab( |
| 614 const std::vector<TabNavigation>& navigations, | 616 const std::vector<TabNavigation>& navigations, |
| 615 int selected_navigation) { | 617 int selected_navigation, |
| 618 bool from_last_session) { |
| 616 TabContents* replacement = new TabContents(profile(), NULL, | 619 TabContents* replacement = new TabContents(profile(), NULL, |
| 617 MSG_ROUTING_NONE, tabstrip_model_.GetSelectedTabContents()); | 620 MSG_ROUTING_NONE, tabstrip_model_.GetSelectedTabContents()); |
| 618 replacement->controller().RestoreFromState(navigations, selected_navigation); | 621 replacement->controller().RestoreFromState(navigations, selected_navigation, |
| 622 from_last_session); |
| 619 | 623 |
| 620 tabstrip_model_.ReplaceNavigationControllerAt( | 624 tabstrip_model_.ReplaceNavigationControllerAt( |
| 621 tabstrip_model_.selected_index(), | 625 tabstrip_model_.selected_index(), |
| 622 &replacement->controller()); | 626 &replacement->controller()); |
| 623 } | 627 } |
| 624 | 628 |
| 625 bool Browser::CanRestoreTab() { | 629 bool Browser::CanRestoreTab() { |
| 626 TabRestoreService* service = profile_->GetTabRestoreService(); | 630 TabRestoreService* service = profile_->GetTabRestoreService(); |
| 627 return service && !service->entries().empty(); | 631 return service && !service->entries().empty(); |
| 628 } | 632 } |
| (...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 session_service->SetTabIndexInWindow( | 2626 session_service->SetTabIndexInWindow( |
| 2623 session_id(), contents->controller().session_id(), i); | 2627 session_id(), contents->controller().session_id(), i); |
| 2624 session_service->SetPinnedState(session_id(), | 2628 session_service->SetPinnedState(session_id(), |
| 2625 contents->controller().session_id(), | 2629 contents->controller().session_id(), |
| 2626 tabstrip_model_.IsTabPinned(i)); | 2630 tabstrip_model_.IsTabPinned(i)); |
| 2627 } | 2631 } |
| 2628 } | 2632 } |
| 2629 } | 2633 } |
| 2630 } | 2634 } |
| 2631 | 2635 |
| 2632 TabContents* Browser::BuildRestoredTab( | |
| 2633 const std::vector<TabNavigation>& navigations, | |
| 2634 int selected_navigation) { | |
| 2635 if (!navigations.empty()) { | |
| 2636 DCHECK(selected_navigation >= 0 && | |
| 2637 selected_navigation < static_cast<int>(navigations.size())); | |
| 2638 // Create a NavigationController. This constructor creates the appropriate | |
| 2639 // set of TabContents. | |
| 2640 TabContents* new_tab = new TabContents(profile_, NULL, | |
| 2641 MSG_ROUTING_NONE, tabstrip_model_.GetSelectedTabContents()); | |
| 2642 new_tab->controller().RestoreFromState(navigations, selected_navigation); | |
| 2643 return new_tab; | |
| 2644 } else { | |
| 2645 // No navigations. Create a tab with about:blank. | |
| 2646 return CreateTabContentsForURL(GURL(chrome::kAboutBlankURL), GURL(), | |
| 2647 profile_, PageTransition::START_PAGE, | |
| 2648 false, NULL); | |
| 2649 } | |
| 2650 } | |
| 2651 | |
| 2652 /////////////////////////////////////////////////////////////////////////////// | 2636 /////////////////////////////////////////////////////////////////////////////// |
| 2653 // Browser, OnBeforeUnload handling (private): | 2637 // Browser, OnBeforeUnload handling (private): |
| 2654 | 2638 |
| 2655 void Browser::ProcessPendingTabs() { | 2639 void Browser::ProcessPendingTabs() { |
| 2656 DCHECK(is_attempting_to_close_browser_); | 2640 DCHECK(is_attempting_to_close_browser_); |
| 2657 | 2641 |
| 2658 if (HasCompletedUnloadProcessing()) { | 2642 if (HasCompletedUnloadProcessing()) { |
| 2659 // We've finished all the unload events and can proceed to close the | 2643 // We've finished all the unload events and can proceed to close the |
| 2660 // browser. | 2644 // browser. |
| 2661 OnWindowClosing(); | 2645 OnWindowClosing(); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2979 /////////////////////////////////////////////////////////////////////////////// | 2963 /////////////////////////////////////////////////////////////////////////////// |
| 2980 // BrowserToolbarModel (private): | 2964 // BrowserToolbarModel (private): |
| 2981 | 2965 |
| 2982 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2966 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
| 2983 // This |current_tab| can be NULL during the initialization of the | 2967 // This |current_tab| can be NULL during the initialization of the |
| 2984 // toolbar during window creation (i.e. before any tabs have been added | 2968 // toolbar during window creation (i.e. before any tabs have been added |
| 2985 // to the window). | 2969 // to the window). |
| 2986 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2970 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 2987 return current_tab ? ¤t_tab->controller() : NULL; | 2971 return current_tab ? ¤t_tab->controller() : NULL; |
| 2988 } | 2972 } |
| OLD | NEW |