forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
native_widget_factory_aura_mus.cc
66 lines (58 loc) · 2.4 KB
/
native_widget_factory_aura_mus.cc
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
59
60
61
62
63
64
65
66
// Copyright 2016 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/native_widget_factory.h"
#include "ui/aura/mus/window_tree_host_mus_init_params.h"
#include "ui/views/mus/desktop_window_tree_host_mus.h"
#include "ui/views/mus/mus_client.h"
#include "ui/views/test/test_platform_native_widget.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/native_widget_aura.h"
namespace views {
namespace test {
namespace {
NativeWidget* CreatePlatformNativeWidgetImplAuraMus(
bool create_desktop_native_widget_aura,
const Widget::InitParams& init_params,
Widget* widget,
int32_t type,
bool* destroyed) {
if (!create_desktop_native_widget_aura) {
return new TestPlatformNativeWidget<NativeWidgetAura>(
widget, type == kStubCapture, destroyed);
}
DesktopNativeWidgetAura* desktop_native_widget_aura =
new TestPlatformNativeWidget<DesktopNativeWidgetAura>(
widget, type == kStubCapture, destroyed);
std::map<std::string, std::vector<uint8_t>> mus_properties =
MusClient::Get()->ConfigurePropertiesFromParams(init_params);
aura::WindowTreeHostMusInitParams window_tree_host_init_params =
aura::CreateInitParamsForTopLevel(MusClient::Get()->window_tree_client(),
std::move(mus_properties));
desktop_native_widget_aura->SetDesktopWindowTreeHost(
std::make_unique<DesktopWindowTreeHostMus>(
std::move(window_tree_host_init_params), widget,
desktop_native_widget_aura));
return desktop_native_widget_aura;
}
} // namespace
NativeWidget* CreatePlatformNativeWidgetImpl(
const Widget::InitParams& init_params,
Widget* widget,
uint32_t type,
bool* destroyed) {
// Only create a NativeWidgetAura if necessary, otherwise use
// DesktopNativeWidgetAura.
return CreatePlatformNativeWidgetImplAuraMus(
MusClient::ShouldCreateDesktopNativeWidgetAura(init_params), init_params,
widget, type, destroyed);
}
NativeWidget* CreatePlatformDesktopNativeWidgetImpl(
const Widget::InitParams& init_params,
Widget* widget,
bool* destroyed) {
return CreatePlatformNativeWidgetImplAuraMus(true, init_params, widget,
kDefault, destroyed);
}
} // namespace test
} // namespace views