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 : context_factory_(nullptr),
13 use_desktop_native_widgets_(false),
14 use_transparent_windows_(false) {
15 DCHECK(!ViewsDelegate::views_delegate);
16 ViewsDelegate::views_delegate = this;
19 TestViewsDelegate::~TestViewsDelegate() {
20 if (ViewsDelegate::views_delegate == this)
21 ViewsDelegate::views_delegate = NULL;
24 void TestViewsDelegate::OnBeforeWidgetInit(
25 Widget::InitParams* params,
26 internal::NativeWidgetDelegate* delegate) {
27 if (params->opacity == Widget::InitParams::INFER_OPACITY) {
28 params->opacity = use_transparent_windows_ ?
29 Widget::InitParams::TRANSLUCENT_WINDOW :
30 Widget::InitParams::OPAQUE_WINDOW;
32 // TODO(tapted): This should return a *Desktop*NativeWidgetMac.
33 if (!params->native_widget && use_desktop_native_widgets_)
34 params->native_widget = new NativeWidgetMac(delegate);
37 ui::ContextFactory* TestViewsDelegate::GetContextFactory() {
38 return context_factory_;