summaryrefslogtreecommitdiffstats
path: root/ui/views/win/windows_session_change_observer.h
blob: 38a3e084c7bbdb1d0585c5f6035d5795ff50d663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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.

#ifndef UI_VIEWS_WIN_WINDOWS_SESSION_CHANGE_OBSERVER_H_
#define UI_VIEWS_WIN_WINDOWS_SESSION_CHANGE_OBSERVER_H_

#include <windows.h>

#include "base/callback.h"
#include "base/macros.h"

namespace views {

// Calls the provided callback on WM_WTSSESSION_CHANGE messages along with
// managing the tricky business of observing a singleton object.
class WindowsSessionChangeObserver {
 public:
  typedef base::Callback<void(WPARAM)> WtsCallback;
  explicit WindowsSessionChangeObserver(const WtsCallback& callback);
  ~WindowsSessionChangeObserver();

 private:
  class WtsRegistrationNotificationManager;

  void OnSessionChange(WPARAM wparam);
  void ClearCallback();

  WtsCallback callback_;

  DISALLOW_COPY_AND_ASSIGN(WindowsSessionChangeObserver);
};

}  // namespace views

#endif  // UI_VIEWS_WIN_WINDOWS_SESSION_CHANGE_OBSERVER_H_