OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/keyboard/keyboard_controller.h" | 5 #include "ui/keyboard/keyboard_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 public: | 117 public: |
118 CallbackAnimationObserver(ui::LayerAnimator* animator, | 118 CallbackAnimationObserver(ui::LayerAnimator* animator, |
119 base::Callback<void(void)> callback); | 119 base::Callback<void(void)> callback); |
120 ~CallbackAnimationObserver() override; | 120 ~CallbackAnimationObserver() override; |
121 | 121 |
122 private: | 122 private: |
123 // Overridden from ui::LayerAnimationObserver: | 123 // Overridden from ui::LayerAnimationObserver: |
124 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override; | 124 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override; |
125 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override; | 125 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override; |
126 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} | 126 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} |
127 bool RequiresNotificationWhenAnimatorDestroyed() const override; | |
127 | 128 |
128 ui::LayerAnimator* animator_; | 129 ui::LayerAnimator* animator_; |
sadrul
2015/04/23 23:07:59
Should this be a scoped_refptr<> instead?
bshe
2015/04/24 14:24:37
Great suggestion! Done.
| |
129 base::Callback<void(void)> callback_; | 130 base::Callback<void(void)> callback_; |
130 | 131 |
131 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); | 132 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); |
132 }; | 133 }; |
133 | 134 |
134 CallbackAnimationObserver::CallbackAnimationObserver( | 135 CallbackAnimationObserver::CallbackAnimationObserver( |
135 ui::LayerAnimator* animator, base::Callback<void(void)> callback) | 136 ui::LayerAnimator* animator, base::Callback<void(void)> callback) |
136 : animator_(animator), callback_(callback) { | 137 : animator_(animator), callback_(callback) { |
137 } | 138 } |
138 | 139 |
139 CallbackAnimationObserver::~CallbackAnimationObserver() { | 140 CallbackAnimationObserver::~CallbackAnimationObserver() { |
140 animator_->RemoveObserver(this); | 141 if (animator_) |
142 animator_->RemoveObserver(this); | |
141 } | 143 } |
142 | 144 |
143 void CallbackAnimationObserver::OnLayerAnimationEnded( | 145 void CallbackAnimationObserver::OnLayerAnimationEnded( |
144 ui::LayerAnimationSequence* seq) { | 146 ui::LayerAnimationSequence* seq) { |
145 if (animator_->is_animating()) | 147 if (animator_->is_animating()) |
146 return; | 148 return; |
147 animator_->RemoveObserver(this); | 149 animator_->RemoveObserver(this); |
148 callback_.Run(); | 150 callback_.Run(); |
151 animator_ = NULL; | |
149 } | 152 } |
150 | 153 |
151 void CallbackAnimationObserver::OnLayerAnimationAborted( | 154 void CallbackAnimationObserver::OnLayerAnimationAborted( |
152 ui::LayerAnimationSequence* seq) { | 155 ui::LayerAnimationSequence* seq) { |
153 animator_->RemoveObserver(this); | 156 animator_->RemoveObserver(this); |
157 animator_ = NULL; | |
158 } | |
159 | |
160 bool CallbackAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() | |
161 const { | |
162 return true; | |
154 } | 163 } |
155 | 164 |
156 class WindowBoundsChangeObserver : public aura::WindowObserver { | 165 class WindowBoundsChangeObserver : public aura::WindowObserver { |
157 public: | 166 public: |
158 void OnWindowBoundsChanged(aura::Window* window, | 167 void OnWindowBoundsChanged(aura::Window* window, |
159 const gfx::Rect& old_bounds, | 168 const gfx::Rect& old_bounds, |
160 const gfx::Rect& new_bounds) override; | 169 const gfx::Rect& new_bounds) override; |
161 void OnWindowDestroyed(aura::Window* window) override; | 170 void OnWindowDestroyed(aura::Window* window) override; |
162 | 171 |
163 void AddObservedWindow(aura::Window* window); | 172 void AddObservedWindow(aura::Window* window); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 proxy_->HideKeyboardContainer(container_.get()); | 578 proxy_->HideKeyboardContainer(container_.get()); |
570 } | 579 } |
571 | 580 |
572 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { | 581 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
573 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 582 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
574 if (target_window) | 583 if (target_window) |
575 window_bounds_observer_->AddObservedWindow(target_window); | 584 window_bounds_observer_->AddObservedWindow(target_window); |
576 } | 585 } |
577 | 586 |
578 } // namespace keyboard | 587 } // namespace keyboard |
OLD | NEW |