Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1556)

Side by Side Diff: mash/login/login.cc

Issue 2118083002: ShellClient -> Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mus2
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mash/login/login.h ('k') | mash/quick_launch/quick_launch_application.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "mash/init/public/interfaces/init.mojom.h" 15 #include "mash/init/public/interfaces/init.mojom.h"
16 #include "mash/login/public/interfaces/login.mojom.h" 16 #include "mash/login/public/interfaces/login.mojom.h"
17 #include "mojo/public/cpp/bindings/binding_set.h" 17 #include "mojo/public/cpp/bindings/binding_set.h"
18 #include "services/shell/public/cpp/connector.h" 18 #include "services/shell/public/cpp/connector.h"
19 #include "services/shell/public/cpp/shell_client.h" 19 #include "services/shell/public/cpp/service.h"
20 #include "services/tracing/public/cpp/tracing_impl.h" 20 #include "services/tracing/public/cpp/tracing_impl.h"
21 #include "services/ui/public/cpp/property_type_converters.h" 21 #include "services/ui/public/cpp/property_type_converters.h"
22 #include "services/ui/public/interfaces/user_access_manager.mojom.h" 22 #include "services/ui/public/interfaces/user_access_manager.mojom.h"
23 #include "ui/views/background.h" 23 #include "ui/views/background.h"
24 #include "ui/views/controls/button/label_button.h" 24 #include "ui/views/controls/button/label_button.h"
25 #include "ui/views/mus/aura_init.h" 25 #include "ui/views/mus/aura_init.h"
26 #include "ui/views/mus/native_widget_mus.h" 26 #include "ui/views/mus/native_widget_mus.h"
27 #include "ui/views/mus/window_manager_connection.h" 27 #include "ui/views/mus/window_manager_connection.h"
28 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
29 29
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const std::string user_id_1_; 125 const std::string user_id_1_;
126 const std::string user_id_2_; 126 const std::string user_id_2_;
127 views::LabelButton* login_button_1_; 127 views::LabelButton* login_button_1_;
128 views::LabelButton* login_button_2_; 128 views::LabelButton* login_button_2_;
129 std::unique_ptr<shell::Connection> mash_wm_connection_; 129 std::unique_ptr<shell::Connection> mash_wm_connection_;
130 std::unique_ptr<views::WindowManagerConnection> window_manager_connection_; 130 std::unique_ptr<views::WindowManagerConnection> window_manager_connection_;
131 131
132 DISALLOW_COPY_AND_ASSIGN(UI); 132 DISALLOW_COPY_AND_ASSIGN(UI);
133 }; 133 };
134 134
135 class Login : public shell::ShellClient, 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::ShellClient: 150 // shell::Service:
151 void Initialize(shell::Connector* connector, 151 void OnStart(shell::Connector* connector,
152 const shell::Identity& identity, 152 const shell::Identity& identity,
153 uint32_t id) override { 153 uint32_t id) override {
154 connector_ = connector; 154 connector_ = connector;
155 identity_ = identity; 155 identity_ = identity;
156 tracing_.Initialize(connector, identity.name()); 156 tracing_.Initialize(connector, identity.name());
157 157
158 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); 158 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
159 159
160 connector_->ConnectToInterface("mojo:ui", &user_access_manager_); 160 connector_->ConnectToInterface("mojo:ui", &user_access_manager_);
161 user_access_manager_->SetActiveUser(identity.user_id()); 161 user_access_manager_->SetActiveUser(identity.user_id());
162 } 162 }
163 bool AcceptConnection(shell::Connection* connection) override { 163 bool OnConnect(shell::Connection* connection) override {
164 connection->AddInterface<mojom::Login>(this); 164 connection->AddInterface<mojom::Login>(this);
165 return true; 165 return true;
166 } 166 }
167 167
168 // shell::InterfaceFactory<mojom::Login>: 168 // shell::InterfaceFactory<mojom::Login>:
169 void Create(shell::Connection* connection, 169 void Create(shell::Connection* connection,
170 mojom::LoginRequest request) override { 170 mojom::LoginRequest request) override {
171 bindings_.AddBinding(this, std::move(request)); 171 bindings_.AddBinding(this, std::move(request));
172 } 172 }
173 173
(...skipping 20 matching lines...) Expand all
194 } else if (sender == login_button_2_) { 194 } else if (sender == login_button_2_) {
195 login_->LoginAs(user_id_2_); 195 login_->LoginAs(user_id_2_);
196 } else { 196 } else {
197 NOTREACHED(); 197 NOTREACHED();
198 } 198 }
199 GetWidget()->Close(); 199 GetWidget()->Close();
200 } 200 }
201 201
202 } // namespace 202 } // namespace
203 203
204 shell::ShellClient* CreateLogin() { 204 shell::Service* CreateLogin() {
205 return new Login; 205 return new Login;
206 } 206 }
207 207
208 } // namespace login 208 } // namespace login
209 } // namespace main 209 } // namespace main
OLDNEW
« no previous file with comments | « mash/login/login.h ('k') | mash/quick_launch/quick_launch_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698