Chromium Code Reviews| 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(bool check_for_update) { | |
| 302 std::string sub_page = chrome::kHelpSubPage; | |
| 303 sub_page += (check_for_update ? "?checkForUpdate=true" : ""); | |
|
stevenjb
2017/05/17 16:56:31
With the parameter removed, you can just add a com
weidongg
2017/05/17 18:33:37
Done.
| |
| 304 ShowSettingsSubPageForActiveUser(sub_page); | |
| 305 } | |
| 306 | |
| 297 void SystemTrayClient::ShowHelp() { | 307 void SystemTrayClient::ShowHelp() { |
| 298 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), | 308 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), |
| 299 chrome::HELP_SOURCE_MENU); | 309 chrome::HELP_SOURCE_MENU); |
| 300 } | 310 } |
| 301 | 311 |
| 302 void SystemTrayClient::ShowAccessibilityHelp() { | 312 void SystemTrayClient::ShowAccessibilityHelp() { |
| 303 chrome::ScopedTabbedBrowserDisplayer displayer( | 313 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 304 ProfileManager::GetActiveUserProfile()); | 314 ProfileManager::GetActiveUserProfile()); |
| 305 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); | 315 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); |
| 306 } | 316 } |
| (...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 | 463 // Show a string specific to updating flash player if there is no system |
| 454 // update. | 464 // update. |
| 455 ash::mojom::UpdateType update_type = detector->notify_upgrade() | 465 ash::mojom::UpdateType update_type = detector->notify_upgrade() |
| 456 ? ash::mojom::UpdateType::SYSTEM | 466 ? ash::mojom::UpdateType::SYSTEM |
| 457 : ash::mojom::UpdateType::FLASH; | 467 : ash::mojom::UpdateType::FLASH; |
| 458 | 468 |
| 459 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(), | 469 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(), |
| 460 update_type); | 470 update_type); |
| 461 } | 471 } |
| 462 | 472 |
| 473 void SystemTrayClient::HandleUpdateOverCellularAvailable() { | |
| 474 system_tray_->ShowUpdateOverCellularAvailableIcon(); | |
| 475 } | |
| 476 | |
| 463 //////////////////////////////////////////////////////////////////////////////// | 477 //////////////////////////////////////////////////////////////////////////////// |
| 464 // chromeos::system::SystemClockObserver: | 478 // chromeos::system::SystemClockObserver: |
| 465 | 479 |
| 466 void SystemTrayClient::OnSystemClockChanged( | 480 void SystemTrayClient::OnSystemClockChanged( |
| 467 chromeos::system::SystemClock* clock) { | 481 chromeos::system::SystemClock* clock) { |
| 468 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 482 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
| 469 } | 483 } |
| 470 | 484 |
| 471 void SystemTrayClient::Observe(int type, | 485 void SystemTrayClient::Observe(int type, |
| 472 const content::NotificationSource& source, | 486 const content::NotificationSource& source, |
| 473 const content::NotificationDetails& details) { | 487 const content::NotificationDetails& details) { |
| 474 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); | 488 if (chrome::NOTIFICATION_UPGRADE_RECOMMENDED == type) |
| 475 HandleUpdateAvailable(); | 489 HandleUpdateAvailable(); |
| 490 else if (chrome::NOTIFICATION_UPDATE_OVER_CELLULAR_AVAILABLE == type) | |
| 491 HandleUpdateOverCellularAvailable(); | |
| 476 } | 492 } |
| 477 | 493 |
| 478 //////////////////////////////////////////////////////////////////////////////// | 494 //////////////////////////////////////////////////////////////////////////////// |
| 479 // policy::CloudPolicyStore::Observer | 495 // policy::CloudPolicyStore::Observer |
| 480 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { | 496 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { |
| 481 UpdateEnterpriseDomain(); | 497 UpdateEnterpriseDomain(); |
| 482 } | 498 } |
| 483 | 499 |
| 484 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { | 500 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { |
| 485 UpdateEnterpriseDomain(); | 501 UpdateEnterpriseDomain(); |
| 486 } | 502 } |
| 487 | 503 |
| 488 void SystemTrayClient::UpdateEnterpriseDomain() { | 504 void SystemTrayClient::UpdateEnterpriseDomain() { |
| 489 policy::BrowserPolicyConnectorChromeOS* connector = | 505 policy::BrowserPolicyConnectorChromeOS* connector = |
| 490 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 506 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 491 const std::string enterprise_domain = connector->GetEnterpriseDomain(); | 507 const std::string enterprise_domain = connector->GetEnterpriseDomain(); |
| 492 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); | 508 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); |
| 493 if (enterprise_domain == last_enterprise_domain_ && | 509 if (enterprise_domain == last_enterprise_domain_ && |
| 494 active_directory_managed == last_active_directory_managed_) { | 510 active_directory_managed == last_active_directory_managed_) { |
| 495 return; | 511 return; |
| 496 } | 512 } |
| 497 // Send to ash, which will add an item to the system tray. | 513 // Send to ash, which will add an item to the system tray. |
| 498 system_tray_->SetEnterpriseDomain(enterprise_domain, | 514 system_tray_->SetEnterpriseDomain(enterprise_domain, |
| 499 active_directory_managed); | 515 active_directory_managed); |
| 500 last_enterprise_domain_ = enterprise_domain; | 516 last_enterprise_domain_ = enterprise_domain; |
| 501 last_active_directory_managed_ = active_directory_managed; | 517 last_active_directory_managed_ = active_directory_managed; |
| 502 } | 518 } |
| OLD | NEW |