summaryrefslogtreecommitdiffstats
path: root/ui/views/test/test_views_delegate_aura.cc
blob: db32fd18c171677c4d5a9d7b2c3115ced4c4c887 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/test/test_views_delegate.h"

#include "build/build_config.h"
#include "ui/aura/env.h"
#include "ui/wm/core/wm_state.h"

#if !defined(OS_CHROMEOS)
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#endif  // !defined(OS_CHROMEOS)


namespace views {

TestViewsDelegate::TestViewsDelegate()
    : context_factory_(nullptr),
      use_desktop_native_widgets_(false),
      use_transparent_windows_(false) {
#if defined(USE_AURA)
  wm_state_.reset(new wm::WMState);
#endif
}

TestViewsDelegate::~TestViewsDelegate() {
}

#if defined(OS_WIN)
HICON TestViewsDelegate::GetSmallWindowIcon() const {
  return nullptr;
}
#endif

void TestViewsDelegate::OnBeforeWidgetInit(
    Widget::InitParams* params,
    internal::NativeWidgetDelegate* delegate) {
  if (params->opacity == Widget::InitParams::INFER_OPACITY) {
    params->opacity = use_transparent_windows_ ?
        Widget::InitParams::TRANSLUCENT_WINDOW :
        Widget::InitParams::OPAQUE_WINDOW;
  }
#if !defined(OS_CHROMEOS)
  if (!params->native_widget && use_desktop_native_widgets_)
    params->native_widget = new DesktopNativeWidgetAura(delegate);
#endif  // !defined(OS_CHROMEOS)
}

ui::ContextFactory* TestViewsDelegate::GetContextFactory() {
  if (context_factory_)
    return context_factory_;
  if (aura::Env::GetInstance())
    return aura::Env::GetInstance()->context_factory();
  return nullptr;
}

}  // namespace views