| 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 SessionService* session_service = | 516 SessionService* session_service = |
| 517 SessionServiceFactory::GetForProfile(profile_); | 517 SessionServiceFactory::GetForProfile(profile_); |
| 518 if (session_service) | 518 if (session_service) |
| 519 session_service->WindowClosed(session_id_); | 519 session_service->WindowClosed(session_id_); |
| 520 | 520 |
| 521 sessions::TabRestoreService* tab_restore_service = | 521 sessions::TabRestoreService* tab_restore_service = |
| 522 TabRestoreServiceFactory::GetForProfile(profile()); | 522 TabRestoreServiceFactory::GetForProfile(profile()); |
| 523 if (tab_restore_service) | 523 if (tab_restore_service) |
| 524 tab_restore_service->BrowserClosed(live_tab_context()); | 524 tab_restore_service->BrowserClosed(live_tab_context()); |
| 525 | 525 |
| 526 #if !defined(OS_MACOSX) | |
| 527 if (!chrome::GetBrowserCount(profile_)) { | |
| 528 // We're the last browser window with this profile. We need to nuke the | |
| 529 // TabRestoreService, which will start the shutdown of the | |
| 530 // NavigationControllers and allow for proper shutdown. If we don't do this | |
| 531 // chrome won't shutdown cleanly, and may end up crashing when some | |
| 532 // thread tries to use the IO thread (or another thread) that is no longer | |
| 533 // valid. | |
| 534 // This isn't a valid assumption for Mac OS, as it stays running after | |
| 535 // the last browser has closed. The Mac equivalent is in its app | |
| 536 // controller. | |
| 537 TabRestoreServiceFactory::ResetForProfile(profile_); | |
| 538 } | |
| 539 #endif | |
| 540 | |
| 541 profile_pref_registrar_.RemoveAll(); | 526 profile_pref_registrar_.RemoveAll(); |
| 542 | 527 |
| 543 encoding_auto_detect_.Destroy(); | 528 encoding_auto_detect_.Destroy(); |
| 544 | 529 |
| 545 // Destroy BrowserExtensionWindowController before the incognito profile | 530 // Destroy BrowserExtensionWindowController before the incognito profile |
| 546 // is destroyed to make sure the chrome.windows.onRemoved event is sent. | 531 // is destroyed to make sure the chrome.windows.onRemoved event is sent. |
| 547 extension_window_controller_.reset(); | 532 extension_window_controller_.reset(); |
| 548 | 533 |
| 549 // Destroy BrowserInstantController before the incongnito profile is destroyed | 534 // Destroy BrowserInstantController before the incongnito profile is destroyed |
| 550 // because the InstantController destructor depends on this profile. | 535 // because the InstantController destructor depends on this profile. |
| (...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2754 if (contents && !allow_js_access) { | 2739 if (contents && !allow_js_access) { |
| 2755 contents->web_contents()->GetController().LoadURL( | 2740 contents->web_contents()->GetController().LoadURL( |
| 2756 target_url, | 2741 target_url, |
| 2757 content::Referrer(), | 2742 content::Referrer(), |
| 2758 ui::PAGE_TRANSITION_LINK, | 2743 ui::PAGE_TRANSITION_LINK, |
| 2759 std::string()); // No extra headers. | 2744 std::string()); // No extra headers. |
| 2760 } | 2745 } |
| 2761 | 2746 |
| 2762 return contents != NULL; | 2747 return contents != NULL; |
| 2763 } | 2748 } |
| OLD | NEW |