Index: ui/views/touchui/touch_selection_controller_impl.cc |
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc |
index f77df761fb52d8ba8f5cbd54530c070728bfc1ee..4b097624988f5216d4477fff054a8ec97aade615 100644 |
--- a/ui/views/touchui/touch_selection_controller_impl.cc |
+++ b/ui/views/touchui/touch_selection_controller_impl.cc |
@@ -327,8 +327,9 @@ TouchSelectionControllerImpl::TouchSelectionControllerImpl( |
client_view->GetNativeView())), |
context_menu_(NULL), |
dragging_handle_(NULL) { |
- client_widget_ = Widget::GetTopLevelWidgetForNativeView( |
- client_view_->GetNativeView()); |
+ aura::Window* client_window = client_view_->GetNativeView(); |
+ client_window->AddObserver(this); |
+ client_widget_ = Widget::GetTopLevelWidgetForNativeView(client_window); |
if (client_widget_) |
client_widget_->AddObserver(this); |
aura::Env::GetInstance()->AddPreTargetHandler(this); |
@@ -339,6 +340,7 @@ TouchSelectionControllerImpl::~TouchSelectionControllerImpl() { |
aura::Env::GetInstance()->RemovePreTargetHandler(this); |
if (client_widget_) |
client_widget_->RemoveObserver(this); |
+ client_view_->GetNativeView()->RemoveObserver(this); |
} |
void TouchSelectionControllerImpl::SelectionChanged() { |
@@ -509,6 +511,12 @@ void TouchSelectionControllerImpl::OnMenuClosed(TouchEditingMenuView* menu) { |
context_menu_ = NULL; |
} |
+void TouchSelectionControllerImpl::OnAncestorWindowTransformed( |
+ aura::Window* window, |
+ aura::Window* ancestor) { |
+ client_view_->DestroyTouchSelection(); |
+} |
+ |
void TouchSelectionControllerImpl::OnWidgetClosing(Widget* widget) { |
DCHECK_EQ(client_widget_, widget); |
client_widget_ = NULL; |