blob: d50d490d669d8651cc6c027831d14eb30a077f41 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright (c) 2011 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/views/focus/widget_focus_manager.h"
#include "base/memory/singleton.h"
namespace views {
// WidgetFocusManager ----------------------------------------------------------
// static
WidgetFocusManager* WidgetFocusManager::GetInstance() {
return Singleton<WidgetFocusManager>::get();
}
void WidgetFocusManager::AddFocusChangeListener(
WidgetFocusChangeListener* listener) {
focus_change_listeners_.AddObserver(listener);
}
void WidgetFocusManager::RemoveFocusChangeListener(
WidgetFocusChangeListener* listener) {
focus_change_listeners_.RemoveObserver(listener);
}
void WidgetFocusManager::OnWidgetFocusEvent(gfx::NativeView focused_before,
gfx::NativeView focused_now) {
if (enabled_ && focused_before != focused_now) {
FOR_EACH_OBSERVER(WidgetFocusChangeListener, focus_change_listeners_,
OnNativeFocusChange(focused_before, focused_now));
}
}
WidgetFocusManager::WidgetFocusManager() : enabled_(true) {}
WidgetFocusManager::~WidgetFocusManager() {}
// AutoNativeNotificationDisabler ----------------------------------------------
AutoNativeNotificationDisabler::AutoNativeNotificationDisabler() {
WidgetFocusManager::GetInstance()->DisableNotifications();
}
AutoNativeNotificationDisabler::~AutoNativeNotificationDisabler() {
WidgetFocusManager::GetInstance()->EnableNotifications();
}
} // namespace views
|