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