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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 current_index = match_index; | 649 current_index = match_index; |
650 } | 650 } |
651 } | 651 } |
652 | 652 |
653 /////////////////////////////////////////////////////////////////////////////// | 653 /////////////////////////////////////////////////////////////////////////////// |
654 // Browser, OnBeforeUnload handling: | 654 // Browser, OnBeforeUnload handling: |
655 | 655 |
656 bool Browser::ShouldCloseWindow() { | 656 bool Browser::ShouldCloseWindow() { |
657 if (!CanCloseWithInProgressDownloads()) | 657 if (!CanCloseWithInProgressDownloads()) |
658 return false; | 658 return false; |
659 | |
660 if (IsFastTabUnloadEnabled()) | 659 if (IsFastTabUnloadEnabled()) |
661 return fast_unload_controller_->ShouldCloseWindow(); | 660 return fast_unload_controller_->ShouldCloseWindow(); |
662 return unload_controller_->ShouldCloseWindow(); | 661 return unload_controller_->ShouldCloseWindow(); |
663 } | 662 } |
664 | 663 |
665 bool Browser::CallBeforeUnloadHandlers( | 664 bool Browser::TryToCloseWindow( |
| 665 bool skip_beforeunload, |
666 const base::Callback<void(bool)>& on_close_confirmed) { | 666 const base::Callback<void(bool)>& on_close_confirmed) { |
667 cancel_download_confirmation_state_ = RESPONSE_RECEIVED; | 667 cancel_download_confirmation_state_ = RESPONSE_RECEIVED; |
668 if (IsFastTabUnloadEnabled()) { | 668 if (IsFastTabUnloadEnabled()) { |
669 return fast_unload_controller_->CallBeforeUnloadHandlers( | 669 return fast_unload_controller_->TryToCloseWindow(skip_beforeunload, |
670 on_close_confirmed); | 670 on_close_confirmed); |
671 } | 671 } |
672 return unload_controller_->CallBeforeUnloadHandlers(on_close_confirmed); | 672 return unload_controller_->TryToCloseWindow(skip_beforeunload, |
| 673 on_close_confirmed); |
673 } | 674 } |
674 | 675 |
675 void Browser::ResetBeforeUnloadHandlers() { | 676 void Browser::ResetTryToCloseWindow() { |
676 cancel_download_confirmation_state_ = NOT_PROMPTED; | 677 cancel_download_confirmation_state_ = NOT_PROMPTED; |
677 if (IsFastTabUnloadEnabled()) | 678 if (IsFastTabUnloadEnabled()) |
678 fast_unload_controller_->ResetBeforeUnloadHandlers(); | 679 fast_unload_controller_->ResetTryToCloseWindow(); |
679 else | 680 else |
680 unload_controller_->ResetBeforeUnloadHandlers(); | 681 unload_controller_->ResetTryToCloseWindow(); |
681 } | 682 } |
682 | 683 |
683 bool Browser::HasCompletedUnloadProcessing() const { | 684 bool Browser::HasCompletedUnloadProcessing() const { |
684 DCHECK(IsFastTabUnloadEnabled()); | 685 DCHECK(IsFastTabUnloadEnabled()); |
685 return fast_unload_controller_->HasCompletedUnloadProcessing(); | 686 return fast_unload_controller_->HasCompletedUnloadProcessing(); |
686 } | 687 } |
687 | 688 |
688 bool Browser::IsAttemptingToCloseBrowser() const { | 689 bool Browser::IsAttemptingToCloseBrowser() const { |
689 if (IsFastTabUnloadEnabled()) | 690 if (IsFastTabUnloadEnabled()) |
690 return fast_unload_controller_->is_attempting_to_close_browser(); | 691 return fast_unload_controller_->is_attempting_to_close_browser(); |
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 // new window later, thus we need to navigate the window now. | 2663 // new window later, thus we need to navigate the window now. |
2663 if (contents) { | 2664 if (contents) { |
2664 contents->web_contents()->GetController().LoadURL( | 2665 contents->web_contents()->GetController().LoadURL( |
2665 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2666 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2666 std::string()); // No extra headers. | 2667 std::string()); // No extra headers. |
2667 } | 2668 } |
2668 } | 2669 } |
2669 | 2670 |
2670 return contents != NULL; | 2671 return contents != NULL; |
2671 } | 2672 } |
OLD | NEW |