| Index: chrome/browser/chromeos/extensions/info_private_api.cc
|
| diff --git a/chrome/browser/chromeos/extensions/info_private_api.cc b/chrome/browser/chromeos/extensions/info_private_api.cc
|
| index 28aa50fb73aae9d6683caead61be0da6d3a50c7d..29bd74e2387dafa036aa085ba42a4ce3aa4386e8 100644
|
| --- a/chrome/browser/chromeos/extensions/info_private_api.cc
|
| +++ b/chrome/browser/chromeos/extensions/info_private_api.cc
|
| @@ -8,6 +8,7 @@
|
|
|
| #include <utility>
|
|
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/sys_info.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/app_mode/app_mode_utils.h"
|
| @@ -228,23 +229,23 @@ bool ChromeosInfoPrivateGetFunction::RunAsync() {
|
| for (size_t i = 0; i < list->GetSize(); ++i) {
|
| std::string property_name;
|
| EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name));
|
| - base::Value* value = GetValue(property_name);
|
| + std::unique_ptr<base::Value> value = GetValue(property_name);
|
| if (value)
|
| - result->Set(property_name, value);
|
| + result->Set(property_name, std::move(value));
|
| }
|
| SetResult(std::move(result));
|
| SendResponse(true);
|
| return true;
|
| }
|
|
|
| -base::Value* ChromeosInfoPrivateGetFunction::GetValue(
|
| +std::unique_ptr<base::Value> ChromeosInfoPrivateGetFunction::GetValue(
|
| const std::string& property_name) {
|
| if (property_name == kPropertyHWID) {
|
| std::string hwid;
|
| chromeos::system::StatisticsProvider* provider =
|
| chromeos::system::StatisticsProvider::GetInstance();
|
| provider->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid);
|
| - return new base::Value(hwid);
|
| + return base::MakeUnique<base::Value>(hwid);
|
| }
|
|
|
| if (property_name == kPropertyCustomizationID) {
|
| @@ -253,7 +254,7 @@ base::Value* ChromeosInfoPrivateGetFunction::GetValue(
|
| chromeos::system::StatisticsProvider::GetInstance();
|
| provider->GetMachineStatistic(chromeos::system::kCustomizationIdKey,
|
| &customization_id);
|
| - return new base::Value(customization_id);
|
| + return base::MakeUnique<base::Value>(customization_id);
|
| }
|
|
|
| if (property_name == kPropertyHomeProvider) {
|
| @@ -263,86 +264,91 @@ base::Value* ChromeosInfoPrivateGetFunction::GetValue(
|
| std::string home_provider_id;
|
| if (cellular_device)
|
| home_provider_id = cellular_device->home_provider_id();
|
| - return new base::Value(home_provider_id);
|
| + return base::MakeUnique<base::Value>(home_provider_id);
|
| }
|
|
|
| if (property_name == kPropertyInitialLocale) {
|
| - return new base::Value(chromeos::StartupUtils::GetInitialLocale());
|
| + return base::MakeUnique<base::Value>(
|
| + chromeos::StartupUtils::GetInitialLocale());
|
| }
|
|
|
| if (property_name == kPropertyBoard) {
|
| - return new base::Value(base::SysInfo::GetLsbReleaseBoard());
|
| + return base::MakeUnique<base::Value>(base::SysInfo::GetLsbReleaseBoard());
|
| }
|
|
|
| if (property_name == kPropertyOwner) {
|
| - return new base::Value(
|
| + return base::MakeUnique<base::Value>(
|
| user_manager::UserManager::Get()->IsCurrentUserOwner());
|
| }
|
|
|
| if (property_name == kPropertySessionType) {
|
| if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode())
|
| - return new base::Value(kSessionTypeKiosk);
|
| + return base::MakeUnique<base::Value>(kSessionTypeKiosk);
|
| if (ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount())
|
| - return new base::Value(kSessionTypePublicSession);
|
| - return new base::Value(kSessionTypeNormal);
|
| + return base::MakeUnique<base::Value>(kSessionTypePublicSession);
|
| + return base::MakeUnique<base::Value>(kSessionTypeNormal);
|
| }
|
|
|
| if (property_name == kPropertyPlayStoreStatus) {
|
| if (arc::IsArcAllowedForProfile(Profile::FromBrowserContext(context_)))
|
| - return new base::Value(kPlayStoreStatusEnabled);
|
| + return base::MakeUnique<base::Value>(kPlayStoreStatusEnabled);
|
| if (arc::IsArcAvailable())
|
| - return new base::Value(kPlayStoreStatusAvailable);
|
| - return new base::Value(kPlayStoreStatusNotAvailable);
|
| + return base::MakeUnique<base::Value>(kPlayStoreStatusAvailable);
|
| + return base::MakeUnique<base::Value>(kPlayStoreStatusNotAvailable);
|
| }
|
|
|
| if (property_name == kPropertyManagedDeviceStatus) {
|
| policy::BrowserPolicyConnectorChromeOS* connector =
|
| g_browser_process->platform_part()->browser_policy_connector_chromeos();
|
| if (connector->IsEnterpriseManaged()) {
|
| - return new base::Value(kManagedDeviceStatusManaged);
|
| + return base::MakeUnique<base::Value>(kManagedDeviceStatusManaged);
|
| }
|
| - return new base::Value(kManagedDeviceStatusNotManaged);
|
| + return base::MakeUnique<base::Value>(kManagedDeviceStatusNotManaged);
|
| }
|
|
|
| if (property_name == kPropertyDeviceType) {
|
| switch (chromeos::GetDeviceType()) {
|
| case chromeos::DeviceType::kChromebox:
|
| - return new base::Value(kDeviceTypeChromebox);
|
| + return base::MakeUnique<base::Value>(kDeviceTypeChromebox);
|
| case chromeos::DeviceType::kChromebase:
|
| - return new base::Value(kDeviceTypeChromebase);
|
| + return base::MakeUnique<base::Value>(kDeviceTypeChromebase);
|
| case chromeos::DeviceType::kChromebit:
|
| - return new base::Value(kDeviceTypeChromebit);
|
| + return base::MakeUnique<base::Value>(kDeviceTypeChromebit);
|
| case chromeos::DeviceType::kChromebook:
|
| - return new base::Value(kDeviceTypeChromebook);
|
| + return base::MakeUnique<base::Value>(kDeviceTypeChromebook);
|
| default:
|
| - return new base::Value(kDeviceTypeChromedevice);
|
| + return base::MakeUnique<base::Value>(kDeviceTypeChromedevice);
|
| }
|
| }
|
|
|
| if (property_name == kPropertyClientId) {
|
| - return new base::Value(GetClientId());
|
| + return base::MakeUnique<base::Value>(GetClientId());
|
| }
|
|
|
| if (property_name == kPropertyTimezone) {
|
| - return chromeos::CrosSettings::Get()->GetPref(
|
| - chromeos::kSystemTimezone)->DeepCopy();
|
| + // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr.
|
| + return base::WrapUnique<base::Value>(
|
| + chromeos::CrosSettings::Get()
|
| + ->GetPref(chromeos::kSystemTimezone)
|
| + ->DeepCopy());
|
| }
|
|
|
| if (property_name == kPropertySupportedTimezones) {
|
| std::unique_ptr<base::ListValue> values =
|
| chromeos::system::GetTimezoneList();
|
| - return values.release();
|
| + // TODO(crbug.com/703565): remove std::move() once Xcode 9.0+ is required.
|
| + return std::move(values);
|
| }
|
|
|
| const char* pref_name = GetBoolPrefNameForApiProperty(property_name.c_str());
|
| if (pref_name) {
|
| - return new base::Value(
|
| + return base::MakeUnique<base::Value>(
|
| Profile::FromBrowserContext(context_)->GetPrefs()->GetBoolean(
|
| pref_name));
|
| }
|
|
|
| DLOG(ERROR) << "Unknown property request: " << property_name;
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| ChromeosInfoPrivateSetFunction::ChromeosInfoPrivateSetFunction() {
|
|
|