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

Unified Diff: ash/common/system/tray/system_tray_controller.cc

Issue 2525813004: chromeos: Introduce SetClient() on ash::mojom::SystemTray interface (Closed)
Patch Set: rebase onto vpn revert Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/system_tray_controller.h ('k') | ash/common/wm_shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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";
sky 2016/11/23 01:27:09 Will this result in a bunch of error logs in tests
James Cook 2016/11/28 18:24:47 Hmm, good point. I rewrote it not to log.
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) {
« no previous file with comments | « ash/common/system/tray/system_tray_controller.h ('k') | ash/common/wm_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698