blob: 8ebb68d27d8cebba98976513a03905a0bc2c46d2 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <windows.h>
#include "base/callback.h"
#include "base/component_export.h"
#include "base/macros.h"
namespace ui {
// Calls the provided callback on WM_WTSSESSION_CHANGE messages along with
// managing the tricky business of observing a singleton object. Only
// WTS_SESSION_LOCK and WTS_SESSION_UNLOCK events trigger the callback
// because those are the only events existing observers handle.
class COMPONENT_EXPORT(UI_BASE) SessionChangeObserver {
// WPARAM is the wparam passed to the OnWndProc when message is
// WM_WTSSESSION_CHANGE. The bool indicates whether the session
// change is for the current session or not. If we couldn't get the current
// session id, it will be nullptr.
using WtsCallback = base::RepeatingCallback<void(WPARAM, const bool*)>;
explicit SessionChangeObserver(const WtsCallback& callback);
class WtsRegistrationNotificationManager;
void OnSessionChange(WPARAM wparam, const bool* is_current_session);
void ClearCallback();
WtsCallback callback_;
} // namespace ui