| 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/login/login.h" | 5 #include "mash/login/login.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/public/interfaces/container.mojom.h" | 10 #include "ash/public/interfaces/container.mojom.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 class Login : public shell::Service, | 135 class Login : public shell::Service, |
| 136 public shell::InterfaceFactory<mojom::Login>, | 136 public shell::InterfaceFactory<mojom::Login>, |
| 137 public mojom::Login { | 137 public mojom::Login { |
| 138 public: | 138 public: |
| 139 Login() {} | 139 Login() {} |
| 140 ~Login() override {} | 140 ~Login() override {} |
| 141 | 141 |
| 142 void LoginAs(const std::string& user_id) { | 142 void LoginAs(const std::string& user_id) { |
| 143 user_access_manager_->SetActiveUser(user_id); | 143 user_access_manager_->SetActiveUser(user_id); |
| 144 mash::init::mojom::InitPtr init; | 144 mash::init::mojom::InitPtr init; |
| 145 connector_->ConnectToInterface("mojo:mash_init", &init); | 145 connector()->ConnectToInterface("mojo:mash_init", &init); |
| 146 init->StartService("mojo:mash_session", user_id); | 146 init->StartService("mojo:mash_session", user_id); |
| 147 } | 147 } |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 // shell::Service: | 150 // shell::Service: |
| 151 void OnStart(shell::Connector* connector, | 151 void OnStart(const shell::Identity& identity) override { |
| 152 const shell::Identity& identity, | |
| 153 uint32_t id) override { | |
| 154 connector_ = connector; | |
| 155 identity_ = identity; | 152 identity_ = identity; |
| 156 tracing_.Initialize(connector, identity.name()); | 153 tracing_.Initialize(connector(), identity.name()); |
| 157 | 154 |
| 158 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); | 155 aura_init_.reset( |
| 156 new views::AuraInit(connector(), "views_mus_resources.pak")); |
| 159 | 157 |
| 160 connector_->ConnectToInterface("mojo:ui", &user_access_manager_); | 158 connector()->ConnectToInterface("mojo:ui", &user_access_manager_); |
| 161 user_access_manager_->SetActiveUser(identity.user_id()); | 159 user_access_manager_->SetActiveUser(identity.user_id()); |
| 162 } | 160 } |
| 163 bool OnConnect(shell::Connection* connection) override { | 161 bool OnConnect(shell::Connection* connection) override { |
| 164 connection->AddInterface<mojom::Login>(this); | 162 connection->AddInterface<mojom::Login>(this); |
| 165 return true; | 163 return true; |
| 166 } | 164 } |
| 167 | 165 |
| 168 // shell::InterfaceFactory<mojom::Login>: | 166 // shell::InterfaceFactory<mojom::Login>: |
| 169 void Create(const shell::Identity& remote_identity, | 167 void Create(const shell::Identity& remote_identity, |
| 170 mojom::LoginRequest request) override { | 168 mojom::LoginRequest request) override { |
| 171 bindings_.AddBinding(this, std::move(request)); | 169 bindings_.AddBinding(this, std::move(request)); |
| 172 } | 170 } |
| 173 | 171 |
| 174 // mojom::Login: | 172 // mojom::Login: |
| 175 void ShowLoginUI() override { UI::Show(connector_, identity_, this); } | 173 void ShowLoginUI() override { |
| 176 void SwitchUser() override { UI::Show(connector_, identity_, this); } | 174 UI::Show(connector(), identity_, this); |
| 175 } |
| 176 void SwitchUser() override { |
| 177 UI::Show(connector(), identity_, this); |
| 178 } |
| 177 | 179 |
| 178 void StartWindowManager(); | 180 void StartWindowManager(); |
| 179 | 181 |
| 180 shell::Connector* connector_; | |
| 181 shell::Identity identity_; | 182 shell::Identity identity_; |
| 182 mojo::TracingImpl tracing_; | 183 mojo::TracingImpl tracing_; |
| 183 std::unique_ptr<views::AuraInit> aura_init_; | 184 std::unique_ptr<views::AuraInit> aura_init_; |
| 184 mojo::BindingSet<mojom::Login> bindings_; | 185 mojo::BindingSet<mojom::Login> bindings_; |
| 185 ui::mojom::UserAccessManagerPtr user_access_manager_; | 186 ui::mojom::UserAccessManagerPtr user_access_manager_; |
| 186 | 187 |
| 187 DISALLOW_COPY_AND_ASSIGN(Login); | 188 DISALLOW_COPY_AND_ASSIGN(Login); |
| 188 }; | 189 }; |
| 189 | 190 |
| 190 void UI::ButtonPressed(views::Button* sender, const ui::Event& event) { | 191 void UI::ButtonPressed(views::Button* sender, const ui::Event& event) { |
| 191 // Login... | 192 // Login... |
| 192 if (sender == login_button_1_) { | 193 if (sender == login_button_1_) { |
| 193 login_->LoginAs(user_id_1_); | 194 login_->LoginAs(user_id_1_); |
| 194 } else if (sender == login_button_2_) { | 195 } else if (sender == login_button_2_) { |
| 195 login_->LoginAs(user_id_2_); | 196 login_->LoginAs(user_id_2_); |
| 196 } else { | 197 } else { |
| 197 NOTREACHED(); | 198 NOTREACHED(); |
| 198 } | 199 } |
| 199 GetWidget()->Close(); | 200 GetWidget()->Close(); |
| 200 } | 201 } |
| 201 | 202 |
| 202 } // namespace | 203 } // namespace |
| 203 | 204 |
| 204 shell::Service* CreateLogin() { | 205 shell::Service* CreateLogin() { |
| 205 return new Login; | 206 return new Login; |
| 206 } | 207 } |
| 207 | 208 |
| 208 } // namespace login | 209 } // namespace login |
| 209 } // namespace main | 210 } // namespace main |
| OLD | NEW |