| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 else | 257 else |
| 258 CloseNow(); | 258 CloseNow(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 // static | 261 // static |
| 262 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow( | 262 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow( |
| 263 aura::Window* window) { | 263 aura::Window* window) { |
| 264 return window->GetProperty(kDesktopNativeWidgetAuraKey); | 264 return window->GetProperty(kDesktopNativeWidgetAuraKey); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void DesktopNativeWidgetAura::SetDesktopWindowTreeHost( |
| 268 std::unique_ptr<DesktopWindowTreeHost> desktop_window_tree_host) { |
| 269 DCHECK(!desktop_window_tree_host_); |
| 270 desktop_window_tree_host_ = desktop_window_tree_host.get(); |
| 271 host_.reset(desktop_window_tree_host.release()->AsWindowTreeHost()); |
| 272 } |
| 273 |
| 267 void DesktopNativeWidgetAura::OnHostClosed() { | 274 void DesktopNativeWidgetAura::OnHostClosed() { |
| 268 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by | 275 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by |
| 269 // DesktopWindowTreeHost. | 276 // DesktopWindowTreeHost. |
| 270 | 277 |
| 271 // The WindowModalityController is at the front of the event pretarget | 278 // The WindowModalityController is at the front of the event pretarget |
| 272 // handler list. We destroy it first to preserve order symantics. | 279 // handler list. We destroy it first to preserve order symantics. |
| 273 if (window_modality_controller_) | 280 if (window_modality_controller_) |
| 274 window_modality_controller_.reset(); | 281 window_modality_controller_.reset(); |
| 275 | 282 |
| 276 // Make sure we don't have capture. Otherwise CaptureController and | 283 // Make sure we don't have capture. Otherwise CaptureController and |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } | 402 } |
| 396 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); | 403 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
| 397 content_window_->Init(params.layer_type); | 404 content_window_->Init(params.layer_type); |
| 398 wm::SetShadowType(content_window_, wm::SHADOW_TYPE_NONE); | 405 wm::SetShadowType(content_window_, wm::SHADOW_TYPE_NONE); |
| 399 | 406 |
| 400 content_window_container_ = new aura::Window(NULL); | 407 content_window_container_ = new aura::Window(NULL); |
| 401 content_window_container_->Init(ui::LAYER_NOT_DRAWN); | 408 content_window_container_->Init(ui::LAYER_NOT_DRAWN); |
| 402 content_window_container_->Show(); | 409 content_window_container_->Show(); |
| 403 content_window_container_->AddChild(content_window_); | 410 content_window_container_->AddChild(content_window_); |
| 404 | 411 |
| 405 desktop_window_tree_host_ = params.desktop_window_tree_host ? | 412 if (!desktop_window_tree_host_) { |
| 406 params.desktop_window_tree_host : | 413 desktop_window_tree_host_ = |
| 407 DesktopWindowTreeHost::Create(native_widget_delegate_, this); | 414 params.desktop_window_tree_host |
| 408 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); | 415 ? params.desktop_window_tree_host |
| 416 : DesktopWindowTreeHost::Create(native_widget_delegate_, this); |
| 417 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); |
| 418 } |
| 409 desktop_window_tree_host_->Init(content_window_, params); | 419 desktop_window_tree_host_->Init(content_window_, params); |
| 410 | 420 |
| 411 host_->InitHost(); | 421 host_->InitHost(); |
| 412 host_->window()->AddChild(content_window_container_); | 422 host_->window()->AddChild(content_window_container_); |
| 413 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); | 423 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); |
| 414 | 424 |
| 415 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); | 425 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); |
| 416 | 426 |
| 417 // The WindowsModalityController event filter should be at the head of the | 427 // The WindowsModalityController event filter should be at the head of the |
| 418 // pre target handlers list. This ensures that it handles input events first | 428 // pre target handlers list. This ensures that it handles input events first |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 new wm::FocusController(new DesktopFocusRules(content_window_)); | 466 new wm::FocusController(new DesktopFocusRules(content_window_)); |
| 457 focus_client_.reset(focus_controller); | 467 focus_client_.reset(focus_controller); |
| 458 aura::client::SetFocusClient(host_->window(), focus_controller); | 468 aura::client::SetFocusClient(host_->window(), focus_controller); |
| 459 aura::client::SetActivationClient(host_->window(), focus_controller); | 469 aura::client::SetActivationClient(host_->window(), focus_controller); |
| 460 host_->window()->AddPreTargetHandler(focus_controller); | 470 host_->window()->AddPreTargetHandler(focus_controller); |
| 461 | 471 |
| 462 position_client_.reset(new DesktopScreenPositionClient(host_->window())); | 472 position_client_.reset(new DesktopScreenPositionClient(host_->window())); |
| 463 | 473 |
| 464 drag_drop_client_ = desktop_window_tree_host_->CreateDragDropClient( | 474 drag_drop_client_ = desktop_window_tree_host_->CreateDragDropClient( |
| 465 native_cursor_manager_); | 475 native_cursor_manager_); |
| 466 aura::client::SetDragDropClient(host_->window(), | 476 // Mus returns null from CreateDragDropClient(). |
| 467 drag_drop_client_.get()); | 477 if (drag_drop_client_) |
| 478 aura::client::SetDragDropClient(host_->window(), drag_drop_client_.get()); |
| 468 | 479 |
| 469 static_cast<aura::client::FocusClient*>(focus_client_.get())-> | 480 static_cast<aura::client::FocusClient*>(focus_client_.get())-> |
| 470 FocusWindow(content_window_); | 481 FocusWindow(content_window_); |
| 471 | 482 |
| 472 OnHostResized(host()); | 483 OnHostResized(host()); |
| 473 | 484 |
| 474 host_->AddObserver(this); | 485 host_->AddObserver(this); |
| 475 | 486 |
| 476 window_parenting_client_.reset( | 487 window_parenting_client_.reset( |
| 477 new DesktopNativeWidgetAuraWindowParentingClient(host_->window())); | 488 new DesktopNativeWidgetAuraWindowParentingClient(host_->window())); |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 if (cursor_reference_count_ == 0) { | 1191 if (cursor_reference_count_ == 0) { |
| 1181 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1192 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
| 1182 // for cleaning up |cursor_manager_|. | 1193 // for cleaning up |cursor_manager_|. |
| 1183 delete cursor_manager_; | 1194 delete cursor_manager_; |
| 1184 native_cursor_manager_ = NULL; | 1195 native_cursor_manager_ = NULL; |
| 1185 cursor_manager_ = NULL; | 1196 cursor_manager_ = NULL; |
| 1186 } | 1197 } |
| 1187 } | 1198 } |
| 1188 | 1199 |
| 1189 } // namespace views | 1200 } // namespace views |
| OLD | NEW |