| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/views/auto_keep_alive.h" | 5 #include "chrome/browser/ui/views/auto_keep_alive.h" |
| 6 | 6 |
| 7 #include "chrome/browser/lifetime/application_lifetime.h" | 7 #include "chrome/browser/lifetime/browser_keep_alive.h" |
| 8 #include "chrome/browser/ui/host_desktop.h" | 8 #include "chrome/browser/ui/host_desktop.h" |
| 9 | 9 |
| 10 AutoKeepAlive::AutoKeepAlive(gfx::NativeWindow window) | 10 AutoKeepAlive::AutoKeepAlive(gfx::NativeWindow window) { |
| 11 : keep_alive_available_(false) { | |
| 12 // In case of aura we want default to be keep alive not available for ash | 11 // In case of aura we want default to be keep alive not available for ash |
| 13 // because ash has keep alive set and we don't want additional keep alive | 12 // because ash has keep alive set and we don't want additional keep alive |
| 14 // count. | 13 // count. |
| 15 chrome::HostDesktopType desktop_type = | 14 chrome::HostDesktopType desktop_type = |
| 16 window ? chrome::GetHostDesktopTypeForNativeWindow(window) | 15 window ? chrome::GetHostDesktopTypeForNativeWindow(window) |
| 17 : chrome::GetActiveDesktop(); | 16 : chrome::GetActiveDesktop(); |
| 18 if (desktop_type != chrome::HOST_DESKTOP_TYPE_ASH) { | 17 if (desktop_type != chrome::HOST_DESKTOP_TYPE_ASH) { |
| 19 keep_alive_available_ = true; | 18 keep_alive_.reset(new browser_lifetime::ScopedKeepAlive); |
| 20 chrome::IncrementKeepAliveCount(); | |
| 21 } | 19 } |
| 22 } | 20 } |
| 23 | 21 |
| 24 AutoKeepAlive::~AutoKeepAlive() { | 22 AutoKeepAlive::~AutoKeepAlive() { |
| 25 if (keep_alive_available_) | 23 keep_alive_.reset(); |
| 26 chrome::DecrementKeepAliveCount(); | |
| 27 } | 24 } |
| OLD | NEW |