| 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/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 416 } |
| 417 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); | 417 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
| 418 content_window_->Init(params.layer_type); | 418 content_window_->Init(params.layer_type); |
| 419 wm::SetShadowType(content_window_, wm::SHADOW_TYPE_NONE); | 419 wm::SetShadowType(content_window_, wm::SHADOW_TYPE_NONE); |
| 420 | 420 |
| 421 content_window_container_ = new aura::Window(NULL); | 421 content_window_container_ = new aura::Window(NULL); |
| 422 content_window_container_->Init(ui::LAYER_NOT_DRAWN); | 422 content_window_container_->Init(ui::LAYER_NOT_DRAWN); |
| 423 content_window_container_->Show(); | 423 content_window_container_->Show(); |
| 424 content_window_container_->AddChild(content_window_); | 424 content_window_container_->AddChild(content_window_); |
| 425 | 425 |
| 426 //TODO(mfomitchev): Hack |
| 427 #if defined(OS_ANDROID) |
| 428 desktop_window_tree_host_ = params.desktop_window_tree_host ? |
| 429 params.desktop_window_tree_host : nullptr; |
| 430 #else |
| 426 desktop_window_tree_host_ = params.desktop_window_tree_host ? | 431 desktop_window_tree_host_ = params.desktop_window_tree_host ? |
| 427 params.desktop_window_tree_host : | 432 params.desktop_window_tree_host : |
| 428 DesktopWindowTreeHost::Create(native_widget_delegate_, this); | 433 DesktopWindowTreeHost::Create(native_widget_delegate_, this); |
| 434 #endif |
| 429 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); | 435 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); |
| 430 desktop_window_tree_host_->Init(content_window_, params); | 436 desktop_window_tree_host_->Init(content_window_, params); |
| 431 | 437 |
| 432 host_->InitHost(); | 438 host_->InitHost(); |
| 433 host_->window()->AddChild(content_window_container_); | 439 host_->window()->AddChild(content_window_container_); |
| 434 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); | 440 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); |
| 435 | 441 |
| 436 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); | 442 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); |
| 437 | 443 |
| 438 // The WindowsModalityController event filter should be at the head of the | 444 // The WindowsModalityController event filter should be at the head of the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 449 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- | 455 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- |
| 450 // handed way of accomplishing focus. | 456 // handed way of accomplishing focus. |
| 451 // No event filter for aura::Env. Create CompoundEventFilter per | 457 // No event filter for aura::Env. Create CompoundEventFilter per |
| 452 // WindowEventDispatcher. | 458 // WindowEventDispatcher. |
| 453 root_window_event_filter_.reset(new wm::CompoundEventFilter); | 459 root_window_event_filter_.reset(new wm::CompoundEventFilter); |
| 454 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); | 460 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); |
| 455 | 461 |
| 456 // The host's dispatcher must be added to |native_cursor_manager_| before | 462 // The host's dispatcher must be added to |native_cursor_manager_| before |
| 457 // OnNativeWidgetCreated() is called. | 463 // OnNativeWidgetCreated() is called. |
| 458 cursor_reference_count_++; | 464 cursor_reference_count_++; |
| 465 #if !defined(OS_ANDROID) |
| 459 if (!native_cursor_manager_) { | 466 if (!native_cursor_manager_) { |
| 460 native_cursor_manager_ = new DesktopNativeCursorManager( | 467 native_cursor_manager_ = new DesktopNativeCursorManager( |
| 461 DesktopCursorLoaderUpdater::Create()); | 468 DesktopCursorLoaderUpdater::Create()); |
| 462 } | 469 } |
| 470 #endif |
| 463 if (!cursor_manager_) { | 471 if (!cursor_manager_) { |
| 464 cursor_manager_ = new wm::CursorManager( | 472 cursor_manager_ = new wm::CursorManager( |
| 465 scoped_ptr<wm::NativeCursorManager>(native_cursor_manager_)); | 473 scoped_ptr<wm::NativeCursorManager>(native_cursor_manager_)); |
| 466 } | 474 } |
| 467 native_cursor_manager_->AddHost(host()); | 475 native_cursor_manager_->AddHost(host()); |
| 468 aura::client::SetCursorClient(host_->window(), cursor_manager_); | 476 aura::client::SetCursorClient(host_->window(), cursor_manager_); |
| 469 | 477 |
| 470 desktop_window_tree_host_->OnNativeWidgetCreated(params); | 478 desktop_window_tree_host_->OnNativeWidgetCreated(params); |
| 471 | 479 |
| 472 UpdateWindowTransparency(); | 480 UpdateWindowTransparency(); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 wm_transition = wm::ANIMATE_BOTH; | 938 wm_transition = wm::ANIMATE_BOTH; |
| 931 break; | 939 break; |
| 932 case Widget::ANIMATE_NONE: | 940 case Widget::ANIMATE_NONE: |
| 933 wm_transition = wm::ANIMATE_NONE; | 941 wm_transition = wm::ANIMATE_NONE; |
| 934 break; | 942 break; |
| 935 } | 943 } |
| 936 wm::SetWindowVisibilityAnimationTransition(content_window_, wm_transition); | 944 wm::SetWindowVisibilityAnimationTransition(content_window_, wm_transition); |
| 937 } | 945 } |
| 938 | 946 |
| 939 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const { | 947 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const { |
| 948 #if defined(OS_ANDROID) |
| 949 return nullptr; |
| 950 #else |
| 940 return DesktopWindowTreeHost::GetNativeTheme(content_window_); | 951 return DesktopWindowTreeHost::GetNativeTheme(content_window_); |
| 952 #endif |
| 941 } | 953 } |
| 942 | 954 |
| 943 void DesktopNativeWidgetAura::OnRootViewLayout() { | 955 void DesktopNativeWidgetAura::OnRootViewLayout() { |
| 944 if (content_window_) | 956 if (content_window_) |
| 945 desktop_window_tree_host_->OnRootViewLayout(); | 957 desktop_window_tree_host_->OnRootViewLayout(); |
| 946 } | 958 } |
| 947 | 959 |
| 948 bool DesktopNativeWidgetAura::IsTranslucentWindowOpacitySupported() const { | 960 bool DesktopNativeWidgetAura::IsTranslucentWindowOpacitySupported() const { |
| 949 return content_window_ && | 961 return content_window_ && |
| 950 desktop_window_tree_host_->IsTranslucentWindowOpacitySupported(); | 962 desktop_window_tree_host_->IsTranslucentWindowOpacitySupported(); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 if (cursor_reference_count_ == 0) { | 1213 if (cursor_reference_count_ == 0) { |
| 1202 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1214 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
| 1203 // for cleaning up |cursor_manager_|. | 1215 // for cleaning up |cursor_manager_|. |
| 1204 delete cursor_manager_; | 1216 delete cursor_manager_; |
| 1205 native_cursor_manager_ = NULL; | 1217 native_cursor_manager_ = NULL; |
| 1206 cursor_manager_ = NULL; | 1218 cursor_manager_ = NULL; |
| 1207 } | 1219 } |
| 1208 } | 1220 } |
| 1209 | 1221 |
| 1210 } // namespace views | 1222 } // namespace views |
| OLD | NEW |