| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "app/animation.h" | 10 #include "app/animation.h" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 ProcessPendingTabs(); | 629 ProcessPendingTabs(); |
| 630 return false; | 630 return false; |
| 631 } | 631 } |
| 632 | 632 |
| 633 void Browser::OnWindowClosing() { | 633 void Browser::OnWindowClosing() { |
| 634 if (!ShouldCloseWindow()) | 634 if (!ShouldCloseWindow()) |
| 635 return; | 635 return; |
| 636 | 636 |
| 637 bool exiting = false; | 637 bool exiting = false; |
| 638 | 638 |
| 639 #if defined(OS_WIN) || defined(OS_LINUX) | 639 #if defined(OS_MACOSX) |
| 640 // We don't want to do this on Mac since closing all windows isn't a sign | 640 // On Mac, closing the last window isn't usually a sign that the app is |
| 641 // that the app is shutting down. | 641 // shutting down. |
| 642 if (BrowserList::size() == 1) { | 642 bool should_quit_if_last_browser = browser_shutdown::IsTryingToQuit(); |
| 643 #else |
| 644 bool should_quit_if_last_browser = true; |
| 645 #endif |
| 646 |
| 647 if (should_quit_if_last_browser && BrowserList::size() == 1) { |
| 643 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); | 648 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); |
| 644 exiting = true; | 649 exiting = true; |
| 645 } | 650 } |
| 646 #endif | |
| 647 | 651 |
| 648 // Don't use HasSessionService here, we want to force creation of the | 652 // Don't use HasSessionService here, we want to force creation of the |
| 649 // session service so that user can restore what was open. | 653 // session service so that user can restore what was open. |
| 650 SessionService* session_service = profile()->GetSessionService(); | 654 SessionService* session_service = profile()->GetSessionService(); |
| 651 if (session_service) | 655 if (session_service) |
| 652 session_service->WindowClosing(session_id()); | 656 session_service->WindowClosing(session_id()); |
| 653 | 657 |
| 654 TabRestoreService* tab_restore_service = profile()->GetTabRestoreService(); | 658 TabRestoreService* tab_restore_service = profile()->GetTabRestoreService(); |
| 655 if (tab_restore_service) | 659 if (tab_restore_service) |
| 656 tab_restore_service->BrowserClosing(this); | 660 tab_restore_service->BrowserClosing(this); |
| (...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3480 if (TabHasUnloadListener(contents)) { | 3484 if (TabHasUnloadListener(contents)) { |
| 3481 // If the page has unload listeners, then we tell the renderer to fire | 3485 // If the page has unload listeners, then we tell the renderer to fire |
| 3482 // them. Once they have fired, we'll get a message back saying whether | 3486 // them. Once they have fired, we'll get a message back saying whether |
| 3483 // to proceed closing the page or not, which sends us back to this method | 3487 // to proceed closing the page or not, which sends us back to this method |
| 3484 // with the HasUnloadListener bit cleared. | 3488 // with the HasUnloadListener bit cleared. |
| 3485 contents->render_view_host()->FirePageBeforeUnload(false); | 3489 contents->render_view_host()->FirePageBeforeUnload(false); |
| 3486 return true; | 3490 return true; |
| 3487 } | 3491 } |
| 3488 return false; | 3492 return false; |
| 3489 } | 3493 } |
| OLD | NEW |