| 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/system/tray/system_tray_controller.h" | 5 #include "ash/system/tray/system_tray_controller.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_port.h" |
| 9 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/system_tray_notifier.h" | 11 #include "ash/system/tray/system_tray_notifier.h" |
| 11 #include "ash/system/update/tray_update.h" | 12 #include "ash/system/update/tray_update.h" |
| 12 #include "ash/wm_shell.h" | |
| 13 #include "ash/wm_window.h" | 13 #include "ash/wm_window.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 | 16 |
| 17 SystemTrayController::SystemTrayController() | 17 SystemTrayController::SystemTrayController() |
| 18 : hour_clock_type_(base::GetHourClockType()) {} | 18 : hour_clock_type_(base::GetHourClockType()) {} |
| 19 | 19 |
| 20 SystemTrayController::~SystemTrayController() {} | 20 SystemTrayController::~SystemTrayController() {} |
| 21 | 21 |
| 22 void SystemTrayController::ShowSettings() { | 22 void SystemTrayController::ShowSettings() { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void SystemTrayController::BindRequest(mojom::SystemTrayRequest request) { | 139 void SystemTrayController::BindRequest(mojom::SystemTrayRequest request) { |
| 140 bindings_.AddBinding(this, std::move(request)); | 140 bindings_.AddBinding(this, std::move(request)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void SystemTrayController::SetClient(mojom::SystemTrayClientPtr client) { | 143 void SystemTrayController::SetClient(mojom::SystemTrayClientPtr client) { |
| 144 system_tray_client_ = std::move(client); | 144 system_tray_client_ = std::move(client); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void SystemTrayController::SetPrimaryTrayEnabled(bool enabled) { | 147 void SystemTrayController::SetPrimaryTrayEnabled(bool enabled) { |
| 148 ash::SystemTray* tray = | 148 ash::SystemTray* tray = |
| 149 WmShell::Get()->GetPrimaryRootWindowController()->GetSystemTray(); | 149 ShellPort::Get()->GetPrimaryRootWindowController()->GetSystemTray(); |
| 150 if (!tray) | 150 if (!tray) |
| 151 return; | 151 return; |
| 152 | 152 |
| 153 // We disable the UI to prevent user from interacting with UI elements, | 153 // We disable the UI to prevent user from interacting with UI elements, |
| 154 // particularly with the system tray menu. However, in case if the system tray | 154 // particularly with the system tray menu. However, in case if the system tray |
| 155 // bubble is opened at this point, it remains opened and interactive even | 155 // bubble is opened at this point, it remains opened and interactive even |
| 156 // after SystemTray::SetEnabled(false) call, which can be dangerous | 156 // after SystemTray::SetEnabled(false) call, which can be dangerous |
| 157 // (http://crbug.com/497080). Close the menu to fix it. Calling | 157 // (http://crbug.com/497080). Close the menu to fix it. Calling |
| 158 // SystemTray::SetEnabled(false) guarantees, that the menu will not be opened | 158 // SystemTray::SetEnabled(false) guarantees, that the menu will not be opened |
| 159 // until the UI is enabled again. | 159 // until the UI is enabled again. |
| 160 if (!enabled && tray->HasSystemBubble()) | 160 if (!enabled && tray->HasSystemBubble()) |
| 161 tray->CloseSystemBubble(); | 161 tray->CloseSystemBubble(); |
| 162 | 162 |
| 163 tray->SetEnabled(enabled); | 163 tray->SetEnabled(enabled); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SystemTrayController::SetPrimaryTrayVisible(bool visible) { | 166 void SystemTrayController::SetPrimaryTrayVisible(bool visible) { |
| 167 ash::SystemTray* tray = | 167 ash::SystemTray* tray = |
| 168 WmShell::Get()->GetPrimaryRootWindowController()->GetSystemTray(); | 168 ShellPort::Get()->GetPrimaryRootWindowController()->GetSystemTray(); |
| 169 if (!tray) | 169 if (!tray) |
| 170 return; | 170 return; |
| 171 | 171 |
| 172 tray->SetVisible(visible); | 172 tray->SetVisible(visible); |
| 173 tray->GetWidget()->SetOpacity(visible ? 1.f : 0.f); | 173 tray->GetWidget()->SetOpacity(visible ? 1.f : 0.f); |
| 174 if (visible) { | 174 if (visible) { |
| 175 tray->GetWidget()->Show(); | 175 tray->GetWidget()->Show(); |
| 176 } else { | 176 } else { |
| 177 tray->GetWidget()->Hide(); | 177 tray->GetWidget()->Hide(); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 void SystemTrayController::SetUse24HourClock(bool use_24_hour) { | 181 void SystemTrayController::SetUse24HourClock(bool use_24_hour) { |
| 182 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; | 182 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; |
| 183 Shell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); | 183 Shell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void SystemTrayController::ShowUpdateIcon(mojom::UpdateSeverity severity, | 186 void SystemTrayController::ShowUpdateIcon(mojom::UpdateSeverity severity, |
| 187 bool factory_reset_required) { | 187 bool factory_reset_required) { |
| 188 // Show the icon on all displays. | 188 // Show the icon on all displays. |
| 189 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { | 189 for (WmWindow* root : ShellPort::Get()->GetAllRootWindows()) { |
| 190 ash::SystemTray* tray = root->GetRootWindowController()->GetSystemTray(); | 190 ash::SystemTray* tray = root->GetRootWindowController()->GetSystemTray(); |
| 191 // External monitors might not have a tray yet. | 191 // External monitors might not have a tray yet. |
| 192 if (!tray) | 192 if (!tray) |
| 193 continue; | 193 continue; |
| 194 tray->tray_update()->ShowUpdateIcon(severity, factory_reset_required); | 194 tray->tray_update()->ShowUpdateIcon(severity, factory_reset_required); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace ash | 198 } // namespace ash |
| OLD | NEW |