| 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/lifetime/application_lifetime.h" | 5 #include "chrome/browser/lifetime/application_lifetime.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/app_mode/app_mode_utils.h" | 8 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/notifications/notification_ui_manager.h" | 10 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/switch_utils.h" | 12 #include "chrome/common/switch_utils.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 | 14 |
| 15 #if defined(USE_ASH) | 15 #if defined(USE_ASH) |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ui/aura/client/capture_client.h" | 17 #include "ui/aura/client/capture_client.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 #if defined(OS_CHROMEOS) |
| 21 #include "chromeos/display/output_configurator.h" |
| 22 #endif |
| 23 |
| 20 namespace chrome { | 24 namespace chrome { |
| 21 | 25 |
| 22 void HandleAppExitingForPlatform() { | 26 void HandleAppExitingForPlatform() { |
| 23 // Close all non browser windows now. Those includes notifications | 27 // Close all non browser windows now. Those includes notifications |
| 24 // and windows created by Ash (launcher, background, etc). | 28 // and windows created by Ash (launcher, background, etc). |
| 25 #if defined(USE_ASH) | 29 #if defined(USE_ASH) |
| 26 // This may be called before |ash::Shell| is initialized when | 30 // This may be called before |ash::Shell| is initialized when |
| 27 // XIOError is reported. crbug.com/150633. | 31 // XIOError is reported. crbug.com/150633. |
| 28 if (ash::Shell::HasInstance()) { | 32 if (ash::Shell::HasInstance()) { |
| 29 g_browser_process->notification_ui_manager()->CancelAll(); | 33 g_browser_process->notification_ui_manager()->CancelAll(); |
| 30 // Releasing the capture will close any menus that might be open: | 34 // Releasing the capture will close any menus that might be open: |
| 31 // http://crbug.com/134472 | 35 // http://crbug.com/134472 |
| 32 aura::client::GetCaptureClient(ash::Shell::GetPrimaryRootWindow())-> | 36 aura::client::GetCaptureClient(ash::Shell::GetPrimaryRootWindow())-> |
| 33 SetCapture(NULL); | 37 SetCapture(NULL); |
| 34 } | 38 } |
| 35 #else | 39 #else |
| 36 g_browser_process->notification_ui_manager()->CancelAll(); | 40 g_browser_process->notification_ui_manager()->CancelAll(); |
| 37 #endif | 41 #endif |
| 38 | 42 |
| 39 views::Widget::CloseAllSecondaryWidgets(); | 43 views::Widget::CloseAllSecondaryWidgets(); |
| 40 | 44 |
| 41 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 46 // Stop handling display configuration events once the shutdown |
| 47 // process starts. crbug.com/177014. |
| 48 ash::Shell::GetInstance()->output_configurator()->Stop(); |
| 49 |
| 42 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 50 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 43 switches::kDisableZeroBrowsersOpenForTests) && | 51 switches::kDisableZeroBrowsersOpenForTests) && |
| 44 !chrome::IsRunningInAppMode()) { | 52 !chrome::IsRunningInAppMode()) { |
| 45 // App is exiting, call EndKeepAlive() on behalf of Aura Shell. | 53 // App is exiting, call EndKeepAlive() on behalf of Aura Shell. |
| 46 EndKeepAlive(); | 54 EndKeepAlive(); |
| 47 // Make sure we have notified the session manager that we are exiting. | 55 // Make sure we have notified the session manager that we are exiting. |
| 48 // This might be called from FastShutdown() or CloseAllBrowsers(), but not | 56 // This might be called from FastShutdown() or CloseAllBrowsers(), but not |
| 49 // if something prevents a browser from closing before SetTryingToQuit() | 57 // if something prevents a browser from closing before SetTryingToQuit() |
| 50 // gets called (e.g. browser->TabsNeedBeforeUnloadFired() is true). | 58 // gets called (e.g. browser->TabsNeedBeforeUnloadFired() is true). |
| 51 // NotifyAndTerminate does nothing if called more than once. | 59 // NotifyAndTerminate does nothing if called more than once. |
| 52 NotifyAndTerminate(true); | 60 NotifyAndTerminate(true); |
| 53 } | 61 } |
| 54 #endif // OS_CHROMEOS | 62 #endif // OS_CHROMEOS |
| 55 } | 63 } |
| 56 | 64 |
| 57 } // namespace chrome | 65 } // namespace chrome |
| OLD | NEW |