1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "ui/views/test/test_views_delegate.h" 6 7 #include "ui/wm/core/wm_state.h" 8 9 #if !defined(OS_CHROMEOS) 10 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 11 #endif // !defined(OS_CHROMEOS) 12 13 14 namespace views { 15 16 TestViewsDelegate::TestViewsDelegate() 17 : use_desktop_native_widgets_(false), 18 use_transparent_windows_(false) { 19 DCHECK(!ViewsDelegate::views_delegate); 20 ViewsDelegate::views_delegate = this; 21 #if defined(USE_AURA) 22 wm_state_.reset(new wm::WMState); 23 #endif 24 } 25 26 TestViewsDelegate::~TestViewsDelegate() { 27 if (ViewsDelegate::views_delegate == this) 28 ViewsDelegate::views_delegate = NULL; 29 } 30 31 void TestViewsDelegate::OnBeforeWidgetInit( 32 Widget::InitParams* params, 33 internal::NativeWidgetDelegate* delegate) { 34 if (params->opacity == Widget::InitParams::INFER_OPACITY) { 35 params->opacity = use_transparent_windows_ ? 36 Widget::InitParams::TRANSLUCENT_WINDOW : 37 Widget::InitParams::OPAQUE_WINDOW; 38 } 39 #if !defined(OS_CHROMEOS) 40 if (!params->native_widget && use_desktop_native_widgets_) 41 params->native_widget = new DesktopNativeWidgetAura(delegate); 42 #endif // !defined(OS_CHROMEOS) 43 } 44 45 } // namespace views 46