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" |
| 11 #include "content/public/common/service_names.mojom.h" |
11 #include "services/service_manager/public/cpp/connector.h" | 12 #include "services/service_manager/public/cpp/connector.h" |
12 | 13 |
13 namespace ash { | 14 namespace ash { |
14 | 15 |
15 SystemTrayController::SystemTrayController( | 16 SystemTrayController::SystemTrayController( |
16 service_manager::Connector* connector) | 17 service_manager::Connector* connector) |
17 : connector_(connector), hour_clock_type_(base::GetHourClockType()) {} | 18 : connector_(connector), hour_clock_type_(base::GetHourClockType()) {} |
18 | 19 |
19 SystemTrayController::~SystemTrayController() {} | 20 SystemTrayController::~SystemTrayController() {} |
20 | 21 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Unit tests may not have a connector. | 122 // Unit tests may not have a connector. |
122 if (!connector_) | 123 if (!connector_) |
123 return false; | 124 return false; |
124 | 125 |
125 #if defined(OS_CHROMEOS) | 126 #if defined(OS_CHROMEOS) |
126 // If already connected, nothing to do. | 127 // If already connected, nothing to do. |
127 if (system_tray_client_.is_bound()) | 128 if (system_tray_client_.is_bound()) |
128 return true; | 129 return true; |
129 | 130 |
130 // Connect (or reconnect) to the interface. | 131 // Connect (or reconnect) to the interface. |
131 connector_->ConnectToInterface("content_browser", &system_tray_client_); | 132 connector_->ConnectToInterface(content::mojom::kBrowserServiceName, |
| 133 &system_tray_client_); |
132 | 134 |
133 // Handle chrome crashes by forcing a reconnect on the next request. | 135 // Handle chrome crashes by forcing a reconnect on the next request. |
134 system_tray_client_.set_connection_error_handler(base::Bind( | 136 system_tray_client_.set_connection_error_handler(base::Bind( |
135 &SystemTrayController::OnClientConnectionError, base::Unretained(this))); | 137 &SystemTrayController::OnClientConnectionError, base::Unretained(this))); |
136 return true; | 138 return true; |
137 #else | 139 #else |
138 // The SystemTrayClient interface in the browser is only implemented for | 140 // The SystemTrayClient interface in the browser is only implemented for |
139 // Chrome OS, so don't try to connect on other platforms. | 141 // Chrome OS, so don't try to connect on other platforms. |
140 return false; | 142 return false; |
141 #endif // defined(OS_CHROMEOS) | 143 #endif // defined(OS_CHROMEOS) |
142 } | 144 } |
143 | 145 |
144 void SystemTrayController::OnClientConnectionError() { | 146 void SystemTrayController::OnClientConnectionError() { |
145 system_tray_client_.reset(); | 147 system_tray_client_.reset(); |
146 } | 148 } |
147 | 149 |
148 void SystemTrayController::SetUse24HourClock(bool use_24_hour) { | 150 void SystemTrayController::SetUse24HourClock(bool use_24_hour) { |
149 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; | 151 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; |
150 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); | 152 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); |
151 } | 153 } |
152 | 154 |
153 } // namespace ash | 155 } // namespace ash |
OLD | NEW |