diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 865f2c3032416b..4f3713a796278d 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3495,6 +3495,9 @@ are declared in tools/grit/grit_rule.gni.
Access document scanners attached via USB or on the local network
+
+ Read the manufacturer and model of this computer
+
Read the icons of the websites you visit
diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn
index 614f27924e7778..f25d5aafd709a5 100644
--- a/chrome/browser/extensions/BUILD.gn
+++ b/chrome/browser/extensions/BUILD.gn
@@ -160,6 +160,8 @@ jumbo_static_library("extensions") {
"api/downloads/downloads_api.h",
"api/downloads_internal/downloads_internal_api.cc",
"api/downloads_internal/downloads_internal_api.h",
+ "api/enterprise_hardware_platform/enterprise_hardware_platform_api.cc",
+ "api/enterprise_hardware_platform/enterprise_hardware_platform_api.h",
"api/extension_action/extension_action_api.cc",
"api/extension_action/extension_action_api.h",
"api/extension_action/extension_page_actions_api_constants.cc",
diff --git a/chrome/browser/extensions/api/enterprise_hardware_platform/OWNERS b/chrome/browser/extensions/api/enterprise_hardware_platform/OWNERS
new file mode 100644
index 00000000000000..05cb9bd3c026ef
--- /dev/null
+++ b/chrome/browser/extensions/api/enterprise_hardware_platform/OWNERS
@@ -0,0 +1 @@
+guidou@chromium.org
diff --git a/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.cc b/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.cc
new file mode 100644
index 00000000000000..3a75d928dd4891
--- /dev/null
+++ b/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.cc
@@ -0,0 +1,38 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.h"
+
+#include
+
+#include "base/bind.h"
+#include "chrome/common/extensions/api/enterprise_hardware_platform.h"
+
+namespace extensions {
+
+EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction::
+ EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction() = default;
+
+EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction::
+ ~EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction() = default;
+
+ExtensionFunction::ResponseAction
+EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction::Run() {
+ base::SysInfo::GetHardwareInfo(base::BindOnce(
+ &EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction::
+ OnHardwarePlatformInfo,
+ this));
+ return RespondLater();
+}
+
+void EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction::
+ OnHardwarePlatformInfo(base::SysInfo::HardwareInfo info) {
+ api::enterprise_hardware_platform::HardwarePlatformInfo result;
+ result.manufacturer = std::move(info.manufacturer);
+ result.model = std::move(info.model);
+ Respond(ArgumentList(api::enterprise_hardware_platform::
+ GetHardwarePlatformInfo::Results::Create(result)));
+}
+
+} // namespace extensions
diff --git a/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.h b/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.h
new file mode 100644
index 00000000000000..70726063ac1588
--- /dev/null
+++ b/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.h
@@ -0,0 +1,37 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_HARDWARE_PLATFORM_ENTERPRISE_HARDWARE_PLATFORM_API_H_
+#define CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_HARDWARE_PLATFORM_ENTERPRISE_HARDWARE_PLATFORM_API_H_
+
+#include "base/macros.h"
+#include "base/sys_info.h"
+#include "extensions/browser/extension_function.h"
+
+namespace extensions {
+
+class EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction
+ : public UIThreadExtensionFunction {
+ public:
+ EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction();
+
+ protected:
+ ~EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction() override;
+
+ ResponseAction Run() override;
+
+ private:
+ DECLARE_EXTENSION_FUNCTION(
+ "enterprise.hardwarePlatform.getHardwarePlatformInfo",
+ ENTERPRISE_HARDWAREPLATFORM_GETHARDWAREPLATFORMINFO);
+
+ void OnHardwarePlatformInfo(base::SysInfo::HardwareInfo info);
+
+ DISALLOW_COPY_AND_ASSIGN(
+ EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_HARDWARE_PLATFORM_ENTERPRISE_HARDWARE_PLATFORM_API_H_
diff --git a/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api_unittest.cc b/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api_unittest.cc
new file mode 100644
index 00000000000000..285c63683a1128
--- /dev/null
+++ b/chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api_unittest.cc
@@ -0,0 +1,84 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.h"
+
+#include
+#include
+
+#include "base/json/json_writer.h"
+#include "chrome/browser/extensions/extension_api_unittest.h"
+#include "chrome/browser/extensions/extension_function_test_utils.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_service_test_with_install.h"
+#include "components/crx_file/id_util.h"
+#include "extensions/common/extension_builder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+
+class EnterpriseHardwarePlatformAPITest
+ : public ExtensionServiceTestWithInstall {
+ public:
+ EnterpriseHardwarePlatformAPITest() = default;
+ ~EnterpriseHardwarePlatformAPITest() override = default;
+ Browser* browser() { return browser_.get(); }
+
+ private:
+ void SetUp() override {
+ ExtensionServiceTestWithInstall::SetUp();
+ InitializeEmptyExtensionService();
+ browser_window_ = std::make_unique();
+ Browser::CreateParams params(profile(), true);
+ params.type = Browser::TYPE_TABBED;
+ params.window = browser_window_.get();
+ browser_ = std::make_unique(params);
+ }
+
+ void TearDown() override {
+ browser_.reset();
+ browser_window_.reset();
+ ExtensionServiceTestWithInstall::TearDown();
+ }
+
+ std::unique_ptr browser_window_;
+ std::unique_ptr browser_;
+
+ DISALLOW_COPY_AND_ASSIGN(EnterpriseHardwarePlatformAPITest);
+};
+
+TEST_F(EnterpriseHardwarePlatformAPITest, GetHardwarePlatformInfo) {
+ scoped_refptr extension = ExtensionBuilder("Test").Build();
+ scoped_refptr
+ function =
+ new EnterpriseHardwarePlatformGetHardwarePlatformInfoFunction();
+ function->set_extension(extension.get());
+ function->set_has_callback(true);
+
+ std::string args;
+ base::JSONWriter::Write(base::ListValue(), &args);
+
+ std::unique_ptr result(
+ extension_function_test_utils::RunFunctionAndReturnSingleResult(
+ function.get(), args, browser()));
+ base::RunLoop().RunUntilIdle();
+
+ ASSERT_TRUE(result);
+ ASSERT_TRUE(result->is_dict());
+ ASSERT_EQ(result->DictSize(), 2u);
+
+ const base::Value* val =
+ result->FindKeyOfType("manufacturer", base::Value::Type::STRING);
+ ASSERT_TRUE(val);
+ const std::string& manufacturer = val->GetString();
+
+ val = result->FindKeyOfType("model", base::Value::Type::STRING);
+ ASSERT_TRUE(val);
+ const std::string& model = val->GetString();
+
+ EXPECT_FALSE(manufacturer.empty());
+ EXPECT_FALSE(model.empty());
+}
+
+} // namespace extensions
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 931689042da529..c23d625b063d43 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -372,6 +372,10 @@
"dependencies": ["permission:echoPrivate"],
"contexts": ["blessed_extension"]
},
+ "enterprise.hardwarePlatform": {
+ "dependencies": ["permission:enterprise.hardwarePlatform"],
+ "contexts": ["blessed_extension"]
+ },
"enterprise.deviceAttributes": {
"dependencies": ["permission:enterprise.deviceAttributes"],
"contexts": ["blessed_extension"]
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
index 8da1ccc1587669..345e58da02218f 100644
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
@@ -292,6 +292,11 @@
"extension_types": ["extension", "platform_app"],
"location": "policy"
},
+ "enterprise.hardwarePlatform": {
+ "channel": "canary",
+ "extension_types": ["extension"],
+ "location": "policy"
+ },
"enterprise.platformKeys": [{
"channel": "stable",
"platforms": ["chromeos"],
diff --git a/chrome/common/extensions/api/api_sources.gni b/chrome/common/extensions/api/api_sources.gni
index ea34622b0a6f94..a26827fa30d6fe 100644
--- a/chrome/common/extensions/api/api_sources.gni
+++ b/chrome/common/extensions/api/api_sources.gni
@@ -37,6 +37,7 @@ schema_sources_ = [
"developer_private.idl",
"downloads.idl",
"downloads_internal.idl",
+ "enterprise_hardware_platform.idl",
"font_settings.json",
"gcm.json",
"history.json",
diff --git a/chrome/common/extensions/api/enterprise_hardware_platform.idl b/chrome/common/extensions/api/enterprise_hardware_platform.idl
new file mode 100644
index 00000000000000..9c5504c7254b6f
--- /dev/null
+++ b/chrome/common/extensions/api/enterprise_hardware_platform.idl
@@ -0,0 +1,23 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Use the chrome.enterprise.hardwarePlatform
API to get the
+// manufacturer and model of the hardware platform where the browser runs.
+// Note: This API is only available to extensions installed by enterprise
+// policy.
+namespace enterprise.hardwarePlatform {
+ dictionary HardwarePlatformInfo {
+ DOMString model;
+ DOMString manufacturer;
+ };
+
+ callback HardwarePlatformInfoCallback = void(HardwarePlatformInfo info);
+
+ interface Functions {
+ // Obtains the manufacturer and model for the hardware platform and, if
+ // the extension is authorized, returns it via |callback|.
+ // |callback|: Called with the hardware platform info.
+ static void getHardwarePlatformInfo(HardwarePlatformInfoCallback callback);
+ };
+};
diff --git a/chrome/common/extensions/permissions/chrome_api_permissions.cc b/chrome/common/extensions/permissions/chrome_api_permissions.cc
index 83af3c749cfbd9..85f9ea1a6f05b5 100644
--- a/chrome/common/extensions/permissions/chrome_api_permissions.cc
+++ b/chrome/common/extensions/permissions/chrome_api_permissions.cc
@@ -74,6 +74,8 @@ ChromeAPIPermissions::GetAllPermissions() const {
APIPermissionInfo::kFlagCannotBeOptional},
{APIPermission::kEnterpriseDeviceAttributes,
"enterprise.deviceAttributes"},
+ {APIPermission::kEnterpriseHardwarePlatform,
+ "enterprise.hardwarePlatform"},
{APIPermission::kEnterprisePlatformKeys, "enterprise.platformKeys"},
{APIPermission::kFileBrowserHandler, "fileBrowserHandler",
APIPermissionInfo::kFlagCannotBeOptional},
diff --git a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc
index 96302805ee71d2..9f3471a24cd5d1 100644
--- a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc
+++ b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc
@@ -639,6 +639,9 @@ ChromePermissionMessageRule::GetAllRules() {
{IDS_EXTENSION_PROMPT_WARNING_DISPLAY_SOURCE,
{APIPermission::kDisplaySource},
{}},
+ {IDS_EXTENSION_PROMPT_WARNING_ENTERPRISE_HARDWARE_PLATFORM,
+ {APIPermission::kEnterpriseHardwarePlatform},
+ {}},
};
return std::vector(
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index 5c807e0547f282..5ce498bab7058c 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -3511,6 +3511,7 @@ test("unit_tests") {
"../browser/extensions/api/developer_private/extension_info_generator_unittest.cc",
"../browser/extensions/api/device_permissions_manager_unittest.cc",
"../browser/extensions/api/downloads/downloads_api_unittest.cc",
+ "../browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api_unittest.cc",
"../browser/extensions/api/extension_action/browser_action_unittest.cc",
"../browser/extensions/api/extension_action/extension_action_prefs_unittest.cc",
"../browser/extensions/api/file_system/file_system_api_unittest.cc",
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h
index 13c9bb686b26a3..bdecc6bbc6acd4 100644
--- a/extensions/browser/extension_function_histogram_value.h
+++ b/extensions/browser/extension_function_histogram_value.h
@@ -1331,6 +1331,7 @@ enum HistogramValue {
AUTOFILLPRIVATE_MIGRATECREDITCARDS = 1268,
AUTOTESTPRIVATE_ISAPPSHOWN = 1269,
ENTERPRISEREPORTINGPRIVATE_GETDEVICEID = 1270,
+ ENTERPRISE_HARDWAREPLATFORM_GETHARDWAREPLATFORMINFO = 1271,
// Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY
diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h
index 8281f3f860e2ed..05e1d7422a4f1c 100644
--- a/extensions/common/permissions/api_permission.h
+++ b/extensions/common/permissions/api_permission.h
@@ -197,7 +197,7 @@ class APIPermission {
kWallpaper = 153,
kWallpaperPrivate = 154,
kWebcamPrivate = 155,
- kWebConnectable = 156, // for externally_connectable manifest key
+ kWebConnectable = 156, // for externally_connectable manifest key
kWebNavigation = 157,
kWebRequest = 158,
kWebRequestBlocking = 159,
@@ -257,6 +257,7 @@ class APIPermission {
kFileSystemRequestDownloads = 213,
kSystemPowerSource = 214,
kArcAppsPrivate = 215,
+ kEnterpriseHardwarePlatform = 216,
// Last entry: Add new entries above and ensure to update the
// "ExtensionPermission3" enum in tools/metrics/histograms/histograms.xml
// (by running update_extension_permission.py).
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 2090aa39300f9c..f0fd77546597d1 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -16582,6 +16582,8 @@ Called by update_net_error_codes.py.-->
+
@@ -17028,6 +17030,7 @@ Called by update_net_error_codes.py.-->
+