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/views/widget/native_widget_mac.h" 8 9 namespace views { 10 11 TestViewsDelegate::TestViewsDelegate() 12 : use_desktop_native_widgets_(false), 13 use_transparent_windows_(false) { 14 DCHECK(!ViewsDelegate::views_delegate); 15 ViewsDelegate::views_delegate = this; 16 } 17 18 TestViewsDelegate::~TestViewsDelegate() { 19 if (ViewsDelegate::views_delegate == this) 20 ViewsDelegate::views_delegate = NULL; 21 } 22 23 void TestViewsDelegate::OnBeforeWidgetInit( 24 Widget::InitParams* params, 25 internal::NativeWidgetDelegate* delegate) { 26 if (params->opacity == Widget::InitParams::INFER_OPACITY) { 27 params->opacity = use_transparent_windows_ ? 28 Widget::InitParams::TRANSLUCENT_WINDOW : 29 Widget::InitParams::OPAQUE_WINDOW; 30 } 31 // TODO(tapted): This should return a *Desktop*NativeWidgetMac. 32 if (!params->native_widget && use_desktop_native_widgets_) 33 params->native_widget = new NativeWidgetMac(delegate); 34 } 35 36 } // namespace views 37