| 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 "mojo/shell/public/cpp/application_connection.h" | 8 #include "mojo/shell/public/cpp/connection.h" |
| 9 #include "mojo/shell/public/cpp/shell.h" | 9 #include "mojo/shell/public/cpp/shell.h" |
| 10 | 10 |
| 11 namespace mash { | 11 namespace mash { |
| 12 namespace shell { | 12 namespace shell { |
| 13 | 13 |
| 14 ShellApplicationDelegate::ShellApplicationDelegate() | 14 ShellApplicationDelegate::ShellApplicationDelegate() |
| 15 : shell_(nullptr), screen_locked_(false) {} | 15 : shell_(nullptr), screen_locked_(false) {} |
| 16 | 16 |
| 17 ShellApplicationDelegate::~ShellApplicationDelegate() {} | 17 ShellApplicationDelegate::~ShellApplicationDelegate() {} |
| 18 | 18 |
| 19 void ShellApplicationDelegate::Initialize(mojo::Shell* shell, | 19 void ShellApplicationDelegate::Initialize(mojo::Shell* shell, |
| 20 const std::string& url, | 20 const std::string& url, |
| 21 uint32_t id) { | 21 uint32_t id) { |
| 22 shell_ = shell; | 22 shell_ = shell; |
| 23 StartBrowserDriver(); | 23 StartBrowserDriver(); |
| 24 StartWindowManager(); | 24 StartWindowManager(); |
| 25 StartWallpaper(); | 25 StartWallpaper(); |
| 26 StartShelf(); | 26 StartShelf(); |
| 27 StartQuickLaunch(); | 27 StartQuickLaunch(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool ShellApplicationDelegate::AcceptConnection( | 30 bool ShellApplicationDelegate::AcceptConnection(mojo::Connection* connection) { |
| 31 mojo::ApplicationConnection* connection) { | |
| 32 connection->AddService<mash::shell::mojom::Shell>(this); | 31 connection->AddService<mash::shell::mojom::Shell>(this); |
| 33 return true; | 32 return true; |
| 34 } | 33 } |
| 35 | 34 |
| 36 void ShellApplicationDelegate::AddScreenlockStateListener( | 35 void ShellApplicationDelegate::AddScreenlockStateListener( |
| 37 mojom::ScreenlockStateListenerPtr listener) { | 36 mojom::ScreenlockStateListenerPtr listener) { |
| 38 listener->ScreenlockStateChanged(screen_locked_); | 37 listener->ScreenlockStateChanged(screen_locked_); |
| 39 screenlock_listeners_.AddInterfacePtr(std::move(listener)); | 38 screenlock_listeners_.AddInterfacePtr(std::move(listener)); |
| 40 } | 39 } |
| 41 | 40 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 return; | 53 return; |
| 55 screen_locked_ = false; | 54 screen_locked_ = false; |
| 56 screenlock_listeners_.ForAllPtrs( | 55 screenlock_listeners_.ForAllPtrs( |
| 57 [](mojom::ScreenlockStateListener* listener) { | 56 [](mojom::ScreenlockStateListener* listener) { |
| 58 listener->ScreenlockStateChanged(false); | 57 listener->ScreenlockStateChanged(false); |
| 59 }); | 58 }); |
| 60 StopScreenlock(); | 59 StopScreenlock(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 void ShellApplicationDelegate::Create( | 62 void ShellApplicationDelegate::Create( |
| 64 mojo::ApplicationConnection* connection, | 63 mojo::Connection* connection, |
| 65 mojo::InterfaceRequest<mash::shell::mojom::Shell> r) { | 64 mojo::InterfaceRequest<mash::shell::mojom::Shell> r) { |
| 66 bindings_.AddBinding(this, std::move(r)); | 65 bindings_.AddBinding(this, std::move(r)); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void ShellApplicationDelegate::StartWindowManager() { | 68 void ShellApplicationDelegate::StartWindowManager() { |
| 70 StartRestartableService( | 69 StartRestartableService( |
| 71 "mojo:desktop_wm", | 70 "mojo:desktop_wm", |
| 72 base::Bind(&ShellApplicationDelegate::StartWindowManager, | 71 base::Bind(&ShellApplicationDelegate::StartWindowManager, |
| 73 base::Unretained(this))); | 72 base::Unretained(this))); |
| 74 } | 73 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 auto connection = connections_.find("mojo:screenlock"); | 109 auto connection = connections_.find("mojo:screenlock"); |
| 111 DCHECK(connections_.end() != connection); | 110 DCHECK(connections_.end() != connection); |
| 112 connections_.erase(connection); | 111 connections_.erase(connection); |
| 113 } | 112 } |
| 114 | 113 |
| 115 void ShellApplicationDelegate::StartRestartableService( | 114 void ShellApplicationDelegate::StartRestartableService( |
| 116 const std::string& url, | 115 const std::string& url, |
| 117 const base::Closure& restart_callback) { | 116 const base::Closure& restart_callback) { |
| 118 // 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 |
| 119 // to avoid infinite crash-restart loops. | 118 // to avoid infinite crash-restart loops. |
| 120 scoped_ptr<mojo::ApplicationConnection> connection = | 119 scoped_ptr<mojo::Connection> connection = |
| 121 shell_->ConnectToApplication(url); | 120 shell_->ConnectToApplication(url); |
| 122 connection->SetRemoteServiceProviderConnectionErrorHandler(restart_callback); | 121 connection->SetRemoteServiceProviderConnectionErrorHandler(restart_callback); |
| 123 connections_[url] = std::move(connection); | 122 connections_[url] = std::move(connection); |
| 124 } | 123 } |
| 125 | 124 |
| 126 } // namespace shell | 125 } // namespace shell |
| 127 } // namespace main | 126 } // namespace main |
| OLD | NEW |