| Index: ui/gfx/win/singleton_hwnd_observer.cc
|
| diff --git a/ui/gfx/win/singleton_hwnd_observer.cc b/ui/gfx/win/singleton_hwnd_observer.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f439105e659d2a8aba8f0b4cef38ce602bfff918
|
| --- /dev/null
|
| +++ b/ui/gfx/win/singleton_hwnd_observer.cc
|
| @@ -0,0 +1,35 @@
|
| +// 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 "ui/gfx/win/singleton_hwnd_observer.h"
|
| +
|
| +#include "ui/gfx/win/singleton_hwnd.h"
|
| +
|
| +namespace gfx {
|
| +
|
| +SingletonHwndObserver::SingletonHwndObserver(const WndProc& wnd_proc)
|
| + : wnd_proc_(wnd_proc) {
|
| + DCHECK(!wnd_proc.is_null());
|
| + SingletonHwnd::GetInstance()->AddObserver(this);
|
| +}
|
| +
|
| +SingletonHwndObserver::~SingletonHwndObserver() {
|
| + ClearWndProc();
|
| +}
|
| +
|
| +void SingletonHwndObserver::ClearWndProc() {
|
| + if (!wnd_proc_.is_null()) {
|
| + SingletonHwnd::GetInstance()->RemoveObserver(this);
|
| + wnd_proc_.Reset();
|
| + }
|
| +}
|
| +
|
| +void SingletonHwndObserver::OnWndProc(HWND hwnd,
|
| + UINT message,
|
| + WPARAM wparam,
|
| + LPARAM lparam) {
|
| + wnd_proc_.Run(hwnd, message, wparam, lparam);
|
| +}
|
| +
|
| +} // namespace gfx
|
|
|