[go: nahoru, domu]

blob: dcfddb6a21813dc66cd0b1fb5e80c80ad19ebbb3 [file] [log] [blame]
Tetsui Ohkubo21722932018-03-02 02:56:561// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/system/model/system_tray_model.h"
6
Tetsui Ohkubo36794462018-06-29 07:26:027#include "ash/root_window_controller.h"
8#include "ash/shell.h"
Tim Song4434c752020-09-17 10:24:479#include "ash/system/message_center/message_center_controller.h"
Tetsui Ohkubo6ab6ae12018-03-28 06:26:0710#include "ash/system/model/clock_model.h"
Tetsui Ohkubo21722932018-03-02 02:56:5611#include "ash/system/model/enterprise_domain_model.h"
Wenzhao Zangbdf77342018-12-12 00:24:4512#include "ash/system/model/locale_model.h"
Tetsui Ohkubo9090a192018-04-18 00:20:3913#include "ash/system/model/session_length_limit_model.h"
Tetsui Ohkuboac7b9672018-03-28 02:43:4514#include "ash/system/model/tracing_model.h"
Tetsui Ohkubo335179a2018-03-28 05:18:1915#include "ash/system/model/update_model.h"
Tetsui Ohkubo852abe62018-10-03 02:52:2716#include "ash/system/model/virtual_keyboard_model.h"
Steven Bennetts71ac2652019-02-07 00:32:5117#include "ash/system/network/active_network_icon.h"
Steven Bennetts02abafd2019-05-22 14:47:0218#include "ash/system/network/tray_network_state_model.h"
Tim Song4434c752020-09-17 10:24:4719#include "ash/system/phonehub/phone_hub_notification_controller.h"
Tim Songb32e7812020-09-11 22:42:1920#include "ash/system/phonehub/phone_hub_tray.h"
Tetsui Ohkubo36794462018-06-29 07:26:0221#include "ash/system/status_area_widget.h"
Tetsui Ohkubo36794462018-06-29 07:26:0222#include "ash/system/unified/unified_system_tray.h"
Tim Songb32e7812020-09-11 22:42:1923#include "chromeos/components/phonehub/phone_hub_manager.h"
Tetsui Ohkubo21722932018-03-02 02:56:5624
25namespace ash {
26
Ken Rockot80738e42019-08-15 20:34:5727SystemTrayModel::SystemTrayModel()
Tetsui Ohkubo6ab6ae12018-03-28 06:26:0728 : clock_(std::make_unique<ClockModel>()),
29 enterprise_domain_(std::make_unique<EnterpriseDomainModel>()),
Wenzhao Zangbdf77342018-12-12 00:24:4530 locale_(std::make_unique<LocaleModel>()),
Tetsui Ohkubo9090a192018-04-18 00:20:3931 session_length_limit_(std::make_unique<SessionLengthLimitModel>()),
Tetsui Ohkubo335179a2018-03-28 05:18:1932 tracing_(std::make_unique<TracingModel>()),
Tetsui Ohkubo852abe62018-10-03 02:52:2733 update_model_(std::make_unique<UpdateModel>()),
Steven Bennetts71ac2652019-02-07 00:32:5134 virtual_keyboard_(std::make_unique<VirtualKeyboardModel>()),
Ken Rockot80738e42019-08-15 20:34:5735 network_state_model_(std::make_unique<TrayNetworkStateModel>()),
Steven Bennetts64682d742019-05-21 19:16:0636 active_network_icon_(
Ken Rockot80738e42019-08-15 20:34:5737 std::make_unique<ActiveNetworkIcon>(network_state_model_.get())) {}
Tetsui Ohkubo21722932018-03-02 02:56:5638
39SystemTrayModel::~SystemTrayModel() = default;
40
James Cooka354b3b2019-05-22 23:15:3841void SystemTrayModel::SetClient(SystemTrayClient* client) {
42 client_ = client;
Tetsui Ohkuboac7b9672018-03-28 02:43:4543}
44
45void SystemTrayModel::SetPrimaryTrayEnabled(bool enabled) {
Tetsui Ohkubod0132522018-10-29 03:08:3746 UnifiedSystemTray* tray = Shell::GetPrimaryRootWindowController()
47 ->GetStatusAreaWidget()
48 ->unified_system_tray();
49 if (!tray)
50 return;
51 tray->SetTrayEnabled(enabled);
Tetsui Ohkuboac7b9672018-03-28 02:43:4552}
53
54void SystemTrayModel::SetPrimaryTrayVisible(bool visible) {
Tetsui Ohkubo36794462018-06-29 07:26:0255 auto* status_area =
56 Shell::GetPrimaryRootWindowController()->GetStatusAreaWidget();
57 if (status_area)
58 status_area->SetSystemTrayVisibility(visible);
Tetsui Ohkuboac7b9672018-03-28 02:43:4559}
60
61void SystemTrayModel::SetUse24HourClock(bool use_24_hour) {
Tetsui Ohkubo6ab6ae12018-03-28 06:26:0762 clock()->SetUse24HourClock(use_24_hour);
Tetsui Ohkuboac7b9672018-03-28 02:43:4563}
64
Brian Malcolm1246992d2020-10-07 18:11:5765void SystemTrayModel::SetEnterpriseDomainInfo(
66 const std::string& enterprise_domain_manager,
Tetsui Ohkuboac7b9672018-03-28 02:43:4567 bool active_directory_managed) {
Brian Malcolm1246992d2020-10-07 18:11:5768 enterprise_domain()->SetEnterpriseDomainInfo(enterprise_domain_manager,
69 active_directory_managed);
Tetsui Ohkuboac7b9672018-03-28 02:43:4570}
71
Andre Le7cc5fc32021-02-18 00:54:0272void SystemTrayModel::SetEnterpriseAccountDomainInfo(
73 const std::string& account_domain_manager) {
74 enterprise_domain()->SetEnterpriseAccountDomainInfo(account_domain_manager);
75}
76
Tetsui Ohkuboac7b9672018-03-28 02:43:4577void SystemTrayModel::SetPerformanceTracingIconVisible(bool visible) {
78 tracing()->SetIsTracing(visible);
79}
80
Wenzhao Zang0cb311d72018-11-15 22:42:3181void SystemTrayModel::SetLocaleList(
Xiyuan Xiabe4303e72019-06-06 18:14:5082 std::vector<LocaleInfo> locale_list,
Wenzhao Zang0cb311d72018-11-15 22:42:3183 const std::string& current_locale_iso_code) {
Wenzhao Zangbdf77342018-12-12 00:24:4584 locale()->SetLocaleList(std::move(locale_list), current_locale_iso_code);
Wenzhao Zang0cb311d72018-11-15 22:42:3185}
86
Xiyuan Xiab6fc2482019-06-05 20:45:0487void SystemTrayModel::ShowUpdateIcon(UpdateSeverity severity,
Tetsui Ohkuboac7b9672018-03-28 02:43:4588 bool factory_reset_required,
Marton Hunyady37ecdeb2018-07-20 18:10:0789 bool rollback,
Xiyuan Xiab6fc2482019-06-05 20:45:0490 UpdateType update_type) {
Marton Hunyady37ecdeb2018-07-20 18:10:0791 update_model()->SetUpdateAvailable(severity, factory_reset_required, rollback,
Tetsui Ohkubo335179a2018-03-28 05:18:1992 update_type);
Tetsui Ohkuboac7b9672018-03-28 02:43:4593}
94
Stefan Teodorescue2f01392018-08-22 19:13:4395void SystemTrayModel::SetUpdateNotificationState(
Xiyuan Xiab6fc2482019-06-05 20:45:0496 NotificationStyle style,
Jan Wilken Dörrie85285b02021-03-11 23:38:4797 const std::u16string& notification_title,
98 const std::u16string& notification_body) {
Stefan Teodorescue2f01392018-08-22 19:13:4399 update_model()->SetUpdateNotificationState(style, notification_title,
100 notification_body);
101}
102
Tetsui Ohkuboac7b9672018-03-28 02:43:45103void SystemTrayModel::SetUpdateOverCellularAvailableIconVisible(bool visible) {
Tetsui Ohkubo335179a2018-03-28 05:18:19104 update_model()->SetUpdateOverCellularAvailable(visible);
Tetsui Ohkuboac7b9672018-03-28 02:43:45105}
106
Tetsui Ohkuboeb0879f2018-06-11 22:52:51107void SystemTrayModel::ShowVolumeSliderBubble() {
Tetsui Ohkubo36794462018-06-29 07:26:02108 // Show the bubble on all monitors with a system tray.
Tetsui Ohkubod0132522018-10-29 03:08:37109 for (RootWindowController* root : Shell::GetAllRootWindowControllers()) {
110 UnifiedSystemTray* system_tray =
111 root->GetStatusAreaWidget()->unified_system_tray();
112 if (!system_tray)
113 continue;
114 system_tray->ShowVolumeSliderBubble();
Tetsui Ohkubo36794462018-06-29 07:26:02115 }
Tetsui Ohkuboeb0879f2018-06-11 22:52:51116}
117
Ahmed Mehfooz15cebdd2021-03-03 01:07:07118void SystemTrayModel::ShowNetworkDetailedViewBubble() {
Petr Smirnov9db99f132019-09-25 21:07:37119 // Show the bubble on the primary display.
120 UnifiedSystemTray* system_tray = Shell::GetPrimaryRootWindowController()
121 ->GetStatusAreaWidget()
122 ->unified_system_tray();
123 if (system_tray)
Ahmed Mehfooz15cebdd2021-03-03 01:07:07124 system_tray->ShowNetworkDetailedViewBubble();
Petr Smirnov9db99f132019-09-25 21:07:37125}
126
Kyle Horimotof4b8e3d2020-08-21 23:35:28127void SystemTrayModel::SetPhoneHubManager(
128 chromeos::phonehub::PhoneHubManager* phone_hub_manager) {
Andre Le4a5d5cd2020-12-08 20:04:15129 for (RootWindowController* root_window_controller :
130 Shell::GetAllRootWindowControllers()) {
131 auto* phone_hub_tray =
132 root_window_controller->GetStatusAreaWidget()->phone_hub_tray();
133 phone_hub_tray->SetPhoneHubManager(phone_hub_manager);
134 }
Tim Song4434c752020-09-17 10:24:47135
136 Shell::Get()
137 ->message_center_controller()
138 ->phone_hub_notification_controller()
Andre Leaeb1a902020-10-27 18:53:56139 ->SetManager(phone_hub_manager);
Kyle Horimotof4b8e3d2020-08-21 23:35:28140}
141
Tetsui Ohkubo21722932018-03-02 02:56:56142} // namespace ash