Chromium Code Reviews| Index: chrome/browser/chromeos/policy/device_status_collector.cc |
| diff --git a/chrome/browser/chromeos/policy/device_status_collector.cc b/chrome/browser/chromeos/policy/device_status_collector.cc |
| index 2c31a3a157c65563f00e756a847f8be90da87c2f..de1319ebc996c9a3687ff6e37aa4da316c7aebfd 100644 |
| --- a/chrome/browser/chromeos/policy/device_status_collector.cc |
| +++ b/chrome/browser/chromeos/policy/device_status_collector.cc |
| @@ -23,6 +23,9 @@ |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/chrome_version_info.h" |
| #include "chrome/common/pref_names.h" |
| +#include "chromeos/network/device_state.h" |
| +#include "chromeos/network/network_handler.h" |
| +#include "chromeos/network/network_state_handler.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/notification_details.h" |
| #include "content/public/browser/notification_source.h" |
| @@ -134,6 +137,7 @@ DeviceStatusCollector::DeviceStatusCollector( |
| report_activity_times_(false), |
| report_boot_mode_(false), |
| report_location_(false), |
| + report_network_interfaces_(false), |
| context_(new Context()) { |
| if (location_update_requester) { |
| location_update_requester_ = *location_update_requester; |
| @@ -154,6 +158,8 @@ DeviceStatusCollector::DeviceStatusCollector( |
| this); |
| cros_settings_->AddSettingsObserver(chromeos::kReportDeviceBootMode, this); |
| cros_settings_->AddSettingsObserver(chromeos::kReportDeviceLocation, this); |
| + cros_settings_->AddSettingsObserver(chromeos::kReportDeviceNetworkInterfaces, |
| + this); |
| // The last known location is persisted in local state. This makes location |
| // information available immediately upon startup and avoids the need to |
| @@ -196,6 +202,8 @@ DeviceStatusCollector::~DeviceStatusCollector() { |
| this); |
| cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceBootMode, this); |
| cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceLocation, this); |
| + cros_settings_->RemoveSettingsObserver( |
| + chromeos::kReportDeviceNetworkInterfaces, this); |
| } |
| // static |
| @@ -230,6 +238,8 @@ void DeviceStatusCollector::UpdateReportingSettings() { |
| chromeos::kReportDeviceBootMode, &report_boot_mode_); |
| cros_settings_->GetBoolean( |
| chromeos::kReportDeviceLocation, &report_location_); |
| + cros_settings_->GetBoolean( |
| + chromeos::kReportDeviceNetworkInterfaces, &report_network_interfaces_); |
| if (report_location_) { |
| ScheduleGeolocationUpdateRequest(); |
| @@ -405,6 +415,26 @@ void DeviceStatusCollector::GetLocation( |
| } |
| } |
| +void DeviceStatusCollector::GetNetworkInterfaces( |
| + em::DeviceStatusReportRequest* request) { |
| + chromeos::NetworkStateHandler::DeviceStateList device_list; |
| + chromeos::NetworkHandler::Get()->network_state_handler()->GetDeviceList( |
| + &device_list); |
| + |
| + chromeos::NetworkStateHandler::DeviceStateList::const_iterator device; |
|
pneubeck (no reviews)
2013/07/04 15:51:48
nit:
alternatively, typedef chromeos::NetworkState
Mattias Nissler (ping if slow)
2013/07/11 17:41:46
I only need the type once, and I'd have to break t
pneubeck (no reviews)
2013/07/11 18:49:31
FWIW, chromeos::NetworkStateHandler::DeviceStateLi
Mattias Nissler (ping if slow)
2013/07/12 08:11:55
Oh right, I misread your comment to typedef the it
|
| + for (device = device_list.begin(); device != device_list.end(); ++device) { |
| + em::NetworkInterface* interface = request->add_network_interface(); |
| + if ((*device)->type().empty()) |
| + continue; |
|
pneubeck (no reviews)
2013/07/04 15:51:48
in this case, an empty NetworkInterface would have
Mattias Nissler (ping if slow)
2013/07/11 17:41:46
I don't think so, hence I skip this case. The upda
|
| + |
| + interface->set_type((*device)->type()); |
| + if (!(*device)->mac_address().empty()) |
| + interface->set_mac_address((*device)->mac_address()); |
| + if (!(*device)->meid().empty()) |
| + interface->set_meid((*device)->meid()); |
| + } |
| +} |
| + |
| void DeviceStatusCollector::GetStatus(em::DeviceStatusReportRequest* request) { |
| // TODO(mnissler): Remove once the old cloud policy stack is retired. The old |
| // stack doesn't support reporting successful submissions back to here, so |
| @@ -427,6 +457,9 @@ bool DeviceStatusCollector::GetDeviceStatus( |
| if (report_location_) |
| GetLocation(status); |
| + if (report_network_interfaces_) |
| + GetNetworkInterfaces(status); |
| + |
| return true; |
| } |