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

Side by Side Diff: chrome/browser/ui/ash/system_tray_client.cc

Issue 2882933002: Add update available icon in system tray (Closed)
Patch Set: Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/ui/ash/system_tray_client.h" 5 #include "chrome/browser/ui/ash/system_tray_client.h"
6 6
7 #include "ash/login_status.h" 7 #include "ash/login_status.h"
8 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/public/interfaces/constants.mojom.h" 9 #include "ash/public/interfaces/constants.mojom.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/weak_ptr.h"
13 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_process_platform_part.h" 16 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 18 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
18 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" 19 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
19 #include "chrome/browser/chromeos/login/help_app_launcher.h" 20 #include "chrome/browser/chromeos/login/help_app_launcher.h"
20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 21 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
21 #include "chrome/browser/chromeos/options/network_config_view.h" 22 #include "chrome/browser/chromeos/options/network_config_view.h"
22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "services/service_manager/public/cpp/connector.h" 55 #include "services/service_manager/public/cpp/connector.h"
55 #include "services/ui/public/cpp/property_type_converters.h" 56 #include "services/ui/public/cpp/property_type_converters.h"
56 #include "services/ui/public/interfaces/window_manager.mojom.h" 57 #include "services/ui/public/interfaces/window_manager.mojom.h"
57 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" 58 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
58 #include "ui/views/widget/widget.h" 59 #include "ui/views/widget/widget.h"
59 #include "ui/views/window/dialog_delegate.h" 60 #include "ui/views/window/dialog_delegate.h"
60 61
61 using chromeos::BluetoothPairingDialog; 62 using chromeos::BluetoothPairingDialog;
62 using chromeos::DBusThreadManager; 63 using chromeos::DBusThreadManager;
63 using chromeos::LoginState; 64 using chromeos::LoginState;
65 using chromeos::UpdateEngineClient;
64 using device::BluetoothDevice; 66 using device::BluetoothDevice;
65 using views::Widget; 67 using views::Widget;
66 68
67 namespace { 69 namespace {
68 70
69 SystemTrayClient* g_instance = nullptr; 71 SystemTrayClient* g_instance = nullptr;
70 72
71 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { 73 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) {
72 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), 74 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
73 sub_page); 75 sub_page);
(...skipping 27 matching lines...) Expand all
101 ->BindInterface(ash::mojom::kServiceName, &system_tray_); 103 ->BindInterface(ash::mojom::kServiceName, &system_tray_);
102 // Register this object as the client interface implementation. 104 // Register this object as the client interface implementation.
103 system_tray_->SetClient(binding_.CreateInterfacePtrAndBind()); 105 system_tray_->SetClient(binding_.CreateInterfacePtrAndBind());
104 106
105 // If this observes clock setting changes before ash comes up the IPCs will 107 // If this observes clock setting changes before ash comes up the IPCs will
106 // be queued on |system_tray_|. 108 // be queued on |system_tray_|.
107 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); 109 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this);
108 110
109 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 111 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
110 content::NotificationService::AllSources()); 112 content::NotificationService::AllSources());
113 registrar_.Add(this, chrome::NOTIFICATION_UPDATE_OVER_CELLULAR_AVAILABLE,
114 content::NotificationService::AllSources());
111 115
112 // If an upgrade is available at startup then tell ash about it. 116 // If an upgrade is available at startup then tell ash about it.
113 if (UpgradeDetector::GetInstance()->notify_upgrade()) 117 if (UpgradeDetector::GetInstance()->notify_upgrade())
114 HandleUpdateAvailable(); 118 HandleUpdateAvailable();
115 119
116 // If the device is enterprise managed then send ash the enterprise domain. 120 // If the device is enterprise managed then send ash the enterprise domain.
117 policy::BrowserPolicyConnectorChromeOS* policy_connector = 121 policy::BrowserPolicyConnectorChromeOS* policy_connector =
118 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 122 g_browser_process->platform_part()->browser_policy_connector_chromeos();
119 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 123 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
120 policy_connector->GetDeviceCloudPolicyManager(); 124 policy_connector->GetDeviceCloudPolicyManager();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return ash::LoginStatus::SUPERVISED; 175 return ash::LoginStatus::SUPERVISED;
172 case LoginState::LOGGED_IN_USER_KIOSK_APP: 176 case LoginState::LOGGED_IN_USER_KIOSK_APP:
173 return ash::LoginStatus::KIOSK_APP; 177 return ash::LoginStatus::KIOSK_APP;
174 case LoginState::LOGGED_IN_USER_ARC_KIOSK_APP: 178 case LoginState::LOGGED_IN_USER_ARC_KIOSK_APP:
175 return ash::LoginStatus::ARC_KIOSK_APP; 179 return ash::LoginStatus::ARC_KIOSK_APP;
176 } 180 }
177 NOTREACHED(); 181 NOTREACHED();
178 return ash::LoginStatus::NOT_LOGGED_IN; 182 return ash::LoginStatus::NOT_LOGGED_IN;
179 } 183 }
180 184
185 void SystemTrayClient::RequestUpdateCheck() {
186 base::WeakPtrFactory<SystemTrayClient> weak_ptr_factory_(this);
187 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck(
188 base::Bind(&SystemTrayClient::OnRequestUpdateCheck,
189 weak_ptr_factory_.GetWeakPtr()));
190 }
191
192 void SystemTrayClient::OnRequestUpdateCheck(
193 UpdateEngineClient::UpdateCheckResult /* result */) {}
194
181 // static 195 // static
182 int SystemTrayClient::GetDialogParentContainerId() { 196 int SystemTrayClient::GetDialogParentContainerId() {
183 const ash::LoginStatus login_status = GetUserLoginStatus(); 197 const ash::LoginStatus login_status = GetUserLoginStatus();
184 if (login_status == ash::LoginStatus::NOT_LOGGED_IN || 198 if (login_status == ash::LoginStatus::NOT_LOGGED_IN ||
185 login_status == ash::LoginStatus::LOCKED) { 199 login_status == ash::LoginStatus::LOCKED) {
186 return ash::kShellWindowId_LockSystemModalContainer; 200 return ash::kShellWindowId_LockSystemModalContainer;
187 } 201 }
188 202
189 session_manager::SessionManager* const session_manager = 203 session_manager::SessionManager* const session_manager =
190 session_manager::SessionManager::Get(); 204 session_manager::SessionManager::Get();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 dialog->ShowInContainer(GetDialogParentContainerId()); 276 dialog->ShowInContainer(GetDialogParentContainerId());
263 } 277 }
264 278
265 void SystemTrayClient::ShowDateSettings() { 279 void SystemTrayClient::ShowDateSettings() {
266 base::RecordAction(base::UserMetricsAction("ShowDateOptions")); 280 base::RecordAction(base::UserMetricsAction("ShowDateOptions"));
267 // Everybody can change the time zone (even though it is a device setting). 281 // Everybody can change the time zone (even though it is a device setting).
268 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), 282 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
269 chrome::kDateTimeSubPage); 283 chrome::kDateTimeSubPage);
270 } 284 }
271 285
286 void SystemTrayClient::ShowAboutChromeOS() {
287 ShowSettingsSubPageForActiveUser(chrome::kHelpSubPage);
288 }
289
272 void SystemTrayClient::ShowSetTimeDialog() { 290 void SystemTrayClient::ShowSetTimeDialog() {
273 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId()); 291 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId());
274 } 292 }
275 293
276 void SystemTrayClient::ShowDisplaySettings() { 294 void SystemTrayClient::ShowDisplaySettings() {
277 base::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); 295 base::RecordAction(base::UserMetricsAction("ShowDisplayOptions"));
278 ShowSettingsSubPageForActiveUser(chrome::kDisplaySubPage); 296 ShowSettingsSubPageForActiveUser(chrome::kDisplaySubPage);
279 } 297 }
280 298
281 void SystemTrayClient::ShowPowerSettings() { 299 void SystemTrayClient::ShowPowerSettings() {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // Show a string specific to updating flash player if there is no system 471 // Show a string specific to updating flash player if there is no system
454 // update. 472 // update.
455 ash::mojom::UpdateType update_type = detector->notify_upgrade() 473 ash::mojom::UpdateType update_type = detector->notify_upgrade()
456 ? ash::mojom::UpdateType::SYSTEM 474 ? ash::mojom::UpdateType::SYSTEM
457 : ash::mojom::UpdateType::FLASH; 475 : ash::mojom::UpdateType::FLASH;
458 476
459 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(), 477 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(),
460 update_type); 478 update_type);
461 } 479 }
462 480
481 void SystemTrayClient::HandleUpdateOverCellularAvailable() {
482 system_tray_->ShowUpdateOverCellularAvailableIcon();
483 }
484
463 //////////////////////////////////////////////////////////////////////////////// 485 ////////////////////////////////////////////////////////////////////////////////
464 // chromeos::system::SystemClockObserver: 486 // chromeos::system::SystemClockObserver:
465 487
466 void SystemTrayClient::OnSystemClockChanged( 488 void SystemTrayClient::OnSystemClockChanged(
467 chromeos::system::SystemClock* clock) { 489 chromeos::system::SystemClock* clock) {
468 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); 490 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock());
469 } 491 }
470 492
471 void SystemTrayClient::Observe(int type, 493 void SystemTrayClient::Observe(int type,
472 const content::NotificationSource& source, 494 const content::NotificationSource& source,
473 const content::NotificationDetails& details) { 495 const content::NotificationDetails& details) {
474 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); 496 if (chrome::NOTIFICATION_UPGRADE_RECOMMENDED == type)
475 HandleUpdateAvailable(); 497 HandleUpdateAvailable();
498 else if (chrome::NOTIFICATION_UPDATE_OVER_CELLULAR_AVAILABLE == type)
499 HandleUpdateOverCellularAvailable();
476 } 500 }
477 501
478 //////////////////////////////////////////////////////////////////////////////// 502 ////////////////////////////////////////////////////////////////////////////////
479 // policy::CloudPolicyStore::Observer 503 // policy::CloudPolicyStore::Observer
480 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { 504 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) {
481 UpdateEnterpriseDomain(); 505 UpdateEnterpriseDomain();
482 } 506 }
483 507
484 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { 508 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) {
485 UpdateEnterpriseDomain(); 509 UpdateEnterpriseDomain();
486 } 510 }
487 511
488 void SystemTrayClient::UpdateEnterpriseDomain() { 512 void SystemTrayClient::UpdateEnterpriseDomain() {
489 policy::BrowserPolicyConnectorChromeOS* connector = 513 policy::BrowserPolicyConnectorChromeOS* connector =
490 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 514 g_browser_process->platform_part()->browser_policy_connector_chromeos();
491 const std::string enterprise_domain = connector->GetEnterpriseDomain(); 515 const std::string enterprise_domain = connector->GetEnterpriseDomain();
492 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); 516 const bool active_directory_managed = connector->IsActiveDirectoryManaged();
493 if (enterprise_domain == last_enterprise_domain_ && 517 if (enterprise_domain == last_enterprise_domain_ &&
494 active_directory_managed == last_active_directory_managed_) { 518 active_directory_managed == last_active_directory_managed_) {
495 return; 519 return;
496 } 520 }
497 // Send to ash, which will add an item to the system tray. 521 // Send to ash, which will add an item to the system tray.
498 system_tray_->SetEnterpriseDomain(enterprise_domain, 522 system_tray_->SetEnterpriseDomain(enterprise_domain,
499 active_directory_managed); 523 active_directory_managed);
500 last_enterprise_domain_ = enterprise_domain; 524 last_enterprise_domain_ = enterprise_domain;
501 last_active_directory_managed_ = active_directory_managed; 525 last_active_directory_managed_ = active_directory_managed;
502 } 526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698