Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: ui/aura/mus/focus_synchronizer.cc

Issue 2578893003: Converts chrome to aura-mus (Closed)
Patch Set: merge again Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura/mus/focus_synchronizer.cc
diff --git a/ui/aura/mus/focus_synchronizer.cc b/ui/aura/mus/focus_synchronizer.cc
index b211315fc9ca0c97d991b01993559d1fe0cd4d51..74ad3e09c8db15283e45a3f2a3818bd6027788a6 100644
--- a/ui/aura/mus/focus_synchronizer.cc
+++ b/ui/aura/mus/focus_synchronizer.cc
@@ -16,13 +16,16 @@ namespace aura {
FocusSynchronizer::FocusSynchronizer(FocusSynchronizerDelegate* delegate,
ui::mojom::WindowTree* window_tree)
- : delegate_(delegate), window_tree_(window_tree) {
- Env::GetInstance()->AddObserver(this);
+ : delegate_(delegate), window_tree_(window_tree), env_(Env::GetInstance()) {
+ DCHECK(env_);
+ env_->AddObserver(this);
}
FocusSynchronizer::~FocusSynchronizer() {
- SetActiveFocusClient(nullptr);
- Env::GetInstance()->RemoveObserver(this);
+ if (env_) {
+ SetActiveFocusClient(nullptr);
+ env_->RemoveObserver(this);
+ }
}
void FocusSynchronizer::SetFocusFromServer(WindowMus* window) {
@@ -81,6 +84,13 @@ void FocusSynchronizer::OnWindowFocused(Window* gained_focus,
void FocusSynchronizer::OnWindowInitialized(Window* window) {}
+void FocusSynchronizer::OnWillDestroyEnv() {
+ // TODO(sky): this override should not be necessary. http://crbug.com/674803.
+ SetActiveFocusClient(nullptr);
+ env_->RemoveObserver(this);
+ env_ = nullptr;
+}
+
void FocusSynchronizer::OnActiveFocusClientChanged(
client::FocusClient* focus_client,
Window* window) {

Powered by Google App Engine
This is Rietveld 408576698