OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 current_index = match_index; | 636 current_index = match_index; |
637 } | 637 } |
638 } | 638 } |
639 | 639 |
640 /////////////////////////////////////////////////////////////////////////////// | 640 /////////////////////////////////////////////////////////////////////////////// |
641 // Browser, OnBeforeUnload handling: | 641 // Browser, OnBeforeUnload handling: |
642 | 642 |
643 bool Browser::ShouldCloseWindow() { | 643 bool Browser::ShouldCloseWindow() { |
644 if (!CanCloseWithInProgressDownloads()) | 644 if (!CanCloseWithInProgressDownloads()) |
645 return false; | 645 return false; |
646 | |
647 if (IsFastTabUnloadEnabled()) | 646 if (IsFastTabUnloadEnabled()) |
648 return fast_unload_controller_->ShouldCloseWindow(); | 647 return fast_unload_controller_->ShouldCloseWindow(); |
649 return unload_controller_->ShouldCloseWindow(); | 648 return unload_controller_->ShouldCloseWindow(); |
650 } | 649 } |
651 | 650 |
652 bool Browser::CallBeforeUnloadHandlers( | 651 bool Browser::TryToCloseWindow( |
| 652 bool skip_before_unload_event, |
653 const base::Callback<void(bool)>& on_close_confirmed) { | 653 const base::Callback<void(bool)>& on_close_confirmed) { |
654 cancel_download_confirmation_state_ = RESPONSE_RECEIVED; | 654 cancel_download_confirmation_state_ = RESPONSE_RECEIVED; |
655 if (IsFastTabUnloadEnabled()) { | 655 if (IsFastTabUnloadEnabled()) { |
656 return fast_unload_controller_->CallBeforeUnloadHandlers( | 656 return fast_unload_controller_->TryToCloseWindow(skip_before_unload_event, |
657 on_close_confirmed); | 657 on_close_confirmed); |
658 } | 658 } |
659 return unload_controller_->CallBeforeUnloadHandlers(on_close_confirmed); | 659 return unload_controller_->TryToCloseWindow(skip_before_unload_event, |
| 660 on_close_confirmed); |
660 } | 661 } |
661 | 662 |
662 void Browser::ResetBeforeUnloadHandlers() { | 663 void Browser::ResetTryToCloseWindow() { |
663 cancel_download_confirmation_state_ = NOT_PROMPTED; | 664 cancel_download_confirmation_state_ = NOT_PROMPTED; |
664 if (IsFastTabUnloadEnabled()) | 665 if (IsFastTabUnloadEnabled()) |
665 fast_unload_controller_->ResetBeforeUnloadHandlers(); | 666 fast_unload_controller_->ResetTryToCloseWindow(); |
666 else | 667 else |
667 unload_controller_->ResetBeforeUnloadHandlers(); | 668 unload_controller_->ResetTryToCloseWindow(); |
668 } | 669 } |
669 | 670 |
670 bool Browser::HasCompletedUnloadProcessing() const { | 671 bool Browser::HasCompletedUnloadProcessing() const { |
671 DCHECK(IsFastTabUnloadEnabled()); | 672 DCHECK(IsFastTabUnloadEnabled()); |
672 return fast_unload_controller_->HasCompletedUnloadProcessing(); | 673 return fast_unload_controller_->HasCompletedUnloadProcessing(); |
673 } | 674 } |
674 | 675 |
675 bool Browser::IsAttemptingToCloseBrowser() const { | 676 bool Browser::IsAttemptingToCloseBrowser() const { |
676 if (IsFastTabUnloadEnabled()) | 677 if (IsFastTabUnloadEnabled()) |
677 return fast_unload_controller_->is_attempting_to_close_browser(); | 678 return fast_unload_controller_->is_attempting_to_close_browser(); |
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2619 // new window later, thus we need to navigate the window now. | 2620 // new window later, thus we need to navigate the window now. |
2620 if (contents) { | 2621 if (contents) { |
2621 contents->web_contents()->GetController().LoadURL( | 2622 contents->web_contents()->GetController().LoadURL( |
2622 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2623 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2623 std::string()); // No extra headers. | 2624 std::string()); // No extra headers. |
2624 } | 2625 } |
2625 } | 2626 } |
2626 | 2627 |
2627 return contents != NULL; | 2628 return contents != NULL; |
2628 } | 2629 } |
OLD | NEW |