| 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 "mash/screenlock/screenlock.h" | 5 #include "mash/screenlock/screenlock.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "mash/session/public/interfaces/session.mojom.h" | 11 #include "mash/session/public/interfaces/session.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "services/service_manager/public/cpp/connector.h" | 13 #include "services/service_manager/public/cpp/connector.h" |
| 13 #include "services/ui/public/cpp/property_type_converters.h" | 14 #include "services/ui/public/cpp/property_type_converters.h" |
| 14 #include "ui/views/background.h" | 15 #include "ui/views/background.h" |
| 15 #include "ui/views/controls/button/md_text_button.h" | 16 #include "ui/views/controls/button/md_text_button.h" |
| 16 #include "ui/views/mus/aura_init.h" | 17 #include "ui/views/mus/aura_init.h" |
| 17 #include "ui/views/mus/native_widget_mus.h" | 18 #include "ui/views/mus/native_widget_mus.h" |
| 18 #include "ui/views/mus/window_manager_connection.h" | 19 #include "ui/views/mus/window_manager_connection.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 Screenlock::~Screenlock() {} | 75 Screenlock::~Screenlock() {} |
| 75 | 76 |
| 76 void Screenlock::OnStart(const service_manager::ServiceInfo& info) { | 77 void Screenlock::OnStart(const service_manager::ServiceInfo& info) { |
| 77 tracing_.Initialize(connector(), info.identity.name()); | 78 tracing_.Initialize(connector(), info.identity.name()); |
| 78 | 79 |
| 79 mash::session::mojom::SessionPtr session; | 80 mash::session::mojom::SessionPtr session; |
| 80 connector()->ConnectToInterface("service:mash_session", &session); | 81 connector()->ConnectToInterface("service:mash_session", &session); |
| 81 session->AddScreenlockStateListener( | 82 session->AddScreenlockStateListener( |
| 82 bindings_.CreateInterfacePtrAndBind(this)); | 83 bindings_.CreateInterfacePtrAndBind(this)); |
| 83 | 84 |
| 84 aura_init_.reset( | 85 aura_init_ = base::MakeUnique<views::AuraInit>(connector(), info.identity, |
| 85 new views::AuraInit(connector(), "views_mus_resources.pak")); | 86 "views_mus_resources.pak"); |
| 86 window_manager_connection_ = | 87 window_manager_connection_ = |
| 87 views::WindowManagerConnection::Create(connector(), info.identity); | 88 views::WindowManagerConnection::Create(connector(), info.identity); |
| 88 | 89 |
| 89 views::Widget* widget = new views::Widget; | 90 views::Widget* widget = new views::Widget; |
| 90 views::Widget::InitParams params( | 91 views::Widget::InitParams params( |
| 91 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 92 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 92 params.delegate = new ScreenlockView(connector()); | 93 params.delegate = new ScreenlockView(connector()); |
| 93 | 94 |
| 94 std::map<std::string, std::vector<uint8_t>> properties; | 95 std::map<std::string, std::vector<uint8_t>> properties; |
| 95 properties[ui::mojom::WindowManager::kInitialContainerId_Property] = | 96 properties[ui::mojom::WindowManager::kInitialContainerId_Property] = |
| 96 mojo::ConvertTo<std::vector<uint8_t>>( | 97 mojo::ConvertTo<std::vector<uint8_t>>( |
| 97 ash::kShellWindowId_LockScreenContainer); | 98 ash::kShellWindowId_LockScreenContainer); |
| 98 ui::Window* window = | 99 ui::Window* window = |
| 99 views::WindowManagerConnection::Get()->NewTopLevelWindow(properties); | 100 views::WindowManagerConnection::Get()->NewTopLevelWindow(properties); |
| 100 params.native_widget = new views::NativeWidgetMus( | 101 params.native_widget = new views::NativeWidgetMus( |
| 101 widget, window, ui::mojom::CompositorFrameSinkType::DEFAULT); | 102 widget, window, ui::mojom::CompositorFrameSinkType::DEFAULT); |
| 102 widget->Init(params); | 103 widget->Init(params); |
| 103 widget->Show(); | 104 widget->Show(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void Screenlock::ScreenlockStateChanged(bool screen_locked) { | 107 void Screenlock::ScreenlockStateChanged(bool screen_locked) { |
| 107 if (!screen_locked) | 108 if (!screen_locked) |
| 108 base::MessageLoop::current()->QuitWhenIdle(); | 109 base::MessageLoop::current()->QuitWhenIdle(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 } // namespace screenlock | 112 } // namespace screenlock |
| 112 } // namespace mash | 113 } // namespace mash |
| OLD | NEW |