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