OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // OS_WIN | 10 #endif // OS_WIN |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 437 } |
438 | 438 |
439 Browser::~Browser() { | 439 Browser::~Browser() { |
440 ProfileSyncService* service = | 440 ProfileSyncService* service = |
441 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 441 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
442 if (service) | 442 if (service) |
443 service->RemoveObserver(this); | 443 service->RemoveObserver(this); |
444 | 444 |
445 BrowserList::RemoveBrowser(this); | 445 BrowserList::RemoveBrowser(this); |
446 | 446 |
| 447 SessionService* session_service = |
| 448 SessionServiceFactory::GetForProfile(profile_); |
| 449 if (session_service) |
| 450 session_service->WindowClosed(session_id_); |
| 451 |
| 452 TabRestoreService* tab_restore_service = |
| 453 TabRestoreServiceFactory::GetForProfile(profile()); |
| 454 if (tab_restore_service) |
| 455 tab_restore_service->BrowserClosed(tab_restore_service_delegate()); |
| 456 |
447 #if !defined(OS_MACOSX) | 457 #if !defined(OS_MACOSX) |
448 if (!BrowserList::HasBrowserWithProfile(profile_)) { | 458 if (!BrowserList::HasBrowserWithProfile(profile_)) { |
449 // We're the last browser window with this profile. We need to nuke the | 459 // We're the last browser window with this profile. We need to nuke the |
450 // TabRestoreService, which will start the shutdown of the | 460 // TabRestoreService, which will start the shutdown of the |
451 // NavigationControllers and allow for proper shutdown. If we don't do this | 461 // NavigationControllers and allow for proper shutdown. If we don't do this |
452 // chrome won't shutdown cleanly, and may end up crashing when some | 462 // chrome won't shutdown cleanly, and may end up crashing when some |
453 // thread tries to use the IO thread (or another thread) that is no longer | 463 // thread tries to use the IO thread (or another thread) that is no longer |
454 // valid. | 464 // valid. |
455 // This isn't a valid assumption for Mac OS, as it stays running after | 465 // This isn't a valid assumption for Mac OS, as it stays running after |
456 // the last browser has closed. The Mac equivalent is in its app | 466 // the last browser has closed. The Mac equivalent is in its app |
457 // controller. | 467 // controller. |
458 TabRestoreServiceFactory::ResetForProfile(profile_); | 468 TabRestoreServiceFactory::ResetForProfile(profile_); |
459 } | 469 } |
460 #endif | 470 #endif |
461 | 471 |
462 SessionService* session_service = | |
463 SessionServiceFactory::GetForProfile(profile_); | |
464 if (session_service) | |
465 session_service->WindowClosed(session_id_); | |
466 | |
467 TabRestoreService* tab_restore_service = | |
468 TabRestoreServiceFactory::GetForProfile(profile()); | |
469 if (tab_restore_service) | |
470 tab_restore_service->BrowserClosed(tab_restore_service_delegate()); | |
471 | |
472 profile_pref_registrar_.RemoveAll(); | 472 profile_pref_registrar_.RemoveAll(); |
473 local_pref_registrar_.RemoveAll(); | 473 local_pref_registrar_.RemoveAll(); |
474 | 474 |
475 encoding_auto_detect_.Destroy(); | 475 encoding_auto_detect_.Destroy(); |
476 | 476 |
477 if (profile_->IsOffTheRecord() && | 477 if (profile_->IsOffTheRecord() && |
478 !BrowserList::IsOffTheRecordSessionActiveForProfile(profile_)) { | 478 !BrowserList::IsOffTheRecordSessionActiveForProfile(profile_)) { |
479 // An incognito profile is no longer needed, this indirectly frees | 479 // An incognito profile is no longer needed, this indirectly frees |
480 // its cache and cookies once it gets destroyed at the appropriate time. | 480 // its cache and cookies once it gets destroyed at the appropriate time. |
481 ProfileDestroyer::DestroyOffTheRecordProfile(profile_); | 481 ProfileDestroyer::DestroyOffTheRecordProfile(profile_); |
(...skipping 5162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5644 } else { | 5644 } else { |
5645 LoginUIServiceFactory::GetForProfile( | 5645 LoginUIServiceFactory::GetForProfile( |
5646 profile()->GetOriginalProfile())->ShowLoginUI(); | 5646 profile()->GetOriginalProfile())->ShowLoginUI(); |
5647 } | 5647 } |
5648 #endif | 5648 #endif |
5649 } | 5649 } |
5650 | 5650 |
5651 void Browser::ToggleSpeechInput() { | 5651 void Browser::ToggleSpeechInput() { |
5652 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5652 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
5653 } | 5653 } |
OLD | NEW |