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

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

Issue 1817443002: Rename mash_shell to mash_session. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/session/session.h ('k') | mash/shell/BUILD.gn » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/shell/shell_application_delegate.h" 5 #include "mash/session/session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mash/login/public/interfaces/login.mojom.h" 10 #include "mash/login/public/interfaces/login.mojom.h"
11 #include "mojo/shell/public/cpp/connection.h" 11 #include "mojo/shell/public/cpp/connection.h"
12 #include "mojo/shell/public/cpp/connector.h" 12 #include "mojo/shell/public/cpp/connector.h"
13 13
14 namespace mash { 14 namespace mash {
15 namespace shell { 15 namespace session {
16 16
17 ShellApplicationDelegate::ShellApplicationDelegate() 17 Session::Session() : connector_(nullptr), screen_locked_(false) {}
18 : connector_(nullptr), screen_locked_(false) {} 18 Session::~Session() {}
19 19
20 ShellApplicationDelegate::~ShellApplicationDelegate() {} 20 void Session::Initialize(mojo::Connector* connector,
21 21 const mojo::Identity& identity,
22 void ShellApplicationDelegate::Initialize(mojo::Connector* connector, 22 uint32_t id) {
23 const mojo::Identity& identity,
24 uint32_t id) {
25 connector_ = connector; 23 connector_ = connector;
26 StartBrowserDriver(); 24 StartBrowserDriver();
27 StartWindowManager(); 25 StartWindowManager();
28 StartSystemUI(); 26 StartSystemUI();
29 StartQuickLaunch(); 27 StartQuickLaunch();
30 } 28 }
31 29
32 bool ShellApplicationDelegate::AcceptConnection(mojo::Connection* connection) { 30 bool Session::AcceptConnection(mojo::Connection* connection) {
33 connection->AddInterface<mojom::Shell>(this); 31 connection->AddInterface<mojom::Session>(this);
34 return true; 32 return true;
35 } 33 }
36 34
37 void ShellApplicationDelegate::Logout() { 35 void Session::Logout() {
38 // TODO(beng): Notify connected listeners that login is happening, potentially 36 // TODO(beng): Notify connected listeners that login is happening, potentially
39 // give them the option to stop it. 37 // give them the option to stop it.
40 mash::login::mojom::LoginPtr login; 38 mash::login::mojom::LoginPtr login;
41 connector_->ConnectToInterface("mojo:login", &login); 39 connector_->ConnectToInterface("mojo:login", &login);
42 login->ShowLoginUI(); 40 login->ShowLoginUI();
43 // This kills the user environment. 41 // This kills the user environment.
44 base::MessageLoop::current()->QuitWhenIdle(); 42 base::MessageLoop::current()->QuitWhenIdle();
45 } 43 }
46 44
47 void ShellApplicationDelegate::SwitchUser() { 45 void Session::SwitchUser() {
48 mash::login::mojom::LoginPtr login; 46 mash::login::mojom::LoginPtr login;
49 connector_->ConnectToInterface("mojo:login", &login); 47 connector_->ConnectToInterface("mojo:login", &login);
50 login->SwitchUser(); 48 login->SwitchUser();
51 } 49 }
52 50
53 void ShellApplicationDelegate::AddScreenlockStateListener( 51 void Session::AddScreenlockStateListener(
54 mojom::ScreenlockStateListenerPtr listener) { 52 mojom::ScreenlockStateListenerPtr listener) {
55 listener->ScreenlockStateChanged(screen_locked_); 53 listener->ScreenlockStateChanged(screen_locked_);
56 screenlock_listeners_.AddInterfacePtr(std::move(listener)); 54 screenlock_listeners_.AddInterfacePtr(std::move(listener));
57 } 55 }
58 56
59 void ShellApplicationDelegate::LockScreen() { 57 void Session::LockScreen() {
60 if (screen_locked_) 58 if (screen_locked_)
61 return; 59 return;
62 screen_locked_ = true; 60 screen_locked_ = true;
63 screenlock_listeners_.ForAllPtrs( 61 screenlock_listeners_.ForAllPtrs(
64 [](mojom::ScreenlockStateListener* listener) { 62 [](mojom::ScreenlockStateListener* listener) {
65 listener->ScreenlockStateChanged(true); 63 listener->ScreenlockStateChanged(true);
66 }); 64 });
67 StartScreenlock(); 65 StartScreenlock();
68 } 66 }
69 void ShellApplicationDelegate::UnlockScreen() { 67 void Session::UnlockScreen() {
70 if (!screen_locked_) 68 if (!screen_locked_)
71 return; 69 return;
72 screen_locked_ = false; 70 screen_locked_ = false;
73 screenlock_listeners_.ForAllPtrs( 71 screenlock_listeners_.ForAllPtrs(
74 [](mojom::ScreenlockStateListener* listener) { 72 [](mojom::ScreenlockStateListener* listener) {
75 listener->ScreenlockStateChanged(false); 73 listener->ScreenlockStateChanged(false);
76 }); 74 });
77 StopScreenlock(); 75 StopScreenlock();
78 } 76 }
79 77
80 void ShellApplicationDelegate::Create( 78 void Session::Create(mojo::Connection* connection,
81 mojo::Connection* connection, 79 mojom::SessionRequest request) {
82 mojom::ShellRequest request) {
83 bindings_.AddBinding(this, std::move(request)); 80 bindings_.AddBinding(this, std::move(request));
84 } 81 }
85 82
86 void ShellApplicationDelegate::StartWindowManager() { 83 void Session::StartWindowManager() {
87 StartRestartableService( 84 StartRestartableService(
88 "mojo:desktop_wm", 85 "mojo:desktop_wm",
89 base::Bind(&ShellApplicationDelegate::StartWindowManager, 86 base::Bind(&Session::StartWindowManager,
90 base::Unretained(this))); 87 base::Unretained(this)));
91 } 88 }
92 89
93 void ShellApplicationDelegate::StartSystemUI() { 90 void Session::StartSystemUI() {
94 StartRestartableService("mojo:ash_sysui", 91 StartRestartableService("mojo:ash_sysui",
95 base::Bind(&ShellApplicationDelegate::StartSystemUI, 92 base::Bind(&Session::StartSystemUI,
96 base::Unretained(this))); 93 base::Unretained(this)));
97 } 94 }
98 95
99 void ShellApplicationDelegate::StartBrowserDriver() { 96 void Session::StartBrowserDriver() {
100 StartRestartableService( 97 StartRestartableService(
101 "mojo:browser_driver", 98 "mojo:browser_driver",
102 base::Bind(&ShellApplicationDelegate::StartBrowserDriver, 99 base::Bind(&Session::StartBrowserDriver,
103 base::Unretained(this))); 100 base::Unretained(this)));
104 } 101 }
105 102
106 void ShellApplicationDelegate::StartQuickLaunch() { 103 void Session::StartQuickLaunch() {
107 StartRestartableService( 104 StartRestartableService(
108 "mojo:quick_launch", 105 "mojo:quick_launch",
109 base::Bind(&ShellApplicationDelegate::StartQuickLaunch, 106 base::Bind(&Session::StartQuickLaunch,
110 base::Unretained(this))); 107 base::Unretained(this)));
111 } 108 }
112 109
113 void ShellApplicationDelegate::StartScreenlock() { 110 void Session::StartScreenlock() {
114 StartRestartableService( 111 StartRestartableService(
115 "mojo:screenlock", 112 "mojo:screenlock",
116 base::Bind(&ShellApplicationDelegate::StartScreenlock, 113 base::Bind(&Session::StartScreenlock,
117 base::Unretained(this))); 114 base::Unretained(this)));
118 } 115 }
119 116
120 void ShellApplicationDelegate::StopScreenlock() { 117 void Session::StopScreenlock() {
121 auto connection = connections_.find("mojo:screenlock"); 118 auto connection = connections_.find("mojo:screenlock");
122 DCHECK(connections_.end() != connection); 119 DCHECK(connections_.end() != connection);
123 connections_.erase(connection); 120 connections_.erase(connection);
124 } 121 }
125 122
126 void ShellApplicationDelegate::StartRestartableService( 123 void Session::StartRestartableService(
127 const std::string& url, 124 const std::string& url,
128 const base::Closure& restart_callback) { 125 const base::Closure& restart_callback) {
129 // TODO(beng): This would be the place to insert logic that counted restarts 126 // TODO(beng): This would be the place to insert logic that counted restarts
130 // to avoid infinite crash-restart loops. 127 // to avoid infinite crash-restart loops.
131 scoped_ptr<mojo::Connection> connection = connector_->Connect(url); 128 scoped_ptr<mojo::Connection> connection = connector_->Connect(url);
132 // Note: |connection| may be null if we've lost our connection to the shell. 129 // Note: |connection| may be null if we've lost our connection to the shell.
133 if (connection) { 130 if (connection) {
134 connection->SetConnectionLostClosure(restart_callback); 131 connection->SetConnectionLostClosure(restart_callback);
135 connection->AddInterface<mojom::Shell>(this); 132 connection->AddInterface<mojom::Session>(this);
136 connections_[url] = std::move(connection); 133 connections_[url] = std::move(connection);
137 } 134 }
138 } 135 }
139 136
140 } // namespace shell 137 } // namespace session
141 } // namespace main 138 } // namespace main
OLDNEW
« no previous file with comments | « mash/session/session.h ('k') | mash/shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698