Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / gfx / win / singleton_hwnd_observer.cc
blobf439105e659d2a8aba8f0b4cef38ce602bfff918
1 // Copyright 2015 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 "ui/gfx/win/singleton_hwnd_observer.h"
7 #include "ui/gfx/win/singleton_hwnd.h"
9 namespace gfx {
11 SingletonHwndObserver::SingletonHwndObserver(const WndProc& wnd_proc)
12 : wnd_proc_(wnd_proc) {
13 DCHECK(!wnd_proc.is_null());
14 SingletonHwnd::GetInstance()->AddObserver(this);
17 SingletonHwndObserver::~SingletonHwndObserver() {
18 ClearWndProc();
21 void SingletonHwndObserver::ClearWndProc() {
22 if (!wnd_proc_.is_null()) {
23 SingletonHwnd::GetInstance()->RemoveObserver(this);
24 wnd_proc_.Reset();
28 void SingletonHwndObserver::OnWndProc(HWND hwnd,
29 UINT message,
30 WPARAM wparam,
31 LPARAM lparam) {
32 wnd_proc_.Run(hwnd, message, wparam, lparam);
35 } // namespace gfx