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/metrics/user_metrics.h" | 13 #include "base/metrics/user_metrics.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_process_platform_part.h" | 15 #include "chrome/browser/browser_process_platform_part.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 18 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" | 18 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" |
| 19 #include "chrome/browser/chromeos/login/help_app_launcher.h" | |
| 19 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 20 #include "chrome/browser/chromeos/options/network_config_view.h" | 21 #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/device_cloud_policy_manager_chromeos.h" | |
| 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 24 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 22 #include "chrome/browser/chromeos/set_time_dialog.h" | 25 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 23 #include "chrome/browser/chromeos/system/system_clock.h" | 26 #include "chrome/browser/chromeos/system/system_clock.h" |
| 24 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 27 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 25 #include "chrome/browser/lifetime/application_lifetime.h" | 28 #include "chrome/browser/lifetime/application_lifetime.h" |
| 26 #include "chrome/browser/lifetime/termination_notification.h" | 29 #include "chrome/browser/lifetime/termination_notification.h" |
| 27 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 28 #include "chrome/browser/ui/ash/ash_util.h" | 31 #include "chrome/browser/ui/ash/ash_util.h" |
| 29 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 32 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 30 #include "chrome/browser/ui/chrome_pages.h" | 33 #include "chrome/browser/ui/chrome_pages.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 // be queued on |system_tray_|. | 102 // be queued on |system_tray_|. |
| 100 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); | 103 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); |
| 101 | 104 |
| 102 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 105 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 103 content::NotificationService::AllSources()); | 106 content::NotificationService::AllSources()); |
| 104 | 107 |
| 105 // If an upgrade is available at startup then tell ash about it. | 108 // If an upgrade is available at startup then tell ash about it. |
| 106 if (UpgradeDetector::GetInstance()->notify_upgrade()) | 109 if (UpgradeDetector::GetInstance()->notify_upgrade()) |
| 107 HandleUpdateAvailable(); | 110 HandleUpdateAvailable(); |
| 108 | 111 |
| 112 // If the device is enterprise managed then send ash the enterprise domain. | |
| 113 policy::BrowserPolicyConnectorChromeOS* policy_connector = | |
| 114 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 115 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | |
| 116 policy_connector->GetDeviceCloudPolicyManager(); | |
| 117 if (policy_manager) | |
| 118 policy_manager->core()->store()->AddObserver(this); | |
| 119 UpdateEnterpriseDomain(); | |
| 120 | |
| 109 DCHECK(!g_instance); | 121 DCHECK(!g_instance); |
| 110 g_instance = this; | 122 g_instance = this; |
| 111 } | 123 } |
| 112 | 124 |
| 113 SystemTrayClient::~SystemTrayClient() { | 125 SystemTrayClient::~SystemTrayClient() { |
| 114 DCHECK_EQ(this, g_instance); | 126 DCHECK_EQ(this, g_instance); |
| 115 g_instance = nullptr; | 127 g_instance = nullptr; |
| 116 | 128 |
| 129 policy::BrowserPolicyConnectorChromeOS* connector = | |
| 130 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 131 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | |
| 132 connector->GetDeviceCloudPolicyManager(); | |
| 133 if (policy_manager) | |
| 134 policy_manager->core()->store()->RemoveObserver(this); | |
| 135 | |
| 117 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); | 136 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); |
| 118 } | 137 } |
| 119 | 138 |
| 120 // static | 139 // static |
| 121 SystemTrayClient* SystemTrayClient::Get() { | 140 SystemTrayClient* SystemTrayClient::Get() { |
| 122 return g_instance; | 141 return g_instance; |
| 123 } | 142 } |
| 124 | 143 |
| 125 // static | 144 // static |
| 126 ash::LoginStatus SystemTrayClient::GetUserLoginStatus() { | 145 ash::LoginStatus SystemTrayClient::GetUserLoginStatus() { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 base::RecordAction(base::UserMetricsAction("ShowPaletteOptions")); | 317 base::RecordAction(base::UserMetricsAction("ShowPaletteOptions")); |
| 299 ShowSettingsSubPageForActiveUser(chrome::kStylusSubPage); | 318 ShowSettingsSubPageForActiveUser(chrome::kStylusSubPage); |
| 300 } | 319 } |
| 301 | 320 |
| 302 void SystemTrayClient::ShowPublicAccountInfo() { | 321 void SystemTrayClient::ShowPublicAccountInfo() { |
| 303 chrome::ScopedTabbedBrowserDisplayer displayer( | 322 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 304 ProfileManager::GetActiveUserProfile()); | 323 ProfileManager::GetActiveUserProfile()); |
| 305 chrome::ShowPolicy(displayer.browser()); | 324 chrome::ShowPolicy(displayer.browser()); |
| 306 } | 325 } |
| 307 | 326 |
| 327 void SystemTrayClient::ShowEnterpriseInfo() { | |
| 328 // At the login screen, lock screen, etc. show enterprise help in a window. | |
| 329 if (session_manager::SessionManager::Get()->IsUserSessionBlocked()) { | |
|
James Cook
2017/04/26 18:49:36
This is slightly different, but I think closer to
xiyuan
2017/04/26 19:55:13
Acknowledged.
| |
| 330 scoped_refptr<chromeos::HelpAppLauncher> help_app( | |
| 331 new chromeos::HelpAppLauncher(nullptr /* parent_window */)); | |
| 332 help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE); | |
| 333 return; | |
| 334 } | |
| 335 | |
| 336 // Otherwise show enterprise help in a browser tab. | |
| 337 chrome::ScopedTabbedBrowserDisplayer displayer( | |
| 338 ProfileManager::GetActiveUserProfile()); | |
| 339 chrome::ShowSingletonTab(displayer.browser(), | |
| 340 GURL(chrome::kLearnMoreEnterpriseURL)); | |
| 341 } | |
| 342 | |
| 308 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { | 343 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { |
| 309 // UI is not available at the lock screen. | 344 // UI is not available at the lock screen. |
| 310 if (session_manager::SessionManager::Get()->IsScreenLocked()) | 345 if (session_manager::SessionManager::Get()->IsScreenLocked()) |
| 311 return; | 346 return; |
| 312 | 347 |
| 313 // Dialog will default to the primary display. | 348 // Dialog will default to the primary display. |
| 314 chromeos::NetworkConfigView::ShowForNetworkId(network_id, | 349 chromeos::NetworkConfigView::ShowForNetworkId(network_id, |
| 315 nullptr /* parent */); | 350 nullptr /* parent */); |
| 316 } | 351 } |
| 317 | 352 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 chromeos::system::SystemClock* clock) { | 445 chromeos::system::SystemClock* clock) { |
| 411 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 446 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
| 412 } | 447 } |
| 413 | 448 |
| 414 void SystemTrayClient::Observe(int type, | 449 void SystemTrayClient::Observe(int type, |
| 415 const content::NotificationSource& source, | 450 const content::NotificationSource& source, |
| 416 const content::NotificationDetails& details) { | 451 const content::NotificationDetails& details) { |
| 417 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); | 452 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); |
| 418 HandleUpdateAvailable(); | 453 HandleUpdateAvailable(); |
| 419 } | 454 } |
| 455 | |
| 456 //////////////////////////////////////////////////////////////////////////////// | |
| 457 // policy::CloudPolicyStore::Observer | |
| 458 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { | |
| 459 UpdateEnterpriseDomain(); | |
| 460 } | |
| 461 | |
| 462 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { | |
| 463 UpdateEnterpriseDomain(); | |
| 464 } | |
| 465 | |
| 466 void SystemTrayClient::UpdateEnterpriseDomain() { | |
| 467 policy::BrowserPolicyConnectorChromeOS* connector = | |
| 468 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 469 const std::string enterprise_domain = connector->GetEnterpriseDomain(); | |
| 470 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); | |
| 471 if (enterprise_domain == last_enterprise_domain_ && | |
| 472 active_directory_managed == last_active_directory_managed_) { | |
| 473 return; | |
| 474 } | |
| 475 // Send to ash, which will add an item to the system tray. | |
| 476 system_tray_->SetEnterpriseDomain(enterprise_domain, | |
| 477 active_directory_managed); | |
| 478 last_enterprise_domain_ = enterprise_domain; | |
| 479 last_active_directory_managed_ = active_directory_managed; | |
| 480 } | |
| OLD | NEW |