| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shell/shell_application_delegate.h" | 5 #include "mash/shell/shell_application_delegate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mash/login/public/interfaces/login.mojom.h" |
| 9 #include "mojo/shell/public/cpp/connection.h" | 11 #include "mojo/shell/public/cpp/connection.h" |
| 10 #include "mojo/shell/public/cpp/connector.h" | 12 #include "mojo/shell/public/cpp/connector.h" |
| 11 | 13 |
| 12 namespace mash { | 14 namespace mash { |
| 13 namespace shell { | 15 namespace shell { |
| 14 | 16 |
| 15 ShellApplicationDelegate::ShellApplicationDelegate() | 17 ShellApplicationDelegate::ShellApplicationDelegate() |
| 16 : connector_(nullptr), screen_locked_(false) {} | 18 : connector_(nullptr), screen_locked_(false) {} |
| 17 | 19 |
| 18 ShellApplicationDelegate::~ShellApplicationDelegate() {} | 20 ShellApplicationDelegate::~ShellApplicationDelegate() {} |
| 19 | 21 |
| 20 void ShellApplicationDelegate::Initialize(mojo::Connector* connector, | 22 void ShellApplicationDelegate::Initialize(mojo::Connector* connector, |
| 21 const mojo::Identity& identity, | 23 const mojo::Identity& identity, |
| 22 uint32_t id) { | 24 uint32_t id) { |
| 23 connector_ = connector; | 25 connector_ = connector; |
| 24 StartBrowserDriver(); | 26 StartBrowserDriver(); |
| 25 StartWindowManager(); | 27 StartWindowManager(); |
| 26 StartSystemUI(); | 28 StartSystemUI(); |
| 27 StartQuickLaunch(); | 29 StartQuickLaunch(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 bool ShellApplicationDelegate::AcceptConnection(mojo::Connection* connection) { | 32 bool ShellApplicationDelegate::AcceptConnection(mojo::Connection* connection) { |
| 31 connection->AddInterface<mojom::Shell>(this); | 33 connection->AddInterface<mojom::Shell>(this); |
| 32 return true; | 34 return true; |
| 33 } | 35 } |
| 34 | 36 |
| 37 void ShellApplicationDelegate::Logout() { |
| 38 // TODO(beng): Notify connected listeners that login is happening, potentially |
| 39 // give them the option to stop it. |
| 40 mash::login::mojom::LoginPtr login; |
| 41 connector_->ConnectToInterface("mojo:login", &login); |
| 42 login->ShowLoginUI(); |
| 43 // This kills the user environment. |
| 44 base::MessageLoop::current()->QuitWhenIdle(); |
| 45 } |
| 46 |
| 47 void ShellApplicationDelegate::SwitchUser() { |
| 48 mash::login::mojom::LoginPtr login; |
| 49 connector_->ConnectToInterface("mojo:login", &login); |
| 50 login->SwitchUser(); |
| 51 } |
| 52 |
| 35 void ShellApplicationDelegate::AddScreenlockStateListener( | 53 void ShellApplicationDelegate::AddScreenlockStateListener( |
| 36 mojom::ScreenlockStateListenerPtr listener) { | 54 mojom::ScreenlockStateListenerPtr listener) { |
| 37 listener->ScreenlockStateChanged(screen_locked_); | 55 listener->ScreenlockStateChanged(screen_locked_); |
| 38 screenlock_listeners_.AddInterfacePtr(std::move(listener)); | 56 screenlock_listeners_.AddInterfacePtr(std::move(listener)); |
| 39 } | 57 } |
| 40 | 58 |
| 41 void ShellApplicationDelegate::LockScreen() { | 59 void ShellApplicationDelegate::LockScreen() { |
| 42 if (screen_locked_) | 60 if (screen_locked_) |
| 43 return; | 61 return; |
| 44 screen_locked_ = true; | 62 screen_locked_ = true; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Note: |connection| may be null if we've lost our connection to the shell. | 132 // Note: |connection| may be null if we've lost our connection to the shell. |
| 115 if (connection) { | 133 if (connection) { |
| 116 connection->SetConnectionLostClosure(restart_callback); | 134 connection->SetConnectionLostClosure(restart_callback); |
| 117 connection->AddInterface<mojom::Shell>(this); | 135 connection->AddInterface<mojom::Shell>(this); |
| 118 connections_[url] = std::move(connection); | 136 connections_[url] = std::move(connection); |
| 119 } | 137 } |
| 120 } | 138 } |
| 121 | 139 |
| 122 } // namespace shell | 140 } // namespace shell |
| 123 } // namespace main | 141 } // namespace main |
| OLD | NEW |