| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/common/system/tray/system_tray_controller.h" | 5 #include "ash/common/system/tray/system_tray_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/system/tray/system_tray_notifier.h" | 7 #include "ash/common/system/tray/system_tray_notifier.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Unit tests may not have a connector. | 95 // Unit tests may not have a connector. |
| 96 if (!connector_) | 96 if (!connector_) |
| 97 return false; | 97 return false; |
| 98 | 98 |
| 99 #if defined(OS_CHROMEOS) | 99 #if defined(OS_CHROMEOS) |
| 100 // If already connected, nothing to do. | 100 // If already connected, nothing to do. |
| 101 if (system_tray_client_.is_bound()) | 101 if (system_tray_client_.is_bound()) |
| 102 return true; | 102 return true; |
| 103 | 103 |
| 104 // Connect (or reconnect) to the interface. | 104 // Connect (or reconnect) to the interface. |
| 105 if (WmShell::Get()->IsRunningInMash()) { | 105 connector_->ConnectToInterface("service:content_browser", |
| 106 connector_->ConnectToInterface("exe:chrome", &system_tray_client_); | 106 &system_tray_client_); |
| 107 } else { | |
| 108 connector_->ConnectToInterface("service:content_browser", | |
| 109 &system_tray_client_); | |
| 110 } | |
| 111 | 107 |
| 112 // Handle chrome crashes by forcing a reconnect on the next request. | 108 // Handle chrome crashes by forcing a reconnect on the next request. |
| 113 system_tray_client_.set_connection_error_handler(base::Bind( | 109 system_tray_client_.set_connection_error_handler(base::Bind( |
| 114 &SystemTrayController::OnClientConnectionError, base::Unretained(this))); | 110 &SystemTrayController::OnClientConnectionError, base::Unretained(this))); |
| 115 return true; | 111 return true; |
| 116 #else | 112 #else |
| 117 // The SystemTrayClient interface in the browser is only implemented for | 113 // The SystemTrayClient interface in the browser is only implemented for |
| 118 // Chrome OS, so don't try to connect on other platforms. | 114 // Chrome OS, so don't try to connect on other platforms. |
| 119 return false; | 115 return false; |
| 120 #endif // defined(OS_CHROMEOS) | 116 #endif // defined(OS_CHROMEOS) |
| 121 } | 117 } |
| 122 | 118 |
| 123 void SystemTrayController::OnClientConnectionError() { | 119 void SystemTrayController::OnClientConnectionError() { |
| 124 system_tray_client_.reset(); | 120 system_tray_client_.reset(); |
| 125 } | 121 } |
| 126 | 122 |
| 127 void SystemTrayController::SetUse24HourClock(bool use_24_hour) { | 123 void SystemTrayController::SetUse24HourClock(bool use_24_hour) { |
| 128 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; | 124 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; |
| 129 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); | 125 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); |
| 130 } | 126 } |
| 131 | 127 |
| 132 } // namespace ash | 128 } // namespace ash |
| OLD | NEW |