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 "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 Loading... |
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 Loading... |
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 chrome::ScopedTabbedBrowserDisplayer displayer( | 291 chrome::ScopedTabbedBrowserDisplayer displayer( |
288 ProfileManager::GetPrimaryUserProfile()); | 292 ProfileManager::GetPrimaryUserProfile()); |
289 chrome::ShowSlow(displayer.browser()); | 293 chrome::ShowSlow(displayer.browser()); |
290 } | 294 } |
291 | 295 |
292 void SystemTrayClient::ShowIMESettings() { | 296 void SystemTrayClient::ShowIMESettings() { |
293 base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); | 297 base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); |
294 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); | 298 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); |
295 } | 299 } |
296 | 300 |
| 301 void SystemTrayClient::ShowAboutChromeOS() { |
| 302 // We always want to check for updates when showing the about page from the |
| 303 // Ash UI. |
| 304 ShowSettingsSubPageForActiveUser(std::string(chrome::kHelpSubPage) + |
| 305 "?checkForUpdate=true"); |
| 306 } |
| 307 |
297 void SystemTrayClient::ShowHelp() { | 308 void SystemTrayClient::ShowHelp() { |
298 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), | 309 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), |
299 chrome::HELP_SOURCE_MENU); | 310 chrome::HELP_SOURCE_MENU); |
300 } | 311 } |
301 | 312 |
302 void SystemTrayClient::ShowAccessibilityHelp() { | 313 void SystemTrayClient::ShowAccessibilityHelp() { |
303 chrome::ScopedTabbedBrowserDisplayer displayer( | 314 chrome::ScopedTabbedBrowserDisplayer displayer( |
304 ProfileManager::GetActiveUserProfile()); | 315 ProfileManager::GetActiveUserProfile()); |
305 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); | 316 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); |
306 } | 317 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 // Show a string specific to updating flash player if there is no system | 464 // Show a string specific to updating flash player if there is no system |
454 // update. | 465 // update. |
455 ash::mojom::UpdateType update_type = detector->notify_upgrade() | 466 ash::mojom::UpdateType update_type = detector->notify_upgrade() |
456 ? ash::mojom::UpdateType::SYSTEM | 467 ? ash::mojom::UpdateType::SYSTEM |
457 : ash::mojom::UpdateType::FLASH; | 468 : ash::mojom::UpdateType::FLASH; |
458 | 469 |
459 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(), | 470 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(), |
460 update_type); | 471 update_type); |
461 } | 472 } |
462 | 473 |
| 474 void SystemTrayClient::HandleUpdateOverCellularAvailable() { |
| 475 system_tray_->ShowUpdateOverCellularAvailableIcon(); |
| 476 } |
| 477 |
463 //////////////////////////////////////////////////////////////////////////////// | 478 //////////////////////////////////////////////////////////////////////////////// |
464 // chromeos::system::SystemClockObserver: | 479 // chromeos::system::SystemClockObserver: |
465 | 480 |
466 void SystemTrayClient::OnSystemClockChanged( | 481 void SystemTrayClient::OnSystemClockChanged( |
467 chromeos::system::SystemClock* clock) { | 482 chromeos::system::SystemClock* clock) { |
468 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 483 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
469 } | 484 } |
470 | 485 |
471 void SystemTrayClient::Observe(int type, | 486 void SystemTrayClient::Observe(int type, |
472 const content::NotificationSource& source, | 487 const content::NotificationSource& source, |
473 const content::NotificationDetails& details) { | 488 const content::NotificationDetails& details) { |
474 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); | 489 if (chrome::NOTIFICATION_UPGRADE_RECOMMENDED == type) |
475 HandleUpdateAvailable(); | 490 HandleUpdateAvailable(); |
| 491 else if (chrome::NOTIFICATION_UPDATE_OVER_CELLULAR_AVAILABLE == type) |
| 492 HandleUpdateOverCellularAvailable(); |
476 } | 493 } |
477 | 494 |
478 //////////////////////////////////////////////////////////////////////////////// | 495 //////////////////////////////////////////////////////////////////////////////// |
479 // policy::CloudPolicyStore::Observer | 496 // policy::CloudPolicyStore::Observer |
480 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { | 497 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { |
481 UpdateEnterpriseDomain(); | 498 UpdateEnterpriseDomain(); |
482 } | 499 } |
483 | 500 |
484 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { | 501 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { |
485 UpdateEnterpriseDomain(); | 502 UpdateEnterpriseDomain(); |
486 } | 503 } |
487 | 504 |
488 void SystemTrayClient::UpdateEnterpriseDomain() { | 505 void SystemTrayClient::UpdateEnterpriseDomain() { |
489 policy::BrowserPolicyConnectorChromeOS* connector = | 506 policy::BrowserPolicyConnectorChromeOS* connector = |
490 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 507 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
491 const std::string enterprise_domain = connector->GetEnterpriseDomain(); | 508 const std::string enterprise_domain = connector->GetEnterpriseDomain(); |
492 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); | 509 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); |
493 if (enterprise_domain == last_enterprise_domain_ && | 510 if (enterprise_domain == last_enterprise_domain_ && |
494 active_directory_managed == last_active_directory_managed_) { | 511 active_directory_managed == last_active_directory_managed_) { |
495 return; | 512 return; |
496 } | 513 } |
497 // Send to ash, which will add an item to the system tray. | 514 // Send to ash, which will add an item to the system tray. |
498 system_tray_->SetEnterpriseDomain(enterprise_domain, | 515 system_tray_->SetEnterpriseDomain(enterprise_domain, |
499 active_directory_managed); | 516 active_directory_managed); |
500 last_enterprise_domain_ = enterprise_domain; | 517 last_enterprise_domain_ = enterprise_domain; |
501 last_active_directory_managed_ = active_directory_managed; | 518 last_active_directory_managed_ = active_directory_managed; |
502 } | 519 } |
OLD | NEW |