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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 #include "chrome/browser/themes/theme_service_factory.h" | 89 #include "chrome/browser/themes/theme_service_factory.h" |
90 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" | 90 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" |
91 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 91 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
92 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 92 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
93 #include "chrome/browser/ui/browser_command_controller.h" | 93 #include "chrome/browser/ui/browser_command_controller.h" |
94 #include "chrome/browser/ui/browser_commands.h" | 94 #include "chrome/browser/ui/browser_commands.h" |
95 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 95 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
96 #include "chrome/browser/ui/browser_dialogs.h" | 96 #include "chrome/browser/ui/browser_dialogs.h" |
97 #include "chrome/browser/ui/browser_finder.h" | 97 #include "chrome/browser/ui/browser_finder.h" |
98 #include "chrome/browser/ui/browser_instant_controller.h" | 98 #include "chrome/browser/ui/browser_instant_controller.h" |
| 99 #include "chrome/browser/ui/browser_iterator.h" |
99 #include "chrome/browser/ui/browser_list.h" | 100 #include "chrome/browser/ui/browser_list.h" |
100 #include "chrome/browser/ui/browser_navigator.h" | 101 #include "chrome/browser/ui/browser_navigator.h" |
101 #include "chrome/browser/ui/browser_tab_contents.h" | 102 #include "chrome/browser/ui/browser_tab_contents.h" |
102 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 103 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
103 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" | 104 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" |
104 #include "chrome/browser/ui/browser_tabstrip.h" | 105 #include "chrome/browser/ui/browser_tabstrip.h" |
105 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" | 106 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" |
106 #include "chrome/browser/ui/browser_ui_prefs.h" | 107 #include "chrome/browser/ui/browser_ui_prefs.h" |
107 #include "chrome/browser/ui/browser_window.h" | 108 #include "chrome/browser/ui/browser_window.h" |
108 #include "chrome/browser/ui/chrome_pages.h" | 109 #include "chrome/browser/ui/chrome_pages.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 return DOWNLOAD_CLOSE_OK; | 709 return DOWNLOAD_CLOSE_OK; |
709 | 710 |
710 int total_download_count = DownloadService::DownloadCountAllProfiles(); | 711 int total_download_count = DownloadService::DownloadCountAllProfiles(); |
711 if (total_download_count == 0) | 712 if (total_download_count == 0) |
712 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. | 713 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. |
713 | 714 |
714 // Figure out how many windows are open total, and associated with this | 715 // Figure out how many windows are open total, and associated with this |
715 // profile, that are relevant for the ok-to-close decision. | 716 // profile, that are relevant for the ok-to-close decision. |
716 int profile_window_count = 0; | 717 int profile_window_count = 0; |
717 int total_window_count = 0; | 718 int total_window_count = 0; |
718 for (BrowserList::const_iterator iter = BrowserList::begin(); | 719 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
719 iter != BrowserList::end(); ++iter) { | |
720 // Don't count this browser window or any other in the process of closing. | 720 // Don't count this browser window or any other in the process of closing. |
721 Browser* const browser = *iter; | 721 Browser* const browser = *it; |
722 // Window closing may be delayed, and windows that are in the process of | 722 // Window closing may be delayed, and windows that are in the process of |
723 // closing don't count against our totals. | 723 // closing don't count against our totals. |
724 if (browser == this || browser->IsAttemptingToCloseBrowser()) | 724 if (browser == this || browser->IsAttemptingToCloseBrowser()) |
725 continue; | 725 continue; |
726 | 726 |
727 if ((*iter)->profile() == profile()) | 727 if (it->profile() == profile()) |
728 profile_window_count++; | 728 profile_window_count++; |
729 total_window_count++; | 729 total_window_count++; |
730 } | 730 } |
731 | 731 |
732 // If there aren't any other windows, we're at browser shutdown, | 732 // If there aren't any other windows, we're at browser shutdown, |
733 // which would cancel all current downloads. | 733 // which would cancel all current downloads. |
734 if (total_window_count == 0) { | 734 if (total_window_count == 0) { |
735 *num_downloads_blocking = total_download_count; | 735 *num_downloads_blocking = total_download_count; |
736 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; | 736 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; |
737 } | 737 } |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 if (contents && !allow_js_access) { | 2332 if (contents && !allow_js_access) { |
2333 contents->web_contents()->GetController().LoadURL( | 2333 contents->web_contents()->GetController().LoadURL( |
2334 target_url, | 2334 target_url, |
2335 content::Referrer(), | 2335 content::Referrer(), |
2336 content::PAGE_TRANSITION_LINK, | 2336 content::PAGE_TRANSITION_LINK, |
2337 std::string()); // No extra headers. | 2337 std::string()); // No extra headers. |
2338 } | 2338 } |
2339 | 2339 |
2340 return contents != NULL; | 2340 return contents != NULL; |
2341 } | 2341 } |
OLD | NEW |