Chromium Code Reviews| 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/bridge/wm_window_mus.h" | 5 #include "ash/mus/bridge/wm_window_mus.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_item_types.h" | |
| 7 #include "ash/common/wm/container_finder.h" | 8 #include "ash/common/wm/container_finder.h" |
| 8 #include "ash/common/wm/window_positioning_utils.h" | 9 #include "ash/common/wm/window_positioning_utils.h" |
| 9 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/common/wm_layout_manager.h" | 11 #include "ash/common/wm_layout_manager.h" |
| 11 #include "ash/common/wm_transient_window_observer.h" | 12 #include "ash/common/wm_transient_window_observer.h" |
| 12 #include "ash/common/wm_window_observer.h" | 13 #include "ash/common/wm_window_observer.h" |
| 13 #include "ash/common/wm_window_property.h" | 14 #include "ash/common/wm_window_property.h" |
| 14 #include "ash/mus/bridge/mus_layout_manager_adapter.h" | 15 #include "ash/mus/bridge/mus_layout_manager_adapter.h" |
| 15 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 16 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
| 16 #include "ash/mus/bridge/wm_shell_mus.h" | 17 #include "ash/mus/bridge/wm_shell_mus.h" |
| 17 #include "ash/mus/property_util.h" | 18 #include "ash/mus/property_util.h" |
| 18 #include "services/ui/public/cpp/property_type_converters.h" | 19 #include "services/ui/public/cpp/property_type_converters.h" |
| 19 #include "services/ui/public/cpp/window.h" | 20 #include "services/ui/public/cpp/window.h" |
| 20 #include "services/ui/public/cpp/window_property.h" | 21 #include "services/ui/public/cpp/window_property.h" |
| 21 #include "services/ui/public/cpp/window_tree_client.h" | 22 #include "services/ui/public/cpp/window_tree_client.h" |
| 22 #include "services/ui/public/interfaces/window_manager.mojom.h" | 23 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 23 #include "ui/aura/mus/mus_util.h" | 24 #include "ui/aura/mus/mus_util.h" |
| 24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 25 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
| 26 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 28 #include "ui/resources/grit/ui_resources.h" | |
| 27 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
| 28 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/widget/widget_delegate.h" | 31 #include "ui/views/widget/widget_delegate.h" |
| 30 | 32 |
| 31 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmWindowMus*); | 33 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmWindowMus*); |
| 32 | 34 |
| 33 namespace { | 35 namespace { |
| 34 | 36 |
| 35 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::mus::WmWindowMus, | 37 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::mus::WmWindowMus, |
| 36 kWmWindowKey, | 38 kWmWindowKey, |
| 37 nullptr); | 39 nullptr); |
| 38 | 40 |
| 39 } // namespace | 41 } // namespace |
| 40 | 42 |
| 41 namespace ash { | 43 namespace ash { |
| 42 namespace mus { | 44 namespace mus { |
| 43 | 45 |
| 44 namespace { | 46 namespace { |
| 45 | 47 |
| 46 // This classes is used so that the WindowState constructor can be made | 48 // This class is used so that the WindowState constructor can be made protected. |
| 47 // protected. GetWindowState() is the only place that should be creating | 49 // GetWindowState() is the only place that should be creating WindowState. |
| 48 // WindowState. | |
| 49 class WindowStateMus : public wm::WindowState { | 50 class WindowStateMus : public wm::WindowState { |
| 50 public: | 51 public: |
| 51 explicit WindowStateMus(WmWindow* window) : wm::WindowState(window) {} | 52 explicit WindowStateMus(WmWindow* window) : wm::WindowState(window) {} |
| 52 ~WindowStateMus() override {} | 53 ~WindowStateMus() override {} |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); | 56 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 ui::WindowShowState UIWindowShowStateFromMojom(ui::mojom::ShowState state) { | 59 ui::WindowShowState UIWindowShowStateFromMojom(ui::mojom::ShowState state) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 } | 187 } |
| 187 } | 188 } |
| 188 | 189 |
| 189 std::string WmWindowMus::GetName() const { | 190 std::string WmWindowMus::GetName() const { |
| 190 return window_->HasSharedProperty(ui::mojom::WindowManager::kName_Property) | 191 return window_->HasSharedProperty(ui::mojom::WindowManager::kName_Property) |
| 191 ? window_->GetSharedProperty<std::string>( | 192 ? window_->GetSharedProperty<std::string>( |
| 192 ui::mojom::WindowManager::kName_Property) | 193 ui::mojom::WindowManager::kName_Property) |
| 193 : std::string(); | 194 : std::string(); |
| 194 } | 195 } |
| 195 | 196 |
| 197 void WmWindowMus::SetTitle(const base::string16& title) { | |
| 198 SetWindowTitle(window_, title); | |
| 199 } | |
| 200 | |
| 196 base::string16 WmWindowMus::GetTitle() const { | 201 base::string16 WmWindowMus::GetTitle() const { |
| 197 return GetWindowTitle(window_); | 202 return GetWindowTitle(window_); |
| 198 } | 203 } |
| 199 | 204 |
| 200 void WmWindowMus::SetShellWindowId(int id) { | 205 void WmWindowMus::SetShellWindowId(int id) { |
| 201 shell_window_id_ = id; | 206 shell_window_id_ = id; |
| 202 } | 207 } |
| 203 | 208 |
| 204 int WmWindowMus::GetShellWindowId() const { | 209 int WmWindowMus::GetShellWindowId() const { |
| 205 return shell_window_id_; | 210 return shell_window_id_; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 if (key == WmWindowProperty::TOP_VIEW_COLOR) { | 369 if (key == WmWindowProperty::TOP_VIEW_COLOR) { |
| 365 // TODO: need support for TOP_VIEW_COLOR: http://crbug.com/615100. | 370 // TODO: need support for TOP_VIEW_COLOR: http://crbug.com/615100. |
| 366 NOTIMPLEMENTED(); | 371 NOTIMPLEMENTED(); |
| 367 return; | 372 return; |
| 368 } | 373 } |
| 369 | 374 |
| 370 NOTREACHED(); | 375 NOTREACHED(); |
| 371 } | 376 } |
| 372 | 377 |
| 373 int WmWindowMus::GetIntProperty(WmWindowProperty key) { | 378 int WmWindowMus::GetIntProperty(WmWindowProperty key) { |
| 379 if (key == WmWindowProperty::MODAL_TYPE) { | |
| 380 // TODO: WindowTree::SetModalWindow() needs to route through WindowManager | |
| 381 // so wm can position. http://crbug.com/645996. | |
| 382 NOTIMPLEMENTED(); | |
| 383 return static_cast<int>(ui::MODAL_TYPE_NONE); | |
| 384 } | |
| 385 | |
| 386 if (key == WmWindowProperty::SHELF_ICON_ID) { | |
| 387 if (window_->HasSharedProperty( | |
| 388 ui::mojom::WindowManager::kShelfIconId_Property)) { | |
| 389 return window_->GetSharedProperty<int>( | |
| 390 ui::mojom::WindowManager::kShelfIconId_Property); | |
| 391 } | |
| 392 // Mash provides a default shelf icon image. | |
| 393 // TODO(msw): Support icon resource ids and bitmaps: | |
| 394 // mojo::Array<uint8_t> app_icon = GetWindowAppIcon(window_); | |
| 395 return IDR_DEFAULT_FAVICON; | |
| 396 } | |
| 397 | |
| 374 if (key == WmWindowProperty::SHELF_ID) { | 398 if (key == WmWindowProperty::SHELF_ID) { |
| 375 NOTIMPLEMENTED(); | 399 NOTIMPLEMENTED(); |
| 376 return 0; | 400 return kInvalidShelfID; |
|
James Cook
2016/09/28 20:41:03
Good catch.
msw
2016/09/28 23:27:46
Acknowledged.
| |
| 401 } | |
| 402 | |
| 403 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | |
| 404 if (window_->HasSharedProperty( | |
| 405 ui::mojom::WindowManager::kShelfItemType_Property)) { | |
| 406 return window_->GetSharedProperty<int>( | |
| 407 ui::mojom::WindowManager::kShelfItemType_Property); | |
| 408 } | |
| 409 // Mash provides a default shelf item type for non-ignored windows. | |
| 410 return GetWindowIgnoredByShelf(window_) ? TYPE_UNDEFINED | |
| 411 : TYPE_PLATFORM_APP; | |
| 377 } | 412 } |
| 378 | 413 |
| 379 if (key == WmWindowProperty::TOP_VIEW_INSET) { | 414 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| 380 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. | 415 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. |
| 381 NOTIMPLEMENTED(); | 416 NOTIMPLEMENTED(); |
| 382 return 0; | 417 return 0; |
| 383 } | 418 } |
| 384 | 419 |
| 385 if (key == WmWindowProperty::MODAL_TYPE) { | |
| 386 // TODO: WindowTree::SetModalWindow() needs to route through WindowManager | |
| 387 // so wm can position. http://crbug.com/645996. | |
| 388 NOTIMPLEMENTED(); | |
| 389 return static_cast<int>(ui::MODAL_TYPE_NONE); | |
| 390 } | |
| 391 | |
| 392 NOTREACHED(); | 420 NOTREACHED(); |
| 393 return 0; | 421 return 0; |
| 394 } | 422 } |
| 395 | 423 |
| 396 void WmWindowMus::SetIntProperty(WmWindowProperty key, int value) { | 424 void WmWindowMus::SetIntProperty(WmWindowProperty key, int value) { |
| 425 if (key == WmWindowProperty::SHELF_ICON_ID) { | |
| 426 window_->SetSharedProperty<int>( | |
| 427 ui::mojom::WindowManager::kShelfIconId_Property, value); | |
| 428 return; | |
| 429 } | |
| 430 | |
| 397 if (key == WmWindowProperty::SHELF_ID) { | 431 if (key == WmWindowProperty::SHELF_ID) { |
| 398 NOTIMPLEMENTED(); | 432 NOTIMPLEMENTED(); |
| 399 return; | 433 return; |
| 400 } | 434 } |
| 401 | 435 |
| 436 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | |
| 437 window_->SetSharedProperty<int>( | |
| 438 ui::mojom::WindowManager::kShelfItemType_Property, value); | |
| 439 return; | |
| 440 } | |
| 441 | |
| 402 if (key == WmWindowProperty::TOP_VIEW_INSET) { | 442 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| 403 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. | 443 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. |
| 404 NOTIMPLEMENTED(); | 444 NOTIMPLEMENTED(); |
| 405 return; | 445 return; |
| 406 } | 446 } |
| 407 | 447 |
| 408 NOTREACHED(); | 448 NOTREACHED(); |
| 409 } | 449 } |
| 410 | 450 |
| 411 ShelfItemDetails* WmWindowMus::GetShelfItemDetails() { | |
| 412 NOTIMPLEMENTED(); // TODO: Add support; see crbug.com/634150 | |
| 413 return nullptr; | |
| 414 } | |
| 415 | |
| 416 void WmWindowMus::SetShelfItemDetails(const ShelfItemDetails& details) { | |
| 417 NOTIMPLEMENTED(); // TODO: Add support; see crbug.com/634150 | |
| 418 } | |
| 419 | |
| 420 void WmWindowMus::ClearShelfItemDetails() { | |
| 421 NOTIMPLEMENTED(); // TODO: Add support; see crbug.com/634150 | |
| 422 } | |
| 423 | |
| 424 const wm::WindowState* WmWindowMus::GetWindowState() const { | 451 const wm::WindowState* WmWindowMus::GetWindowState() const { |
| 425 return window_state_.get(); | 452 return window_state_.get(); |
| 426 } | 453 } |
| 427 | 454 |
| 428 WmWindow* WmWindowMus::GetToplevelWindow() { | 455 WmWindow* WmWindowMus::GetToplevelWindow() { |
| 429 return WmShellMus::GetToplevelAncestor(window_); | 456 return WmShellMus::GetToplevelAncestor(window_); |
| 430 } | 457 } |
| 431 | 458 |
| 432 WmWindow* WmWindowMus::GetToplevelWindowForFocus() { | 459 WmWindow* WmWindowMus::GetToplevelWindowForFocus() { |
| 433 // TODO(sky): resolve if we really need two notions of top-level. In the mus | 460 // TODO(sky): resolve if we really need two notions of top-level. In the mus |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 923 } | 950 } |
| 924 | 951 |
| 925 void WmWindowMus::OnTransientChildRemoved(ui::Window* window, | 952 void WmWindowMus::OnTransientChildRemoved(ui::Window* window, |
| 926 ui::Window* transient) { | 953 ui::Window* transient) { |
| 927 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, | 954 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, |
| 928 OnTransientChildRemoved(this, Get(transient))); | 955 OnTransientChildRemoved(this, Get(transient))); |
| 929 } | 956 } |
| 930 | 957 |
| 931 } // namespace mus | 958 } // namespace mus |
| 932 } // namespace ash | 959 } // namespace ash |
| OLD | NEW |