| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/widget/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 26 #include "ui/gfx/geometry/size_conversions.h" | 26 #include "ui/gfx/geometry/size_conversions.h" |
| 27 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
| 28 #include "ui/native_theme/native_theme.h" | 28 #include "ui/native_theme/native_theme.h" |
| 29 #include "ui/views/corewm/tooltip.h" | 29 #include "ui/views/corewm/tooltip.h" |
| 30 #include "ui/views/corewm/tooltip_controller.h" | 30 #include "ui/views/corewm/tooltip_controller.h" |
| 31 #include "ui/views/drag_utils.h" | 31 #include "ui/views/drag_utils.h" |
| 32 #include "ui/views/view_constants_aura.h" | 32 #include "ui/views/view_constants_aura.h" |
| 33 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" | 33 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" |
| 34 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" | 34 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" |
| 35 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" | |
| 36 #include "ui/views/widget/desktop_aura/desktop_event_client.h" | 35 #include "ui/views/widget/desktop_aura/desktop_event_client.h" |
| 37 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" | 36 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" |
| 38 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 37 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
| 39 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 38 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
| 40 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" | 39 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
| 41 #include "ui/views/widget/drop_helper.h" | 40 #include "ui/views/widget/drop_helper.h" |
| 42 #include "ui/views/widget/native_widget_aura.h" | 41 #include "ui/views/widget/native_widget_aura.h" |
| 43 #include "ui/views/widget/root_view.h" | 42 #include "ui/views/widget/root_view.h" |
| 44 #include "ui/views/widget/tooltip_manager_aura.h" | 43 #include "ui/views/widget/tooltip_manager_aura.h" |
| 45 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 desktop_window_tree_host_ = NULL; | 333 desktop_window_tree_host_ = NULL; |
| 335 content_window_ = NULL; | 334 content_window_ = NULL; |
| 336 | 335 |
| 337 native_widget_delegate_->OnNativeWidgetDestroyed(); | 336 native_widget_delegate_->OnNativeWidgetDestroyed(); |
| 338 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 337 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 339 delete this; | 338 delete this; |
| 340 } | 339 } |
| 341 | 340 |
| 342 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( | 341 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( |
| 343 aura::WindowTreeHost* host) { | 342 aura::WindowTreeHost* host) { |
| 344 // |dispatcher_| is still valid, but DesktopWindowTreeHost is nearly | |
| 345 // destroyed. Do cleanup here of members DesktopWindowTreeHost may also use. | |
| 346 aura::client::SetDispatcherClient(host->window(), NULL); | |
| 347 dispatcher_client_.reset(); | |
| 348 | |
| 349 // We explicitly do NOT clear the cursor client property. Since the cursor | 343 // We explicitly do NOT clear the cursor client property. Since the cursor |
| 350 // manager is a singleton, it can outlive any window hierarchy, and it's | 344 // manager is a singleton, it can outlive any window hierarchy, and it's |
| 351 // important that objects attached to this destroying window hierarchy have | 345 // important that objects attached to this destroying window hierarchy have |
| 352 // an opportunity to deregister their observers from the cursor manager. | 346 // an opportunity to deregister their observers from the cursor manager. |
| 353 // They may want to do this when they are notified that they're being | 347 // They may want to do this when they are notified that they're being |
| 354 // removed from the window hierarchy, which happens soon after this | 348 // removed from the window hierarchy, which happens soon after this |
| 355 // function when DesktopWindowTreeHost* calls DestroyDispatcher(). | 349 // function when DesktopWindowTreeHost* calls DestroyDispatcher(). |
| 356 native_cursor_manager_->RemoveHost(host); | 350 native_cursor_manager_->RemoveHost(host); |
| 357 | 351 |
| 358 aura::client::SetScreenPositionClient(host->window(), NULL); | 352 aura::client::SetScreenPositionClient(host->window(), NULL); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 470 |
| 477 capture_client_.reset(new DesktopCaptureClient(host_->window())); | 471 capture_client_.reset(new DesktopCaptureClient(host_->window())); |
| 478 | 472 |
| 479 wm::FocusController* focus_controller = | 473 wm::FocusController* focus_controller = |
| 480 new wm::FocusController(new DesktopFocusRules(content_window_)); | 474 new wm::FocusController(new DesktopFocusRules(content_window_)); |
| 481 focus_client_.reset(focus_controller); | 475 focus_client_.reset(focus_controller); |
| 482 aura::client::SetFocusClient(host_->window(), focus_controller); | 476 aura::client::SetFocusClient(host_->window(), focus_controller); |
| 483 aura::client::SetActivationClient(host_->window(), focus_controller); | 477 aura::client::SetActivationClient(host_->window(), focus_controller); |
| 484 host_->window()->AddPreTargetHandler(focus_controller); | 478 host_->window()->AddPreTargetHandler(focus_controller); |
| 485 | 479 |
| 486 dispatcher_client_.reset(new DesktopDispatcherClient); | |
| 487 aura::client::SetDispatcherClient(host_->window(), | |
| 488 dispatcher_client_.get()); | |
| 489 | |
| 490 position_client_.reset(new DesktopScreenPositionClient(host_->window())); | 480 position_client_.reset(new DesktopScreenPositionClient(host_->window())); |
| 491 | 481 |
| 492 drag_drop_client_ = desktop_window_tree_host_->CreateDragDropClient( | 482 drag_drop_client_ = desktop_window_tree_host_->CreateDragDropClient( |
| 493 native_cursor_manager_); | 483 native_cursor_manager_); |
| 494 aura::client::SetDragDropClient(host_->window(), | 484 aura::client::SetDragDropClient(host_->window(), |
| 495 drag_drop_client_.get()); | 485 drag_drop_client_.get()); |
| 496 | 486 |
| 497 static_cast<aura::client::FocusClient*>(focus_client_.get())-> | 487 static_cast<aura::client::FocusClient*>(focus_client_.get())-> |
| 498 FocusWindow(content_window_); | 488 FocusWindow(content_window_); |
| 499 | 489 |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 if (cursor_reference_count_ == 0) { | 1197 if (cursor_reference_count_ == 0) { |
| 1208 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1198 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
| 1209 // for cleaning up |cursor_manager_|. | 1199 // for cleaning up |cursor_manager_|. |
| 1210 delete cursor_manager_; | 1200 delete cursor_manager_; |
| 1211 native_cursor_manager_ = NULL; | 1201 native_cursor_manager_ = NULL; |
| 1212 cursor_manager_ = NULL; | 1202 cursor_manager_ = NULL; |
| 1213 } | 1203 } |
| 1214 } | 1204 } |
| 1215 | 1205 |
| 1216 } // namespace views | 1206 } // namespace views |
| OLD | NEW |