OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/mus/sysui_application.h" | 5 #include "ash/mus/sysui_application.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/host/ash_window_tree_host_init_params.h" | 8 #include "ash/host/ash_window_tree_host_init_params.h" |
9 #include "ash/host/ash_window_tree_host_platform.h" | 9 #include "ash/host/ash_window_tree_host_platform.h" |
10 #include "ash/mus/keyboard_ui_mus.h" | 10 #include "ash/mus/keyboard_ui_mus.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "ui/events/devices/device_data_manager.h" | 38 #include "ui/events/devices/device_data_manager.h" |
39 #endif | 39 #endif |
40 | 40 |
41 using views::ViewsDelegate; | 41 using views::ViewsDelegate; |
42 | 42 |
43 namespace ash { | 43 namespace ash { |
44 namespace sysui { | 44 namespace sysui { |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // Tries to determine the corresponding container in mash from the ash container | 48 // Tries to determine the corresponding mash container from widget init params. |
49 // for the widget. | 49 mash::wm::mojom::Container GetContainerId( |
50 mash::wm::mojom::Container GetContainerId(aura::Window* container) { | 50 const views::Widget::InitParams& params) { |
51 DCHECK(container); | 51 DCHECK(params.parent); |
52 int id = container->id(); | 52 const int id = params.parent->id(); |
53 if (id == kShellWindowId_DesktopBackgroundContainer) | 53 if (id == kShellWindowId_DesktopBackgroundContainer) |
54 return mash::wm::mojom::Container::USER_BACKGROUND; | 54 return mash::wm::mojom::Container::USER_BACKGROUND; |
55 // mash::wm::ShelfLayout manages both the shelf and the status area. | 55 // mash::wm::ShelfLayout manages both the shelf and the status area. |
56 if (id == kShellWindowId_ShelfContainer || | 56 if (id == kShellWindowId_ShelfContainer || |
57 id == kShellWindowId_StatusContainer) { | 57 id == kShellWindowId_StatusContainer) { |
58 return mash::wm::mojom::Container::USER_SHELF; | 58 return mash::wm::mojom::Container::USER_SHELF; |
59 } | 59 } |
| 60 |
| 61 // Show mash shelf tooltips and settings bubbles in the menu container. |
| 62 if (params.type == views::Widget::InitParams::Type::TYPE_MENU || |
| 63 params.type == views::Widget::InitParams::Type::TYPE_BUBBLE) { |
| 64 return mash::wm::mojom::Container::MENUS; |
| 65 } |
| 66 |
| 67 if (params.type == views::Widget::InitParams::Type::TYPE_TOOLTIP) |
| 68 return mash::wm::mojom::Container::TOOLTIPS; |
| 69 |
60 return mash::wm::mojom::Container::COUNT; | 70 return mash::wm::mojom::Container::COUNT; |
61 } | 71 } |
62 | 72 |
63 // Tries to determine the corresponding ash window type from the ash container | 73 // Tries to determine the corresponding ash window type from the ash container |
64 // for the widget. | 74 // for the widget. |
65 mash::wm::mojom::AshWindowType GetAshWindowType(aura::Window* container) { | 75 mash::wm::mojom::AshWindowType GetAshWindowType(aura::Window* container) { |
66 DCHECK(container); | 76 DCHECK(container); |
67 int id = container->id(); | 77 int id = container->id(); |
68 if (id == kShellWindowId_ShelfContainer) | 78 if (id == kShellWindowId_ShelfContainer) |
69 return mash::wm::mojom::AshWindowType::SHELF; | 79 return mash::wm::mojom::AshWindowType::SHELF; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ViewsDelegate::GetInstance()->set_native_widget_factory( | 121 ViewsDelegate::GetInstance()->set_native_widget_factory( |
112 ViewsDelegate::NativeWidgetFactory()); | 122 ViewsDelegate::NativeWidgetFactory()); |
113 } | 123 } |
114 | 124 |
115 private: | 125 private: |
116 views::NativeWidget* InitNativeWidget( | 126 views::NativeWidget* InitNativeWidget( |
117 const views::Widget::InitParams& params, | 127 const views::Widget::InitParams& params, |
118 views::internal::NativeWidgetDelegate* delegate) { | 128 views::internal::NativeWidgetDelegate* delegate) { |
119 std::map<std::string, std::vector<uint8_t>> properties; | 129 std::map<std::string, std::vector<uint8_t>> properties; |
120 if (params.parent) { | 130 if (params.parent) { |
121 mash::wm::mojom::Container container = GetContainerId(params.parent); | 131 mash::wm::mojom::Container container = GetContainerId(params); |
122 if (container != mash::wm::mojom::Container::COUNT) { | 132 if (container != mash::wm::mojom::Container::COUNT) { |
123 properties[mash::wm::mojom::kWindowContainer_Property] = | 133 properties[mash::wm::mojom::kWindowContainer_Property] = |
124 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( | 134 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( |
125 static_cast<int32_t>(container)); | 135 static_cast<int32_t>(container)); |
126 } | 136 } |
127 mash::wm::mojom::AshWindowType type = GetAshWindowType(params.parent); | 137 mash::wm::mojom::AshWindowType type = GetAshWindowType(params.parent); |
128 if (type != mash::wm::mojom::AshWindowType::COUNT) { | 138 if (type != mash::wm::mojom::AshWindowType::COUNT) { |
129 properties[mash::wm::mojom::kAshWindowType_Property] = | 139 properties[mash::wm::mojom::kAshWindowType_Property] = |
130 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( | 140 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( |
131 static_cast<int32_t>(type)); | 141 static_cast<int32_t>(type)); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 ash_init_.reset(new AshInit()); | 293 ash_init_.reset(new AshInit()); |
284 ash_init_->Initialize(connector); | 294 ash_init_->Initialize(connector); |
285 } | 295 } |
286 | 296 |
287 bool SysUIApplication::AcceptConnection(mojo::Connection* connection) { | 297 bool SysUIApplication::AcceptConnection(mojo::Connection* connection) { |
288 return true; | 298 return true; |
289 } | 299 } |
290 | 300 |
291 } // namespace sysui | 301 } // namespace sysui |
292 } // namespace ash | 302 } // namespace ash |
OLD | NEW |