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/sysui/sysui_application.h" | 5 #include "ash/sysui/sysui_application.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 namespace ash { | 53 namespace ash { |
54 namespace sysui { | 54 namespace sysui { |
55 | 55 |
56 namespace { | 56 namespace { |
57 | 57 |
58 const char kResourceFileStrings[] = "ash_resources_strings.pak"; | 58 const char kResourceFileStrings[] = "ash_resources_strings.pak"; |
59 const char kResourceFile100[] = "ash_resources_100_percent.pak"; | 59 const char kResourceFile100[] = "ash_resources_100_percent.pak"; |
60 const char kResourceFile200[] = "ash_resources_200_percent.pak"; | 60 const char kResourceFile200[] = "ash_resources_200_percent.pak"; |
61 | 61 |
62 // Tries to determine the corresponding mash container from widget init params. | 62 // Tries to determine the corresponding mash container from widget init params. |
63 mojom::Container GetContainerId(const views::Widget::InitParams& params) { | 63 bool GetContainerForWidget(const views::Widget::InitParams& params, |
64 const int id = params.parent->id(); | 64 mojom::Container* container) { |
65 if (id == kShellWindowId_DesktopBackgroundContainer) | 65 switch (params.parent->id()) { |
66 return mojom::Container::USER_BACKGROUND; | 66 case kShellWindowId_DesktopBackgroundContainer: |
67 if (id == kShellWindowId_ShelfContainer) | 67 *container = mojom::Container::USER_BACKGROUND; |
68 return mojom::Container::USER_PRIVATE_SHELF; | 68 return true; |
69 if (id == kShellWindowId_StatusContainer) | 69 |
70 return mojom::Container::STATUS; | 70 case kShellWindowId_ShelfContainer: |
| 71 *container = mojom::Container::USER_PRIVATE_SHELF; |
| 72 return true; |
| 73 |
| 74 case kShellWindowId_StatusContainer: |
| 75 *container = mojom::Container::STATUS; |
| 76 return true; |
| 77 } |
71 | 78 |
72 // Determine the container based on Widget type. | 79 // Determine the container based on Widget type. |
73 switch (params.type) { | 80 switch (params.type) { |
74 case views::Widget::InitParams::Type::TYPE_BUBBLE: | 81 case views::Widget::InitParams::Type::TYPE_BUBBLE: |
75 return mojom::Container::BUBBLES; | 82 *container = mojom::Container::BUBBLES; |
| 83 return true; |
| 84 |
76 case views::Widget::InitParams::Type::TYPE_MENU: | 85 case views::Widget::InitParams::Type::TYPE_MENU: |
77 return mojom::Container::MENUS; | 86 *container = mojom::Container::MENUS; |
| 87 return true; |
| 88 |
78 case views::Widget::InitParams::Type::TYPE_TOOLTIP: | 89 case views::Widget::InitParams::Type::TYPE_TOOLTIP: |
79 return mojom::Container::DRAG_AND_TOOLTIPS; | 90 *container = mojom::Container::DRAG_AND_TOOLTIPS; |
| 91 return true; |
| 92 |
80 default: | 93 default: |
81 return mojom::Container::COUNT; | 94 break; |
82 } | 95 } |
| 96 return false; |
83 } | 97 } |
84 | 98 |
85 // Tries to determine the corresponding ash window type from the ash container | 99 // Tries to determine the corresponding ash window type from the ash container |
86 // for the widget. | 100 // for the widget. |
87 mojom::AshWindowType GetAshWindowType(aura::Window* container) { | 101 mojom::AshWindowType GetAshWindowType(aura::Window* container) { |
88 DCHECK(container); | 102 DCHECK(container); |
89 int id = container->id(); | 103 int id = container->id(); |
90 if (id == kShellWindowId_ShelfContainer) | 104 if (id == kShellWindowId_ShelfContainer) |
91 return mojom::AshWindowType::SHELF; | 105 return mojom::AshWindowType::SHELF; |
92 if (id == kShellWindowId_StatusContainer) | 106 if (id == kShellWindowId_StatusContainer) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ViewsDelegate::GetInstance()->set_native_widget_factory( | 147 ViewsDelegate::GetInstance()->set_native_widget_factory( |
134 ViewsDelegate::NativeWidgetFactory()); | 148 ViewsDelegate::NativeWidgetFactory()); |
135 } | 149 } |
136 | 150 |
137 private: | 151 private: |
138 views::NativeWidget* InitNativeWidget( | 152 views::NativeWidget* InitNativeWidget( |
139 const views::Widget::InitParams& params, | 153 const views::Widget::InitParams& params, |
140 views::internal::NativeWidgetDelegate* delegate) { | 154 views::internal::NativeWidgetDelegate* delegate) { |
141 std::map<std::string, std::vector<uint8_t>> properties; | 155 std::map<std::string, std::vector<uint8_t>> properties; |
142 if (params.parent) { | 156 if (params.parent) { |
143 mojom::Container container = GetContainerId(params); | 157 mojom::Container container; |
144 if (container != mojom::Container::COUNT) { | 158 if (GetContainerForWidget(params, &container)) { |
145 properties[mojom::kWindowContainer_Property] = | 159 properties[mojom::kWindowContainer_Property] = |
146 mojo::ConvertTo<std::vector<uint8_t>>( | 160 mojo::ConvertTo<std::vector<uint8_t>>( |
147 static_cast<int32_t>(container)); | 161 static_cast<int32_t>(container)); |
148 } | 162 } |
149 mojom::AshWindowType type = GetAshWindowType(params.parent); | 163 mojom::AshWindowType type = GetAshWindowType(params.parent); |
150 if (type != mojom::AshWindowType::COUNT) { | 164 if (type != mojom::AshWindowType::COUNT) { |
151 properties[mojom::kAshWindowType_Property] = | 165 properties[mojom::kAshWindowType_Property] = |
152 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>(type)); | 166 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>(type)); |
153 } | 167 } |
154 } | 168 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 void SysUIApplication::Create( | 337 void SysUIApplication::Create( |
324 ::shell::Connection* connection, | 338 ::shell::Connection* connection, |
325 mojo::InterfaceRequest<mash::shelf::mojom::ShelfController> request) { | 339 mojo::InterfaceRequest<mash::shelf::mojom::ShelfController> request) { |
326 mash::shelf::mojom::ShelfController* shelf_controller = | 340 mash::shelf::mojom::ShelfController* shelf_controller = |
327 static_cast<ShelfDelegateMus*>(Shell::GetInstance()->GetShelfDelegate()); | 341 static_cast<ShelfDelegateMus*>(Shell::GetInstance()->GetShelfDelegate()); |
328 shelf_controller_bindings_.AddBinding(shelf_controller, std::move(request)); | 342 shelf_controller_bindings_.AddBinding(shelf_controller, std::move(request)); |
329 } | 343 } |
330 | 344 |
331 } // namespace sysui | 345 } // namespace sysui |
332 } // namespace ash | 346 } // namespace ash |
OLD | NEW |