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