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

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

Issue 1899323002: Add mash shelf application id support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address simpler comments. Created 4 years, 8 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
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 "base/guid.h" 10 #include "base/guid.h"
(...skipping 18 matching lines...) Expand all
29 29
30 namespace mash { 30 namespace mash {
31 namespace login { 31 namespace login {
32 namespace { 32 namespace {
33 33
34 class Login; 34 class Login;
35 35
36 class UI : public views::WidgetDelegateView, 36 class UI : public views::WidgetDelegateView,
37 public views::ButtonListener { 37 public views::ButtonListener {
38 public: 38 public:
39 static void Show(shell::Connector* connector, Login* login) { 39 static void Show(shell::Connector* connector,
40 const shell::Identity& identity,
41 Login* login) {
40 UI* ui = new UI(login, connector); 42 UI* ui = new UI(login, connector);
41 ui->StartWindowManager(); 43 ui->StartWindowManager();
42 44
43 views::WindowManagerConnection::Create(connector); 45 views::WindowManagerConnection::Create(connector, identity);
44 46
45 views::Widget* widget = new views::Widget; 47 views::Widget* widget = new views::Widget;
46 views::Widget::InitParams params( 48 views::Widget::InitParams params(
47 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 49 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
48 params.delegate = ui; 50 params.delegate = ui;
49 51
50 std::map<std::string, std::vector<uint8_t>> properties; 52 std::map<std::string, std::vector<uint8_t>> properties;
51 properties[mash::wm::mojom::kWindowContainer_Property] = 53 properties[mash::wm::mojom::kWindowContainer_Property] =
52 mojo::ConvertTo<std::vector<uint8_t>>( 54 mojo::ConvertTo<std::vector<uint8_t>>(
53 static_cast<int32_t>(mash::wm::mojom::Container::LOGIN_WINDOWS)); 55 static_cast<int32_t>(mash::wm::mojom::Container::LOGIN_WINDOWS));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 connector_->ConnectToInterface("mojo:mash_init", &init); 144 connector_->ConnectToInterface("mojo:mash_init", &init);
143 init->StartService("mojo:mash_session", user_id); 145 init->StartService("mojo:mash_session", user_id);
144 } 146 }
145 147
146 private: 148 private:
147 // shell::ShellClient: 149 // shell::ShellClient:
148 void Initialize(shell::Connector* connector, 150 void Initialize(shell::Connector* connector,
149 const shell::Identity& identity, 151 const shell::Identity& identity,
150 uint32_t id) override { 152 uint32_t id) override {
151 connector_ = connector; 153 connector_ = connector;
154 identity_ = identity;
152 tracing_.Initialize(connector, identity.name()); 155 tracing_.Initialize(connector, identity.name());
153 156
154 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); 157 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
155 158
156 connector_->ConnectToInterface("mojo:mus", &user_access_manager_); 159 connector_->ConnectToInterface("mojo:mus", &user_access_manager_);
157 user_access_manager_->SetActiveUser(identity.user_id()); 160 user_access_manager_->SetActiveUser(identity.user_id());
158 } 161 }
159 bool AcceptConnection(shell::Connection* connection) override { 162 bool AcceptConnection(shell::Connection* connection) override {
160 connection->AddInterface<mojom::Login>(this); 163 connection->AddInterface<mojom::Login>(this);
161 return true; 164 return true;
162 } 165 }
163 166
164 // shell::InterfaceFactory<mojom::Login>: 167 // shell::InterfaceFactory<mojom::Login>:
165 void Create(shell::Connection* connection, 168 void Create(shell::Connection* connection,
166 mojom::LoginRequest request) override { 169 mojom::LoginRequest request) override {
167 bindings_.AddBinding(this, std::move(request)); 170 bindings_.AddBinding(this, std::move(request));
168 } 171 }
169 172
170 // mojom::Login: 173 // mojom::Login:
171 void ShowLoginUI() override { 174 void ShowLoginUI() override { UI::Show(connector_, identity_, this); }
172 UI::Show(connector_, this); 175 void SwitchUser() override { UI::Show(connector_, identity_, this); }
173 }
174 void SwitchUser() override {
175 UI::Show(connector_, this);
176 }
177 176
178 void StartWindowManager(); 177 void StartWindowManager();
179 178
180 shell::Connector* connector_; 179 shell::Connector* connector_;
180 shell::Identity identity_;
181 mojo::TracingImpl tracing_; 181 mojo::TracingImpl tracing_;
182 std::unique_ptr<views::AuraInit> aura_init_; 182 std::unique_ptr<views::AuraInit> aura_init_;
183 mojo::BindingSet<mojom::Login> bindings_; 183 mojo::BindingSet<mojom::Login> bindings_;
184 mus::mojom::UserAccessManagerPtr user_access_manager_; 184 mus::mojom::UserAccessManagerPtr user_access_manager_;
185 std::unique_ptr<shell::Connection> window_manager_connection_; 185 std::unique_ptr<shell::Connection> window_manager_connection_;
186 186
187 DISALLOW_COPY_AND_ASSIGN(Login); 187 DISALLOW_COPY_AND_ASSIGN(Login);
188 }; 188 };
189 189
190 void UI::ButtonPressed(views::Button* sender, const ui::Event& event) { 190 void UI::ButtonPressed(views::Button* sender, const ui::Event& event) {
191 // Login... 191 // Login...
192 if (sender == login_button_1_) { 192 if (sender == login_button_1_) {
193 login_->LoginAs(user_id_1_); 193 login_->LoginAs(user_id_1_);
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::ShellClient* 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/example/window_type_launcher/window_type_launcher.cc ('k') | mash/quick_launch/quick_launch_application.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698