| 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/touch_hud/mus/touch_hud_application.h" | 5 #include "ash/touch_hud/mus/touch_hud_application.h" |
| 6 | 6 |
| 7 #include "ash/public/interfaces/container.mojom.h" | 7 #include "ash/public/interfaces/container.mojom.h" |
| 8 #include "ash/touch_hud/touch_hud_renderer.h" | 8 #include "ash/touch_hud/touch_hud_renderer.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 views::WindowManagerConnection* window_manager_connection_; | 54 views::WindowManagerConnection* window_manager_connection_; |
| 55 TouchHudRenderer* touch_hud_renderer_; | 55 TouchHudRenderer* touch_hud_renderer_; |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(TouchHudUI); | 57 DISALLOW_COPY_AND_ASSIGN(TouchHudUI); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 TouchHudApplication::TouchHudApplication() : binding_(this) {} | 60 TouchHudApplication::TouchHudApplication() : binding_(this) {} |
| 61 TouchHudApplication::~TouchHudApplication() {} | 61 TouchHudApplication::~TouchHudApplication() {} |
| 62 | 62 |
| 63 void TouchHudApplication::OnStart(shell::Connector* connector, | 63 void TouchHudApplication::OnStart(const shell::Identity& identity) { |
| 64 const shell::Identity& identity, | 64 aura_init_.reset(new views::AuraInit(connector(), "views_mus_resources.pak")); |
| 65 uint32_t id) { | |
| 66 connector_ = connector; | |
| 67 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); | |
| 68 window_manager_connection_ = | 65 window_manager_connection_ = |
| 69 views::WindowManagerConnection::Create(connector, identity); | 66 views::WindowManagerConnection::Create(connector(), identity); |
| 70 } | 67 } |
| 71 | 68 |
| 72 bool TouchHudApplication::OnConnect(shell::Connection* connection) { | 69 bool TouchHudApplication::OnConnect(shell::Connection* connection) { |
| 73 connection->AddInterface<mash::mojom::Launchable>(this); | 70 connection->AddInterface<mash::mojom::Launchable>(this); |
| 74 return true; | 71 return true; |
| 75 } | 72 } |
| 76 | 73 |
| 77 void TouchHudApplication::Launch(uint32_t what, mash::mojom::LaunchMode how) { | 74 void TouchHudApplication::Launch(uint32_t what, mash::mojom::LaunchMode how) { |
| 78 if (!widget_) { | 75 if (!widget_) { |
| 79 widget_ = new views::Widget; | 76 widget_ = new views::Widget; |
| 80 views::Widget::InitParams params( | 77 views::Widget::InitParams params( |
| 81 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 78 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 82 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 79 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 83 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | 80 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| 84 params.accept_events = false; | 81 params.accept_events = false; |
| 85 params.delegate = new TouchHudUI(window_manager_connection_.get(), widget_); | 82 params.delegate = new TouchHudUI(window_manager_connection_.get(), widget_); |
| 86 | 83 |
| 87 std::map<std::string, std::vector<uint8_t>> properties; | 84 std::map<std::string, std::vector<uint8_t>> properties; |
| 88 properties[ash::mojom::kWindowContainer_Property] = | 85 properties[ash::mojom::kWindowContainer_Property] = |
| 89 mojo::ConvertTo<std::vector<uint8_t>>( | 86 mojo::ConvertTo<std::vector<uint8_t>>( |
| 90 static_cast<int32_t>(ash::mojom::Container::OVERLAY)); | 87 static_cast<int32_t>(ash::mojom::Container::OVERLAY)); |
| 91 properties[ui::mojom::WindowManager::kShowState_Property] = | 88 properties[ui::mojom::WindowManager::kShowState_Property] = |
| 92 mojo::ConvertTo<std::vector<uint8_t>>( | 89 mojo::ConvertTo<std::vector<uint8_t>>( |
| 93 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); | 90 static_cast<int32_t>(ui::mojom::ShowState::FULLSCREEN)); |
| 94 ui::Window* window = | 91 ui::Window* window = |
| 95 window_manager_connection_.get()->NewWindow(properties); | 92 window_manager_connection_.get()->NewWindow(properties); |
| 96 params.native_widget = new views::NativeWidgetMus( | 93 params.native_widget = new views::NativeWidgetMus( |
| 97 widget_, connector_, window, ui::mojom::SurfaceType::DEFAULT); | 94 widget_, connector(), window, ui::mojom::SurfaceType::DEFAULT); |
| 98 widget_->Init(params); | 95 widget_->Init(params); |
| 99 widget_->Show(); | 96 widget_->Show(); |
| 100 } else { | 97 } else { |
| 101 widget_->Close(); | 98 widget_->Close(); |
| 102 base::MessageLoop::current()->QuitWhenIdle(); | 99 base::MessageLoop::current()->QuitWhenIdle(); |
| 103 } | 100 } |
| 104 } | 101 } |
| 105 | 102 |
| 106 void TouchHudApplication::Create(const shell::Identity& remote_identity, | 103 void TouchHudApplication::Create(const shell::Identity& remote_identity, |
| 107 mash::mojom::LaunchableRequest request) { | 104 mash::mojom::LaunchableRequest request) { |
| 108 binding_.Bind(std::move(request)); | 105 binding_.Bind(std::move(request)); |
| 109 } | 106 } |
| 110 | 107 |
| 111 } // namespace touch_hud | 108 } // namespace touch_hud |
| 112 } // namespace ash | 109 } // namespace ash |
| OLD | NEW |