Chromium Code Reviews| Index: ash/common/system/tray/system_tray_controller.cc |
| diff --git a/ash/common/system/tray/system_tray_controller.cc b/ash/common/system/tray/system_tray_controller.cc |
| index 7ce7e904e3e45a634c1391b28c9a3787d49f3778..0e7be4b88b2d78847fdb9813809350f4b8401fef 100644 |
| --- a/ash/common/system/tray/system_tray_controller.cc |
| +++ b/ash/common/system/tray/system_tray_controller.cc |
| @@ -6,111 +6,106 @@ |
| #include "ash/common/system/tray/system_tray_notifier.h" |
| #include "ash/common/wm_shell.h" |
| -#include "base/bind.h" |
| -#include "base/bind_helpers.h" |
| -#include "content/public/common/service_names.mojom.h" |
| -#include "services/service_manager/public/cpp/connector.h" |
| namespace ash { |
| -SystemTrayController::SystemTrayController( |
| - service_manager::Connector* connector) |
| - : connector_(connector), hour_clock_type_(base::GetHourClockType()) {} |
| +SystemTrayController::SystemTrayController() |
| + : hour_clock_type_(base::GetHourClockType()) {} |
| SystemTrayController::~SystemTrayController() {} |
| void SystemTrayController::ShowSettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowSettings(); |
| } |
| void SystemTrayController::ShowDateSettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowDateSettings(); |
| } |
| void SystemTrayController::ShowSetTimeDialog() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowSetTimeDialog(); |
| } |
| void SystemTrayController::ShowDisplaySettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowDisplaySettings(); |
| } |
| void SystemTrayController::ShowPowerSettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowPowerSettings(); |
| } |
| void SystemTrayController::ShowChromeSlow() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowChromeSlow(); |
| } |
| void SystemTrayController::ShowIMESettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowIMESettings(); |
| } |
| void SystemTrayController::ShowHelp() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowHelp(); |
| } |
| void SystemTrayController::ShowAccessibilityHelp() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowAccessibilityHelp(); |
| } |
| void SystemTrayController::ShowAccessibilitySettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowAccessibilitySettings(); |
| } |
| void SystemTrayController::ShowPaletteHelp() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowPaletteHelp(); |
| } |
| void SystemTrayController::ShowPaletteSettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowPaletteSettings(); |
| } |
| void SystemTrayController::ShowPublicAccountInfo() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowPublicAccountInfo(); |
| } |
| void SystemTrayController::ShowNetworkConfigure(const std::string& network_id) { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowNetworkConfigure(network_id); |
| } |
| void SystemTrayController::ShowNetworkCreate(const std::string& type) { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowNetworkCreate(type); |
| } |
| void SystemTrayController::ShowNetworkSettings(const std::string& network_id) { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowNetworkSettings(network_id); |
| } |
| void SystemTrayController::ShowProxySettings() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->ShowProxySettings(); |
| } |
| void SystemTrayController::SignOut() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->SignOut(); |
| } |
| void SystemTrayController::RequestRestartForUpdate() { |
| - if (ConnectToSystemTrayClient()) |
| + if (HasSystemTrayClient()) |
| system_tray_client_->RequestRestartForUpdate(); |
| } |
| @@ -118,33 +113,15 @@ void SystemTrayController::BindRequest(mojom::SystemTrayRequest request) { |
| bindings_.AddBinding(this, std::move(request)); |
| } |
| -bool SystemTrayController::ConnectToSystemTrayClient() { |
| - // Unit tests may not have a connector. |
| - if (!connector_) |
| - return false; |
| - |
| -#if defined(OS_CHROMEOS) |
| - // If already connected, nothing to do. |
| - if (system_tray_client_.is_bound()) |
| +bool SystemTrayController::HasSystemTrayClient() { |
| + if (system_tray_client_) |
| return true; |
| - |
| - // Connect (or reconnect) to the interface. |
| - connector_->ConnectToInterface(content::mojom::kBrowserServiceName, |
| - &system_tray_client_); |
| - |
| - // Handle chrome crashes by forcing a reconnect on the next request. |
| - system_tray_client_.set_connection_error_handler(base::Bind( |
| - &SystemTrayController::OnClientConnectionError, base::Unretained(this))); |
| - return true; |
| -#else |
| - // The SystemTrayClient interface in the browser is only implemented for |
| - // Chrome OS, so don't try to connect on other platforms. |
| + LOG(ERROR) << "SystemTrayClient not bound"; |
|
James Cook
2016/11/22 23:46:20
I didn't want to have silent failures when running
|
| return false; |
| -#endif // defined(OS_CHROMEOS) |
| } |
| -void SystemTrayController::OnClientConnectionError() { |
| - system_tray_client_.reset(); |
| +void SystemTrayController::SetClient(mojom::SystemTrayClientPtr client) { |
| + system_tray_client_ = std::move(client); |
| } |
| void SystemTrayController::SetUse24HourClock(bool use_24_hour) { |