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.
5 #include "ui/views/test/test_views_delegate.h"
7 #include "ui/views/widget/native_widget_mac.h"
11 TestViewsDelegate::TestViewsDelegate()
12 : use_desktop_native_widgets_(false),
13 use_transparent_windows_(false) {
14 DCHECK(!ViewsDelegate::views_delegate);
15 ViewsDelegate::views_delegate = this;
18 TestViewsDelegate::~TestViewsDelegate() {
19 if (ViewsDelegate::views_delegate == this)
20 ViewsDelegate::views_delegate = NULL;
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;
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);