OLD | NEW |
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/shell/shell_application_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" |
8 #include "mojo/shell/public/cpp/application_connection.h" | 9 #include "mojo/shell/public/cpp/application_connection.h" |
9 #include "mojo/shell/public/cpp/application_impl.h" | 10 #include "mojo/shell/public/cpp/application_impl.h" |
10 | 11 |
| 12 namespace { |
| 13 |
| 14 const char kUseAshSysui[] = "use-ash-sysui"; |
| 15 |
| 16 } // namespace |
| 17 |
11 namespace mash { | 18 namespace mash { |
12 namespace shell { | 19 namespace shell { |
13 | 20 |
14 ShellApplicationDelegate::ShellApplicationDelegate() | 21 ShellApplicationDelegate::ShellApplicationDelegate() |
15 : app_(nullptr), screen_locked_(false) {} | 22 : app_(nullptr), screen_locked_(false) {} |
16 | 23 |
17 ShellApplicationDelegate::~ShellApplicationDelegate() {} | 24 ShellApplicationDelegate::~ShellApplicationDelegate() {} |
18 | 25 |
19 void ShellApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { | 26 void ShellApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { |
20 app_ = app; | 27 app_ = app; |
21 StartBrowserDriver(); | 28 StartBrowserDriver(); |
22 StartWindowManager(); | 29 StartWindowManager(); |
23 StartWallpaper(); | 30 StartSystemUI(); |
24 StartShelf(); | |
25 StartQuickLaunch(); | 31 StartQuickLaunch(); |
26 } | 32 } |
27 | 33 |
28 bool ShellApplicationDelegate::ConfigureIncomingConnection( | 34 bool ShellApplicationDelegate::ConfigureIncomingConnection( |
29 mojo::ApplicationConnection* connection) { | 35 mojo::ApplicationConnection* connection) { |
30 connection->AddService<mash::shell::mojom::Shell>(this); | 36 connection->AddService<mash::shell::mojom::Shell>(this); |
31 return true; | 37 return true; |
32 } | 38 } |
33 | 39 |
34 void ShellApplicationDelegate::AddScreenlockStateListener( | 40 void ShellApplicationDelegate::AddScreenlockStateListener( |
(...skipping 29 matching lines...) Expand all Loading... |
64 bindings_.AddBinding(this, std::move(r)); | 70 bindings_.AddBinding(this, std::move(r)); |
65 } | 71 } |
66 | 72 |
67 void ShellApplicationDelegate::StartWindowManager() { | 73 void ShellApplicationDelegate::StartWindowManager() { |
68 StartRestartableService( | 74 StartRestartableService( |
69 "mojo:desktop_wm", | 75 "mojo:desktop_wm", |
70 base::Bind(&ShellApplicationDelegate::StartWindowManager, | 76 base::Bind(&ShellApplicationDelegate::StartWindowManager, |
71 base::Unretained(this))); | 77 base::Unretained(this))); |
72 } | 78 } |
73 | 79 |
| 80 void ShellApplicationDelegate::StartSystemUI() { |
| 81 static bool use_ash = |
| 82 base::CommandLine::ForCurrentProcess()->HasSwitch(kUseAshSysui); |
| 83 if (use_ash) { |
| 84 StartRestartableService("mojo:ash_sysui", |
| 85 base::Bind(&ShellApplicationDelegate::StartSystemUI, |
| 86 base::Unretained(this))); |
| 87 } else { |
| 88 StartWallpaper(); |
| 89 StartShelf(); |
| 90 } |
| 91 } |
| 92 |
74 void ShellApplicationDelegate::StartWallpaper() { | 93 void ShellApplicationDelegate::StartWallpaper() { |
75 StartRestartableService("mojo:wallpaper", | 94 StartRestartableService("mojo:wallpaper", |
76 base::Bind(&ShellApplicationDelegate::StartWallpaper, | 95 base::Bind(&ShellApplicationDelegate::StartWallpaper, |
77 base::Unretained(this))); | 96 base::Unretained(this))); |
78 } | 97 } |
79 | 98 |
80 void ShellApplicationDelegate::StartShelf() { | 99 void ShellApplicationDelegate::StartShelf() { |
81 StartRestartableService("mojo:shelf", | 100 StartRestartableService("mojo:shelf", |
82 base::Bind(&ShellApplicationDelegate::StartShelf, | 101 base::Bind(&ShellApplicationDelegate::StartShelf, |
83 base::Unretained(this))); | 102 base::Unretained(this))); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // TODO(beng): This would be the place to insert logic that counted restarts | 135 // TODO(beng): This would be the place to insert logic that counted restarts |
117 // to avoid infinite crash-restart loops. | 136 // to avoid infinite crash-restart loops. |
118 scoped_ptr<mojo::ApplicationConnection> connection = | 137 scoped_ptr<mojo::ApplicationConnection> connection = |
119 app_->ConnectToApplication(url); | 138 app_->ConnectToApplication(url); |
120 connection->SetRemoteServiceProviderConnectionErrorHandler(restart_callback); | 139 connection->SetRemoteServiceProviderConnectionErrorHandler(restart_callback); |
121 connections_[url] = std::move(connection); | 140 connections_[url] = std::move(connection); |
122 } | 141 } |
123 | 142 |
124 } // namespace shell | 143 } // namespace shell |
125 } // namespace main | 144 } // namespace main |
OLD | NEW |