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

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

Issue 2026623002: views/mus: Have explicit ownership of views::WindowManagerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 4 years, 6 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 "ash/public/interfaces/container.mojom.h" 10 #include "ash/public/interfaces/container.mojom.h"
(...skipping 22 matching lines...) Expand all
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, 39 static void Show(shell::Connector* connector,
40 const shell::Identity& identity, 40 const shell::Identity& identity,
41 Login* login) { 41 Login* login) {
42 UI* ui = new UI(login, connector); 42 UI* ui = new UI(login, connector);
43 ui->StartWindowManager(); 43 ui->StartWindowManager(identity);
44
45 views::WindowManagerConnection::Create(connector, identity);
46 44
47 views::Widget* widget = new views::Widget; 45 views::Widget* widget = new views::Widget;
48 views::Widget::InitParams params( 46 views::Widget::InitParams params(
49 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 47 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
50 params.delegate = ui; 48 params.delegate = ui;
51 49
52 std::map<std::string, std::vector<uint8_t>> properties; 50 std::map<std::string, std::vector<uint8_t>> properties;
53 properties[ash::mojom::kWindowContainer_Property] = 51 properties[ash::mojom::kWindowContainer_Property] =
54 mojo::ConvertTo<std::vector<uint8_t>>( 52 mojo::ConvertTo<std::vector<uint8_t>>(
55 static_cast<int32_t>(ash::mojom::Container::LOGIN_WINDOWS)); 53 static_cast<int32_t>(ash::mojom::Container::LOGIN_WINDOWS));
(...skipping 16 matching lines...) Expand all
72 login_button_2_( 70 login_button_2_(
73 new views::LabelButton(this, base::ASCIIToUTF16("Jimothy"))) { 71 new views::LabelButton(this, base::ASCIIToUTF16("Jimothy"))) {
74 set_background(views::Background::CreateSolidBackground(SK_ColorRED)); 72 set_background(views::Background::CreateSolidBackground(SK_ColorRED));
75 login_button_1_->SetStyle(views::Button::STYLE_BUTTON); 73 login_button_1_->SetStyle(views::Button::STYLE_BUTTON);
76 login_button_2_->SetStyle(views::Button::STYLE_BUTTON); 74 login_button_2_->SetStyle(views::Button::STYLE_BUTTON);
77 AddChildView(login_button_1_); 75 AddChildView(login_button_1_);
78 AddChildView(login_button_2_); 76 AddChildView(login_button_2_);
79 } 77 }
80 ~UI() override { 78 ~UI() override {
81 // Prevent the window manager from restarting during graceful shutdown. 79 // Prevent the window manager from restarting during graceful shutdown.
82 window_manager_connection_->SetConnectionLostClosure(base::Closure()); 80 mash_wm_connection_->SetConnectionLostClosure(base::Closure());
83 base::MessageLoop::current()->QuitWhenIdle(); 81 base::MessageLoop::current()->QuitWhenIdle();
84 } 82 }
85 83
86 // Overridden from views::WidgetDelegate: 84 // Overridden from views::WidgetDelegate:
87 views::View* GetContentsView() override { return this; } 85 views::View* GetContentsView() override { return this; }
88 base::string16 GetWindowTitle() const override { 86 base::string16 GetWindowTitle() const override {
89 // TODO(beng): use resources. 87 // TODO(beng): use resources.
90 return base::ASCIIToUTF16("Login"); 88 return base::ASCIIToUTF16("Login");
91 } 89 }
92 void DeleteDelegate() override { delete this; } 90 void DeleteDelegate() override { delete this; }
(...skipping 14 matching lines...) Expand all
107 105
108 login_button_1_->SetBounds(button_box.x(), button_box.y(), ps1.width(), 106 login_button_1_->SetBounds(button_box.x(), button_box.y(), ps1.width(),
109 ps1.height()); 107 ps1.height());
110 login_button_2_->SetBounds(login_button_1_->bounds().right() + 10, 108 login_button_2_->SetBounds(login_button_1_->bounds().right() + 10,
111 button_box.y(), ps2.width(), ps2.height()); 109 button_box.y(), ps2.width(), ps2.height());
112 } 110 }
113 111
114 // Overridden from views::ButtonListener: 112 // Overridden from views::ButtonListener:
115 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 113 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
116 114
117 void StartWindowManager() { 115 void StartWindowManager(const shell::Identity& identity) {
118 window_manager_connection_ = connector_->Connect("mojo:ash"); 116 mash_wm_connection_ = connector_->Connect("mojo:ash");
119 window_manager_connection_->SetConnectionLostClosure( 117 mash_wm_connection_->SetConnectionLostClosure(
120 base::Bind(&UI::StartWindowManager, base::Unretained(this))); 118 base::Bind(&UI::StartWindowManager, base::Unretained(this), identity));
119 window_manager_connection_ =
120 views::WindowManagerConnection::Create(connector_, identity);
121 } 121 }
122 122
123 Login* login_; 123 Login* login_;
124 shell::Connector* connector_; 124 shell::Connector* connector_;
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> window_manager_connection_; 129 std::unique_ptr<shell::Connection> mash_wm_connection_;
130 std::unique_ptr<views::WindowManagerConnection> window_manager_connection_;
130 131
131 DISALLOW_COPY_AND_ASSIGN(UI); 132 DISALLOW_COPY_AND_ASSIGN(UI);
132 }; 133 };
133 134
134 class Login : public shell::ShellClient, 135 class Login : public shell::ShellClient,
135 public shell::InterfaceFactory<mojom::Login>, 136 public shell::InterfaceFactory<mojom::Login>,
136 public mojom::Login { 137 public mojom::Login {
137 public: 138 public:
138 Login() {} 139 Login() {}
139 ~Login() override {} 140 ~Login() override {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void SwitchUser() override { UI::Show(connector_, identity_, this); } 176 void SwitchUser() override { UI::Show(connector_, identity_, this); }
176 177
177 void StartWindowManager(); 178 void StartWindowManager();
178 179
179 shell::Connector* connector_; 180 shell::Connector* connector_;
180 shell::Identity identity_; 181 shell::Identity identity_;
181 mojo::TracingImpl tracing_; 182 mojo::TracingImpl tracing_;
182 std::unique_ptr<views::AuraInit> aura_init_; 183 std::unique_ptr<views::AuraInit> aura_init_;
183 mojo::BindingSet<mojom::Login> bindings_; 184 mojo::BindingSet<mojom::Login> bindings_;
184 mus::mojom::UserAccessManagerPtr user_access_manager_; 185 mus::mojom::UserAccessManagerPtr user_access_manager_;
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.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698