forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmode_indicator_observer.cc
34 lines (26 loc) · 1002 Bytes
/
mode_indicator_observer.cc
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
// Copyright 2018 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 "ash/ime/mode_indicator_observer.h"
#include "ui/views/widget/widget.h"
namespace ash {
ModeIndicatorObserver::ModeIndicatorObserver() : active_widget_(nullptr) {}
ModeIndicatorObserver::~ModeIndicatorObserver() {
if (active_widget_)
active_widget_->RemoveObserver(this);
CHECK(!IsInObserverList());
}
void ModeIndicatorObserver::AddModeIndicatorWidget(views::Widget* widget) {
// If other active mode indicator widget is shown, close it immediately
// without fading animation. Then store this widget as the active widget.
DCHECK(widget);
if (active_widget_)
active_widget_->Close();
active_widget_ = widget;
widget->AddObserver(this);
}
void ModeIndicatorObserver::OnWidgetDestroying(views::Widget* widget) {
if (widget == active_widget_)
active_widget_ = nullptr;
}
} // namespace ash