This source file includes following definitions.
- GetInstance
- AddFocusChangeListener
- RemoveFocusChangeListener
- OnWidgetFocusEvent
#include "ui/views/focus/widget_focus_manager.h"
#include "base/memory/singleton.h"
namespace views {
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() {
WidgetFocusManager::GetInstance()->DisableNotifications();
}
AutoNativeNotificationDisabler::~AutoNativeNotificationDisabler() {
WidgetFocusManager::GetInstance()->EnableNotifications();
}
}