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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.h" | 91 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.h" |
92 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h" | 92 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h" |
93 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 93 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
94 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 94 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
95 #include "chrome/browser/ui/browser_command_controller.h" | 95 #include "chrome/browser/ui/browser_command_controller.h" |
96 #include "chrome/browser/ui/browser_commands.h" | 96 #include "chrome/browser/ui/browser_commands.h" |
97 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 97 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
98 #include "chrome/browser/ui/browser_dialogs.h" | 98 #include "chrome/browser/ui/browser_dialogs.h" |
99 #include "chrome/browser/ui/browser_finder.h" | 99 #include "chrome/browser/ui/browser_finder.h" |
100 #include "chrome/browser/ui/browser_instant_controller.h" | 100 #include "chrome/browser/ui/browser_instant_controller.h" |
101 #include "chrome/browser/ui/browser_iterator.h" | |
102 #include "chrome/browser/ui/browser_list.h" | 101 #include "chrome/browser/ui/browser_list.h" |
103 #include "chrome/browser/ui/browser_live_tab_context.h" | 102 #include "chrome/browser/ui/browser_live_tab_context.h" |
104 #include "chrome/browser/ui/browser_navigator.h" | 103 #include "chrome/browser/ui/browser_navigator.h" |
105 #include "chrome/browser/ui/browser_navigator_params.h" | 104 #include "chrome/browser/ui/browser_navigator_params.h" |
106 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" | 105 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" |
107 #include "chrome/browser/ui/browser_tabstrip.h" | 106 #include "chrome/browser/ui/browser_tabstrip.h" |
108 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" | 107 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" |
109 #include "chrome/browser/ui/browser_ui_prefs.h" | 108 #include "chrome/browser/ui/browser_ui_prefs.h" |
110 #include "chrome/browser/ui/browser_window.h" | 109 #include "chrome/browser/ui/browser_window.h" |
111 #include "chrome/browser/ui/chrome_bubble_manager.h" | 110 #include "chrome/browser/ui/chrome_bubble_manager.h" |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 791 |
793 int total_download_count = | 792 int total_download_count = |
794 DownloadService::NonMaliciousDownloadCountAllProfiles(); | 793 DownloadService::NonMaliciousDownloadCountAllProfiles(); |
795 if (total_download_count == 0) | 794 if (total_download_count == 0) |
796 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. | 795 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. |
797 | 796 |
798 // Figure out how many windows are open total, and associated with this | 797 // Figure out how many windows are open total, and associated with this |
799 // profile, that are relevant for the ok-to-close decision. | 798 // profile, that are relevant for the ok-to-close decision. |
800 int profile_window_count = 0; | 799 int profile_window_count = 0; |
801 int total_window_count = 0; | 800 int total_window_count = 0; |
802 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 801 for (auto* browser : *BrowserList::GetInstance()) { |
803 // Don't count this browser window or any other in the process of closing. | 802 // Don't count this browser window or any other in the process of closing. |
804 Browser* const browser = *it; | |
805 // Window closing may be delayed, and windows that are in the process of | 803 // Window closing may be delayed, and windows that are in the process of |
806 // closing don't count against our totals. | 804 // closing don't count against our totals. |
807 if (browser == this || browser->IsAttemptingToCloseBrowser()) | 805 if (browser == this || browser->IsAttemptingToCloseBrowser()) |
808 continue; | 806 continue; |
809 | 807 |
810 if (it->profile() == profile()) | 808 if (browser->profile() == profile()) |
811 profile_window_count++; | 809 profile_window_count++; |
812 total_window_count++; | 810 total_window_count++; |
813 } | 811 } |
814 | 812 |
815 // If there aren't any other windows, we're at browser shutdown, | 813 // If there aren't any other windows, we're at browser shutdown, |
816 // which would cancel all current downloads. | 814 // which would cancel all current downloads. |
817 if (total_window_count == 0) { | 815 if (total_window_count == 0) { |
818 *num_downloads_blocking = total_download_count; | 816 *num_downloads_blocking = total_download_count; |
819 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; | 817 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; |
820 } | 818 } |
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2735 if (contents && !allow_js_access) { | 2733 if (contents && !allow_js_access) { |
2736 contents->web_contents()->GetController().LoadURL( | 2734 contents->web_contents()->GetController().LoadURL( |
2737 target_url, | 2735 target_url, |
2738 content::Referrer(), | 2736 content::Referrer(), |
2739 ui::PAGE_TRANSITION_LINK, | 2737 ui::PAGE_TRANSITION_LINK, |
2740 std::string()); // No extra headers. | 2738 std::string()); // No extra headers. |
2741 } | 2739 } |
2742 | 2740 |
2743 return contents != NULL; | 2741 return contents != NULL; |
2744 } | 2742 } |
OLD | NEW |