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

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

Issue 2487573002: Service Manager: Remove ServiceContext* arg from Service::OnStart() (Closed)
Patch Set: rebase Created 4 years, 1 month 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/init/init.cc ('k') | mash/quick_launch/quick_launch.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/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 class Login : public service_manager::Service, 137 class Login : public service_manager::Service,
138 public service_manager::InterfaceFactory<mojom::Login>, 138 public service_manager::InterfaceFactory<mojom::Login>,
139 public mojom::Login { 139 public mojom::Login {
140 public: 140 public:
141 Login() {} 141 Login() {}
142 ~Login() override {} 142 ~Login() override {}
143 143
144 void LoginAs(const std::string& user_id) { 144 void LoginAs(const std::string& user_id) {
145 user_access_manager_->SetActiveUser(user_id); 145 user_access_manager_->SetActiveUser(user_id);
146 mash::init::mojom::InitPtr init; 146 mash::init::mojom::InitPtr init;
147 context_->connector()->ConnectToInterface("service:mash_init", &init); 147 context()->connector()->ConnectToInterface("service:mash_init", &init);
148 init->StartService("service:mash_session", user_id); 148 init->StartService("service:mash_session", user_id);
149 } 149 }
150 150
151 private: 151 private:
152 // service_manager::Service: 152 // service_manager::Service:
153 void OnStart(service_manager::ServiceContext* context) override { 153 void OnStart() override {
154 context_ = context; 154 tracing_.Initialize(context()->connector(), context()->identity().name());
155 tracing_.Initialize(context->connector(), context->identity().name());
156 155
157 aura_init_ = base::MakeUnique<views::AuraInit>( 156 aura_init_ = base::MakeUnique<views::AuraInit>(
158 context->connector(), context->identity(), "views_mus_resources.pak"); 157 context()->connector(), context()->identity(),
158 "views_mus_resources.pak");
159 159
160 context->connector()->ConnectToInterface( 160 context()->connector()->ConnectToInterface(
161 "service:ui", &user_access_manager_); 161 "service:ui", &user_access_manager_);
162 user_access_manager_->SetActiveUser(context->identity().user_id()); 162 user_access_manager_->SetActiveUser(context()->identity().user_id());
163 } 163 }
164 164
165 bool OnConnect(const service_manager::ServiceInfo& remote_info, 165 bool OnConnect(const service_manager::ServiceInfo& remote_info,
166 service_manager::InterfaceRegistry* registry) override { 166 service_manager::InterfaceRegistry* registry) override {
167 registry->AddInterface<mojom::Login>(this); 167 registry->AddInterface<mojom::Login>(this);
168 return true; 168 return true;
169 } 169 }
170 170
171 // service_manager::InterfaceFactory<mojom::Login>: 171 // service_manager::InterfaceFactory<mojom::Login>:
172 void Create(const service_manager::Identity& remote_identity, 172 void Create(const service_manager::Identity& remote_identity,
173 mojom::LoginRequest request) override { 173 mojom::LoginRequest request) override {
174 bindings_.AddBinding(this, std::move(request)); 174 bindings_.AddBinding(this, std::move(request));
175 } 175 }
176 176
177 // mojom::Login: 177 // mojom::Login:
178 void ShowLoginUI() override { 178 void ShowLoginUI() override {
179 UI::Show(context_->connector(), context_->identity(), this); 179 UI::Show(context()->connector(), context()->identity(), this);
180 } 180 }
181 void SwitchUser() override { 181 void SwitchUser() override {
182 UI::Show(context_->connector(), context_->identity(), this); 182 UI::Show(context()->connector(), context()->identity(), this);
183 } 183 }
184 184
185 void StartWindowManager(); 185 void StartWindowManager();
186 186
187 service_manager::ServiceContext* context_ = nullptr;
188
189 tracing::Provider tracing_; 187 tracing::Provider tracing_;
190 std::unique_ptr<views::AuraInit> aura_init_; 188 std::unique_ptr<views::AuraInit> aura_init_;
191 mojo::BindingSet<mojom::Login> bindings_; 189 mojo::BindingSet<mojom::Login> bindings_;
192 ui::mojom::UserAccessManagerPtr user_access_manager_; 190 ui::mojom::UserAccessManagerPtr user_access_manager_;
193 191
194 DISALLOW_COPY_AND_ASSIGN(Login); 192 DISALLOW_COPY_AND_ASSIGN(Login);
195 }; 193 };
196 194
197 void UI::ButtonPressed(views::Button* sender, const ui::Event& event) { 195 void UI::ButtonPressed(views::Button* sender, const ui::Event& event) {
198 // Login... 196 // Login...
199 if (sender == login_button_1_) { 197 if (sender == login_button_1_) {
200 login_->LoginAs(user_id_1_); 198 login_->LoginAs(user_id_1_);
201 } else if (sender == login_button_2_) { 199 } else if (sender == login_button_2_) {
202 login_->LoginAs(user_id_2_); 200 login_->LoginAs(user_id_2_);
203 } else { 201 } else {
204 NOTREACHED(); 202 NOTREACHED();
205 } 203 }
206 GetWidget()->Close(); 204 GetWidget()->Close();
207 } 205 }
208 206
209 } // namespace 207 } // namespace
210 208
211 service_manager::Service* CreateLogin() { 209 service_manager::Service* CreateLogin() {
212 return new Login; 210 return new Login;
213 } 211 }
214 212
215 } // namespace login 213 } // namespace login
216 } // namespace main 214 } // namespace main
OLDNEW
« no previous file with comments | « mash/init/init.cc ('k') | mash/quick_launch/quick_launch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698