Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/policy/device_status_collector.h" | 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 27 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
| 28 #include "base/task_runner_util.h" | 28 #include "base/task_runner_util.h" |
| 29 #include "base/threading/sequenced_task_runner_handle.h" | 29 #include "base/threading/sequenced_task_runner_handle.h" |
| 30 #include "base/threading/sequenced_worker_pool.h" | 30 #include "base/threading/sequenced_worker_pool.h" |
| 31 #include "base/values.h" | 31 #include "base/values.h" |
| 32 #include "base/version.h" | 32 #include "base/version.h" |
| 33 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
| 34 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" | |
| 34 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 35 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 35 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 36 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 36 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 37 #include "chrome/browser/chromeos/policy/device_local_account.h" | 38 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 38 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 39 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 39 #include "chrome/browser/chromeos/policy/user_policy_manager_factory_chromeos.h" | 40 #include "chrome/browser/chromeos/policy/user_policy_manager_factory_chromeos.h" |
| 40 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 41 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 41 #include "chrome/browser/chromeos/settings/cros_settings.h" | 42 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 42 #include "chrome/browser/policy/profile_policy_connector.h" | 43 #include "chrome/browser/policy/profile_policy_connector.h" |
| 43 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 44 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 54 #include "chromeos/settings/cros_settings_names.h" | 55 #include "chromeos/settings/cros_settings_names.h" |
| 55 #include "chromeos/system/statistics_provider.h" | 56 #include "chromeos/system/statistics_provider.h" |
| 56 #include "components/arc/arc_bridge_service.h" | 57 #include "components/arc/arc_bridge_service.h" |
| 57 #include "components/arc/arc_service_manager.h" | 58 #include "components/arc/arc_service_manager.h" |
| 58 #include "components/arc/common/enterprise_reporting.mojom.h" | 59 #include "components/arc/common/enterprise_reporting.mojom.h" |
| 59 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 60 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 60 #include "components/policy/proto/device_management_backend.pb.h" | 61 #include "components/policy/proto/device_management_backend.pb.h" |
| 61 #include "components/prefs/pref_registry_simple.h" | 62 #include "components/prefs/pref_registry_simple.h" |
| 62 #include "components/prefs/pref_service.h" | 63 #include "components/prefs/pref_service.h" |
| 63 #include "components/prefs/scoped_user_pref_update.h" | 64 #include "components/prefs/scoped_user_pref_update.h" |
| 65 #include "components/signin/core/account_id/account_id.h" | |
| 64 #include "components/user_manager/user.h" | 66 #include "components/user_manager/user.h" |
| 65 #include "components/user_manager/user_manager.h" | 67 #include "components/user_manager/user_manager.h" |
| 66 #include "components/user_manager/user_type.h" | 68 #include "components/user_manager/user_type.h" |
| 67 #include "components/version_info/version_info.h" | 69 #include "components/version_info/version_info.h" |
| 68 #include "content/public/browser/browser_thread.h" | 70 #include "content/public/browser/browser_thread.h" |
| 69 #include "extensions/browser/extension_registry.h" | 71 #include "extensions/browser/extension_registry.h" |
| 70 #include "extensions/common/extension.h" | 72 #include "extensions/common/extension.h" |
| 71 #include "storage/browser/fileapi/external_mount_points.h" | 73 #include "storage/browser/fileapi/external_mount_points.h" |
| 72 #include "third_party/cros_system_api/dbus/service_constants.h" | 74 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 73 | 75 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 instance->GetStatus(receiver); | 248 instance->GetStatus(receiver); |
| 247 return true; | 249 return true; |
| 248 } | 250 } |
| 249 | 251 |
| 250 // Returns the DeviceLocalAccount associated with the current kiosk session. | 252 // Returns the DeviceLocalAccount associated with the current kiosk session. |
| 251 // Returns null if there is no active kiosk session, or if that kiosk | 253 // Returns null if there is no active kiosk session, or if that kiosk |
| 252 // session has been removed from policy since the session started, in which | 254 // session has been removed from policy since the session started, in which |
| 253 // case we won't report its status). | 255 // case we won't report its status). |
| 254 std::unique_ptr<policy::DeviceLocalAccount> GetCurrentKioskDeviceLocalAccount( | 256 std::unique_ptr<policy::DeviceLocalAccount> GetCurrentKioskDeviceLocalAccount( |
| 255 chromeos::CrosSettings* settings) { | 257 chromeos::CrosSettings* settings) { |
| 256 if (!user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) | 258 if (!user_manager::UserManager::Get()->IsLoggedInAsKioskApp() && |
| 259 !user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp()) | |
|
Luis Héctor Chávez
2017/03/16 19:42:30
nit: you cannot elide the brace here since the con
Ivan Šandrk
2017/03/16 22:32:50
Is there a rule about this in the style guide? I n
| |
| 257 return std::unique_ptr<policy::DeviceLocalAccount>(); | 260 return std::unique_ptr<policy::DeviceLocalAccount>(); |
| 258 const user_manager::User* const user = | 261 const user_manager::User* const user = |
| 259 user_manager::UserManager::Get()->GetActiveUser(); | 262 user_manager::UserManager::Get()->GetActiveUser(); |
| 260 const std::vector<policy::DeviceLocalAccount> accounts = | 263 const std::vector<policy::DeviceLocalAccount> accounts = |
| 261 policy::GetDeviceLocalAccounts(settings); | 264 policy::GetDeviceLocalAccounts(settings); |
| 262 | 265 |
| 263 for (const auto& device_local_account : accounts) { | 266 for (const auto& device_local_account : accounts) { |
| 264 if (AccountId::FromUserEmail(device_local_account.user_id) == | 267 if (AccountId::FromUserEmail(device_local_account.user_id) == |
| 265 user->GetAccountId()) { | 268 user->GetAccountId()) { |
| 266 return base::MakeUnique<policy::DeviceLocalAccount>(device_local_account); | 269 return base::MakeUnique<policy::DeviceLocalAccount>(device_local_account); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 } | 687 } |
| 685 last_idle_check_ = now; | 688 last_idle_check_ = now; |
| 686 } | 689 } |
| 687 | 690 |
| 688 std::unique_ptr<DeviceLocalAccount> | 691 std::unique_ptr<DeviceLocalAccount> |
| 689 DeviceStatusCollector::GetAutoLaunchedKioskSessionInfo() { | 692 DeviceStatusCollector::GetAutoLaunchedKioskSessionInfo() { |
| 690 std::unique_ptr<DeviceLocalAccount> account = | 693 std::unique_ptr<DeviceLocalAccount> account = |
| 691 GetCurrentKioskDeviceLocalAccount(cros_settings_); | 694 GetCurrentKioskDeviceLocalAccount(cros_settings_); |
| 692 if (account) { | 695 if (account) { |
| 693 chromeos::KioskAppManager::App current_app; | 696 chromeos::KioskAppManager::App current_app; |
| 694 if (chromeos::KioskAppManager::Get()->GetApp(account->kiosk_app_id, | 697 auto* arc_kiosk_app_manager = chromeos::ArcKioskAppManager::Get(); |
| 695 ¤t_app) && | 698 const chromeos::ArcKioskAppManager::ArcKioskApp* current_arc_app = |
| 696 current_app.was_auto_launched_with_zero_delay) { | 699 arc_kiosk_app_manager->GetAppByAccountId( |
| 700 AccountId::FromUserEmail(account->user_id)); | |
| 701 if ((chromeos::KioskAppManager::Get()->GetApp(account->kiosk_app_id, | |
| 702 ¤t_app) && | |
| 703 current_app.was_auto_launched_with_zero_delay) || | |
| 704 (current_arc_app && current_arc_app->account_id() == | |
| 705 arc_kiosk_app_manager->GetWasAutoLaunchedWithZeroDelay())) { | |
| 697 return account; | 706 return account; |
| 698 } | 707 } |
| 699 } | 708 } |
| 700 // No auto-launched kiosk session active. | 709 // No auto-launched kiosk session active. |
| 701 return std::unique_ptr<DeviceLocalAccount>(); | 710 return std::unique_ptr<DeviceLocalAccount>(); |
| 702 } | 711 } |
| 703 | 712 |
| 704 void DeviceStatusCollector::SampleResourceUsage() { | 713 void DeviceStatusCollector::SampleResourceUsage() { |
| 705 // Results must be written in the creation thread since that's where they | 714 // Results must be written in the creation thread since that's where they |
| 706 // are read from in the Get*StatusAsync methods. | 715 // are read from in the Get*StatusAsync methods. |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1251 | 1260 |
| 1252 void DeviceStatusCollector::OnOSVersion(const std::string& version) { | 1261 void DeviceStatusCollector::OnOSVersion(const std::string& version) { |
| 1253 os_version_ = version; | 1262 os_version_ = version; |
| 1254 } | 1263 } |
| 1255 | 1264 |
| 1256 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { | 1265 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { |
| 1257 firmware_version_ = version; | 1266 firmware_version_ = version; |
| 1258 } | 1267 } |
| 1259 | 1268 |
| 1260 } // namespace policy | 1269 } // namespace policy |
| OLD | NEW |