Commit a266e218 authored by Alexander Hendrich's avatar Alexander Hendrich Committed by Commit Bot

Add new enterprise.networkingAttributes API

This CL adds a new API to read the device's local IP and MAC address
if it is connected to a network. This API is only available to
force-installed extensions in an affiliated context.

Bug: 1081333
Change-Id: I5d8cb5f20b8dfabf8be503b99ac264a8ea6b03b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2197117
Commit-Queue: Alexander Hendrich <hendrich@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779264}
parent 605f5dc8
...@@ -949,6 +949,8 @@ static_library("extensions") { ...@@ -949,6 +949,8 @@ static_library("extensions") {
"api/certificate_provider/certificate_provider_api.h", "api/certificate_provider/certificate_provider_api.h",
"api/enterprise_device_attributes/enterprise_device_attributes_api.cc", "api/enterprise_device_attributes/enterprise_device_attributes_api.cc",
"api/enterprise_device_attributes/enterprise_device_attributes_api.h", "api/enterprise_device_attributes/enterprise_device_attributes_api.h",
"api/enterprise_networking_attributes/enterprise_networking_attributes_api.cc",
"api/enterprise_networking_attributes/enterprise_networking_attributes_api.h",
"api/enterprise_platform_keys/enterprise_platform_keys_api.cc", "api/enterprise_platform_keys/enterprise_platform_keys_api.cc",
"api/enterprise_platform_keys/enterprise_platform_keys_api.h", "api/enterprise_platform_keys/enterprise_platform_keys_api.h",
"api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc", "api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc",
......
// Copyright 2020 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_networking_attributes/enterprise_networking_attributes_api.h"
#include "base/values.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/enterprise_networking_attributes.h"
#include "chromeos/network/device_state.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_util.h"
#include "components/user_manager/user.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
namespace extensions {
namespace {
const char kErrorUserNotAffiliated[] =
"Network attributes can only be read by an affiliated user.";
const char kErrorNetworkNotConnected[] =
"Device is not connected to a network.";
// Checks for the current browser context if the user is affiliated or belongs
// to the sign-in profile.
bool CanGetNetworkAttributesForBrowserContext(
content::BrowserContext* context) {
const Profile* profile = Profile::FromBrowserContext(context);
if (chromeos::ProfileHelper::IsSigninProfile(profile))
return true;
if (!profile->IsRegularProfile())
return false;
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
return user->IsAffiliated();
}
} // namespace
EnterpriseNetworkingAttributesGetNetworkDetailsFunction::
EnterpriseNetworkingAttributesGetNetworkDetailsFunction() = default;
EnterpriseNetworkingAttributesGetNetworkDetailsFunction::
~EnterpriseNetworkingAttributesGetNetworkDetailsFunction() = default;
ExtensionFunction::ResponseAction
EnterpriseNetworkingAttributesGetNetworkDetailsFunction::Run() {
if (!CanGetNetworkAttributesForBrowserContext(browser_context())) {
return RespondNow(Error(kErrorUserNotAffiliated));
}
chromeos::NetworkStateHandler* network_state_handler =
chromeos::NetworkHandler::Get()->network_state_handler();
const chromeos::NetworkState* network =
network_state_handler->DefaultNetwork();
if (!network) {
// Not connected to a network.
return RespondNow(Error(kErrorNetworkNotConnected));
}
const chromeos::DeviceState* device =
network_state_handler->GetDeviceState(network->device_path());
if (!device) {
return RespondNow(Error(kErrorNetworkNotConnected));
}
const std::string mac_address =
chromeos::network_util::FormattedMacAddress(device->mac_address());
const std::string ipv4_address = device->GetIpAddressByType(shill::kTypeIPv4);
const std::string ipv6_address = device->GetIpAddressByType(shill::kTypeIPv6);
api::enterprise_networking_attributes::NetworkDetails details;
details.mac_address = mac_address;
if (!ipv4_address.empty()) {
details.ipv4 = std::make_unique<std::string>(ipv4_address);
}
if (!ipv6_address.empty()) {
details.ipv6 = std::make_unique<std::string>(ipv6_address);
}
return RespondNow(OneArgument(details.ToValue()));
}
} // namespace extensions
// Copyright 2020 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_NETWORKING_ATTRIBUTES_ENTERPRISE_NETWORKING_ATTRIBUTES_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_NETWORKING_ATTRIBUTES_ENTERPRISE_NETWORKING_ATTRIBUTES_API_H_
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_function_histogram_value.h"
namespace extensions {
class EnterpriseNetworkingAttributesGetNetworkDetailsFunction
: public ExtensionFunction {
public:
EnterpriseNetworkingAttributesGetNetworkDetailsFunction();
protected:
~EnterpriseNetworkingAttributesGetNetworkDetailsFunction() override;
ResponseAction Run() override;
private:
DECLARE_EXTENSION_FUNCTION(
"enterprise.networkingAttributes.getNetworkDetails",
ENTERPRISE_NETWORKINGATTRIBUTES_GETNETWORKDETAILS)
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_ENTERPRISE_NETWORKING_ATTRIBUTES_ENTERPRISE_NETWORKING_ATTRIBUTES_API_H_
// Copyright 2020 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 <memory>
#include <string>
#include "base/values.h"
#include "chrome/browser/chromeos/policy/affiliation_test_helper.h"
#include "chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chromeos/dbus/shill/shill_device_client.h"
#include "chromeos/dbus/shill/shill_ipconfig_client.h"
#include "chromeos/dbus/shill/shill_profile_client.h"
#include "chromeos/dbus/shill/shill_service_client.h"
#include "content/public/test/browser_test.h"
#include "url/gurl.h"
namespace {
const char kErrorUserNotAffiliated[] =
"Network attributes can only be read by an affiliated user.";
const char kErrorNetworkNotConnected[] =
"Device is not connected to a network.";
constexpr char kTestExtensionID[] = "pkhdjpcjgonhlomdjmnddhbfpgkdhgle";
constexpr char kUpdateManifestPath[] =
"/extensions/api_test/enterprise_networking_attributes/update_manifest.xml";
constexpr char kMacAddress[] = "0123456789AB";
constexpr char kFormattedMacAddress[] = "01:23:45:67:89:AB";
constexpr char kIpv4Address[] = "192.168.0.42";
constexpr char kIpv6Address[] = "fe80::1262:d0ff:fef5:e8a9";
constexpr char kWifiDevicePath[] = "/device/stub_wifi";
constexpr char kWifiServicePath[] = "/service/stub_wifi";
constexpr char kWifiIPConfigV4Path[] = "/ipconfig/stub_wifi-ipv4";
constexpr char kWifiIPConfigV6Path[] = "/ipconfig/stub_wifi-ipv6";
base::Value BuildCustomArgForSuccess(const std::string& expected_mac_address,
const std::string& expected_ipv4_address,
const std::string& expected_ipv6_address) {
base::Value network_details(base::Value::Type::DICTIONARY);
network_details.SetKey("macAddress", base::Value(expected_mac_address));
network_details.SetKey("ipv4", base::Value(expected_ipv4_address));
network_details.SetKey("ipv6", base::Value(expected_ipv6_address));
base::Value custom_arg(base::Value::Type::DICTIONARY);
custom_arg.SetKey("testName", base::Value("success"));
custom_arg.SetKey("expectedResult", std::move(network_details));
return custom_arg;
}
base::Value BuildCustomArgForFailure(
const std::string& expected_error_message) {
base::Value custom_arg(base::Value::Type::DICTIONARY);
custom_arg.SetKey("testName", base::Value("failure"));
custom_arg.SetKey("expectedErrorMessage",
base::Value(expected_error_message));
return custom_arg;
}
} // namespace
namespace extensions {
class EnterpriseNetworkingAttributesTest
: public ForceInstalledAffiliatedExtensionApiTest,
public ::testing::WithParamInterface<bool> {
public:
EnterpriseNetworkingAttributesTest()
: ForceInstalledAffiliatedExtensionApiTest(GetParam()) {}
void SetupDisconnectedNetwork() {
chromeos::ShillDeviceClient::TestInterface* shill_device_client =
chromeos::DBusThreadManager::Get()
->GetShillDeviceClient()
->GetTestInterface();
chromeos::ShillIPConfigClient::TestInterface* shill_ipconfig_client =
chromeos::DBusThreadManager::Get()
->GetShillIPConfigClient()
->GetTestInterface();
chromeos::ShillServiceClient::TestInterface* shill_service_client =
chromeos::DBusThreadManager::Get()
->GetShillServiceClient()
->GetTestInterface();
chromeos::ShillProfileClient::TestInterface* shill_profile_client =
chromeos::DBusThreadManager::Get()
->GetShillProfileClient()
->GetTestInterface();
shill_service_client->ClearServices();
shill_device_client->ClearDevices();
shill_device_client->AddDevice(kWifiDevicePath, shill::kTypeWifi,
"stub_wifi_device");
shill_device_client->SetDeviceProperty(
kWifiDevicePath, shill::kAddressProperty, base::Value(kMacAddress),
/* notify_changed= */ false);
base::DictionaryValue ipconfig_v4_dictionary;
ipconfig_v4_dictionary.SetKey(shill::kAddressProperty,
base::Value(kIpv4Address));
ipconfig_v4_dictionary.SetKey(shill::kMethodProperty,
base::Value(shill::kTypeIPv4));
shill_ipconfig_client->AddIPConfig(kWifiIPConfigV4Path,
ipconfig_v4_dictionary);
base::DictionaryValue ipconfig_v6_dictionary;
ipconfig_v6_dictionary.SetKey(shill::kAddressProperty,
base::Value(kIpv6Address));
ipconfig_v6_dictionary.SetKey(shill::kMethodProperty,
base::Value(shill::kTypeIPv6));
shill_ipconfig_client->AddIPConfig(kWifiIPConfigV6Path,
ipconfig_v6_dictionary);
base::ListValue ip_configs;
ip_configs.AppendString(kWifiIPConfigV4Path);
ip_configs.AppendString(kWifiIPConfigV6Path);
shill_device_client->SetDeviceProperty(
kWifiDevicePath, shill::kIPConfigsProperty, ip_configs,
/*notify_changed=*/false);
shill_service_client->AddService(kWifiServicePath, "wifi_guid",
"wifi_network_name", shill::kTypeWifi,
shill::kStateIdle, /* visible= */ true);
shill_service_client->SetServiceProperty(
kWifiServicePath, shill::kConnectableProperty, base::Value(true));
shill_profile_client->AddService(
chromeos::ShillProfileClient::GetSharedProfilePath(), kWifiServicePath);
base::RunLoop().RunUntilIdle();
}
void ConnectNetwork() {
chromeos::ShillServiceClient::TestInterface* shill_service_client =
chromeos::DBusThreadManager::Get()
->GetShillServiceClient()
->GetTestInterface();
shill_service_client->SetServiceProperty(kWifiServicePath,
shill::kStateProperty,
base::Value(shill::kStateOnline));
base::RunLoop().RunUntilIdle();
}
};
IN_PROC_BROWSER_TEST_P(EnterpriseNetworkingAttributesTest,
PRE_GetNetworkDetails) {
policy::AffiliationTestHelper::PreLoginUser(affiliated_account_id_);
}
IN_PROC_BROWSER_TEST_P(EnterpriseNetworkingAttributesTest, GetNetworkDetails) {
const bool is_affiliated = GetParam();
EXPECT_EQ(is_affiliated, user_manager::UserManager::Get()
->FindUser(affiliated_account_id_)
->IsAffiliated());
const Extension* extension =
ForceInstallExtension(kTestExtensionID, kUpdateManifestPath);
SetupDisconnectedNetwork();
const GURL test_url = extension->GetResourceURL("test.html");
// Run test without connected network.
base::Value custom_arg_disconnected =
is_affiliated ? BuildCustomArgForFailure(kErrorNetworkNotConnected)
: BuildCustomArgForFailure(kErrorUserNotAffiliated);
TestExtension(CreateBrowser(profile()), test_url,
std::move(custom_arg_disconnected));
// Run test with connected network.
ConnectNetwork();
base::Value custom_arg_connected =
is_affiliated ? BuildCustomArgForSuccess(kFormattedMacAddress,
kIpv4Address, kIpv6Address)
: BuildCustomArgForFailure(kErrorUserNotAffiliated);
TestExtension(CreateBrowser(profile()), test_url,
std::move(custom_arg_connected));
}
// Both cases of affiliated and non-affiliated users are tested.
INSTANTIATE_TEST_SUITE_P(AffiliationCheck,
EnterpriseNetworkingAttributesTest,
::testing::Bool());
// Ensure that extensions that are not pre-installed by policy throw an install
// warning if they request the enterprise.networkingAttributes permission in the
// manifest and that such extensions don't see the
// chrome.enterprise.networkingAttributes namespace.
IN_PROC_BROWSER_TEST_F(
ExtensionApiTest,
EnterpriseNetworkingAttributesIsRestrictedToPolicyExtension) {
ASSERT_TRUE(RunExtensionSubtest("enterprise_networking_attributes",
"api_not_available.html",
kFlagIgnoreManifestWarnings, kFlagNone));
base::FilePath extension_path =
test_data_dir_.AppendASCII("enterprise_networking_attributes");
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile())
->enabled_extensions()
.GetByID(kTestExtensionID);
ASSERT_FALSE(extension->install_warnings().empty());
EXPECT_EQ(
"'enterprise.networkingAttributes' is not allowed for specified install "
"location.",
extension->install_warnings()[0].message);
}
} // namespace extensions
...@@ -110,14 +110,18 @@ void ForceInstalledAffiliatedExtensionApiTest::SetUpOnMainThread() { ...@@ -110,14 +110,18 @@ void ForceInstalledAffiliatedExtensionApiTest::SetUpOnMainThread() {
ExtensionApiTest::SetUpOnMainThread(); ExtensionApiTest::SetUpOnMainThread();
} }
void ForceInstalledAffiliatedExtensionApiTest::ForceInstallExtension( const extensions::Extension*
ForceInstalledAffiliatedExtensionApiTest::ForceInstallExtension(
const extensions::ExtensionId& extension_id, const extensions::ExtensionId& extension_id,
const std::string& update_manifest_path) { const std::string& update_manifest_path) {
policy_test_utils::SetExtensionInstallForcelistPolicy( policy_test_utils::SetExtensionInstallForcelistPolicy(
extension_id, embedded_test_server()->GetURL(update_manifest_path), extension_id, embedded_test_server()->GetURL(update_manifest_path),
profile(), &policy_provider_); profile(), &policy_provider_);
ASSERT_TRUE(ExtensionRegistry::Get(profile())->enabled_extensions().GetByID( const extensions::Extension* extension =
extension_id)); ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(
extension_id);
DCHECK(extension);
return extension;
} }
void ForceInstalledAffiliatedExtensionApiTest::TestExtension( void ForceInstalledAffiliatedExtensionApiTest::TestExtension(
......
...@@ -24,6 +24,8 @@ class CommandLine; ...@@ -24,6 +24,8 @@ class CommandLine;
namespace extensions { namespace extensions {
class Extension;
// TODO(https://crbug.com/1082195) Create force-installed extension and user // TODO(https://crbug.com/1082195) Create force-installed extension and user
// affiliation test mixins to replace this class. // affiliation test mixins to replace this class.
...@@ -40,8 +42,9 @@ class ForceInstalledAffiliatedExtensionApiTest : public ExtensionApiTest { ...@@ -40,8 +42,9 @@ class ForceInstalledAffiliatedExtensionApiTest : public ExtensionApiTest {
void SetUpInProcessBrowserTestFixture() override; void SetUpInProcessBrowserTestFixture() override;
void SetUpOnMainThread() override; void SetUpOnMainThread() override;
void ForceInstallExtension(const extensions::ExtensionId& extension_id, const extensions::Extension* ForceInstallExtension(
const std::string& update_manifest_path); const extensions::ExtensionId& extension_id,
const std::string& update_manifest_path);
// Sets |custom_arg_value|, loads |page_url| and waits for an extension API // Sets |custom_arg_value|, loads |page_url| and waits for an extension API
// test pass/fail notification. // test pass/fail notification.
......
...@@ -341,6 +341,10 @@ ...@@ -341,6 +341,10 @@
"dependencies": ["permission:enterprise.deviceAttributes"], "dependencies": ["permission:enterprise.deviceAttributes"],
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
}, },
"enterprise.networkingAttributes": {
"dependencies": ["permission:enterprise.networkingAttributes"],
"contexts": ["blessed_extension"]
},
"enterprise.platformKeys": { "enterprise.platformKeys": {
"dependencies": ["permission:enterprise.platformKeys"], "dependencies": ["permission:enterprise.platformKeys"],
"contexts": ["blessed_extension"], "contexts": ["blessed_extension"],
......
...@@ -274,6 +274,31 @@ ...@@ -274,6 +274,31 @@
"320857126E2180A5751AA384B7B7332A4964BD8C" // Imprivata (login screen) crbug.com/1065112 "320857126E2180A5751AA384B7B7332A4964BD8C" // Imprivata (login screen) crbug.com/1065112
] ]
}], }],
"enterprise.networkingAttributes": [{
"channel": "dev",
"platforms": ["chromeos"],
"extension_types": ["extension"],
"location": "policy"
}, {
"channel": "dev",
"extension_types": ["login_screen_extension"],
"location": "policy",
"platforms": ["chromeos"],
"whitelist": [
"E219EE36A3B40612FD2A8CD6937B03EF0C97D3FE", // Imprivata (login screen) crbug.com/1065112
"4DBFC1C52D6660DD90791976DF7FEF7B3D360509", // Imprivata (login screen) crbug.com/1065112
"CDA6A10BE50CE65C59B766D0CE6A27E8E0A1533F", // Imprivata (login screen) crbug.com/1065112
"D85454743B32D9F5ABF3E5F18DF78809F3A0ABD4", // Imprivata (login screen) crbug.com/1065112
"04569B963251EB28C0906099668D98EE65ECA2D8", // Imprivata (login screen) crbug.com/1065112
"7BF5B69C3ACA9E6ACA5C480661B8073EB9FA32A9", // Imprivata (login screen) crbug.com/1065112
"5F2EF8E9F7E975090278D6A0AD039860430C5684", // Imprivata (login screen) crbug.com/1065112
"97A4DC8AFC1FCF665C71B624A55675C297AB256C", // Imprivata (login screen) crbug.com/1065112
"A00EB72B456C374F1EA86C09833C7DBB6CD95CAE", // Imprivata (login screen) crbug.com/1065112
"51DDBADA37EF4D25AD03CB1BB6451799456FE183", // Imprivata (login screen) crbug.com/1065112
"DD97CAE4D8658003658140109BC119188A19A5B8", // Imprivata (login screen) crbug.com/1065112
"320857126E2180A5751AA384B7B7332A4964BD8C" // Imprivata (login screen) crbug.com/1065112
]
}],
"enterprise.hardwarePlatform": { "enterprise.hardwarePlatform": {
"channel": "stable", "channel": "stable",
"extension_types": ["extension"], "extension_types": ["extension"],
......
...@@ -82,6 +82,7 @@ if (is_chromeos) { ...@@ -82,6 +82,7 @@ if (is_chromeos) {
"certificate_provider_internal.idl", "certificate_provider_internal.idl",
"echo_private.json", "echo_private.json",
"enterprise_device_attributes.idl", "enterprise_device_attributes.idl",
"enterprise_networking_attributes.idl",
"enterprise_platform_keys.idl", "enterprise_platform_keys.idl",
"enterprise_platform_keys_internal.idl", "enterprise_platform_keys_internal.idl",
"enterprise_platform_keys_private.json", "enterprise_platform_keys_private.json",
......
// Copyright 2020 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 <code>chrome.enterprise.networkingAttributes</code> API to read
// information about your current network.
// Note: This API is only available to extensions force-installed by enterprise
// policy.
[platforms = ("chromeos"),
implemented_in = "chrome/browser/extensions/api/enterprise_networking_attributes/enterprise_networking_attributes_api.h"]
namespace enterprise.networkingAttributes {
dictionary NetworkDetails {
// The device's MAC address.
DOMString macAddress;
// The device's local IPv4 address (undefined if not configured).
DOMString? ipv4;
// The device's local IPv6 address (undefined if not configured).
DOMString? ipv6;
};
callback GetNetworkDetailsCallback = void(NetworkDetails networkAddresses);
interface Functions {
// Retrieves the network details of the device's default network.
// If the user is not affiliated or the device is not connected to a
// network, $(ref:runtime.lastError) will be set with a failure reason.
// |callback| : Called with the device's default network's
// $(ref:NetworkDetails).
void getNetworkDetails(GetNetworkDetailsCallback callback);
};
};
...@@ -77,6 +77,9 @@ constexpr APIPermissionInfo::InitInfo permissions_to_register[] = { ...@@ -77,6 +77,9 @@ constexpr APIPermissionInfo::InitInfo permissions_to_register[] = {
APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning},
{APIPermission::kEnterpriseHardwarePlatform, "enterprise.hardwarePlatform", {APIPermission::kEnterpriseHardwarePlatform, "enterprise.hardwarePlatform",
APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning},
{APIPermission::kEnterpriseNetworkingAttributes,
"enterprise.networkingAttributes",
APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning},
{APIPermission::kEnterprisePlatformKeys, "enterprise.platformKeys", {APIPermission::kEnterprisePlatformKeys, "enterprise.platformKeys",
APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning}, APIPermissionInfo::kFlagDoesNotRequireManagedSessionFullLoginWarning},
{APIPermission::kFileBrowserHandler, "fileBrowserHandler", {APIPermission::kFileBrowserHandler, "fileBrowserHandler",
......
...@@ -781,10 +781,12 @@ TEST(PermissionsTest, PermissionMessages) { ...@@ -781,10 +781,12 @@ TEST(PermissionsTest, PermissionMessages) {
skip.insert(APIPermission::kWebView); skip.insert(APIPermission::kWebView);
skip.insert(APIPermission::kWindowShape); skip.insert(APIPermission::kWindowShape);
// TODO(https://crbug.com/1080698) Add permission messages for enterprise.*
// These permissions are restricted to extensions force-installed by policy // These permissions are restricted to extensions force-installed by policy
// and don't require a prompt, i.e. they're restricted to location 'policy'. // and don't require a prompt, i.e. they're restricted to location 'policy'.
skip.insert(APIPermission::kEnterprisePlatformKeys); skip.insert(APIPermission::kEnterprisePlatformKeys);
skip.insert(APIPermission::kEnterpriseDeviceAttributes); skip.insert(APIPermission::kEnterpriseDeviceAttributes);
skip.insert(APIPermission::kEnterpriseNetworkingAttributes);
// TODO(erikkay) add a string for this permission. // TODO(erikkay) add a string for this permission.
skip.insert(APIPermission::kBackground); skip.insert(APIPermission::kBackground);
......
...@@ -1862,6 +1862,7 @@ if (!is_android) { ...@@ -1862,6 +1862,7 @@ if (!is_android) {
"../browser/accessibility/accessibility_extension_api_browsertest.cc", "../browser/accessibility/accessibility_extension_api_browsertest.cc",
"../browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_apitest.cc", "../browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_apitest.cc",
"../browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc", "../browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc",
"../browser/extensions/api/enterprise_networking_attributes/enterprise_networking_attributes_apitest.cc",
"../browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc", "../browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc",
"../browser/extensions/api/force_installed_affiliated_extension_apitest.cc", "../browser/extensions/api/force_installed_affiliated_extension_apitest.cc",
"../browser/extensions/api/force_installed_affiliated_extension_apitest.h", "../browser/extensions/api/force_installed_affiliated_extension_apitest.h",
......
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDiqjM3H8vL8r4F
n6MdHU9GidCx7mNGxDYP5HyA/j9A5XuA/FqEWsCcFiQY9Z54g1Lz1Lbdw9g/H31I
fXHhGVTzixwQT9RCGvU+es0YLxn5jzsr7EvyurTPE0rOXXzdqoibD6wHY9LgXr8C
f43o72ga5OCLlGZP13GR3mnC7JefFZhkr4YrYp8b7Qk4b39z+DOQiqiw5eZ8fvW6
xrwbBiZUI2J4LeZxaSb1xvtBtdbd+o8juYMmO3jxcBT3AOLLwSI7KkfuJeErQIIV
+pyoz2hOesdIE+J6sL9aw01Sur2kGx1IfavKKj6Z9zsr5v1m8VpsBkjpWepgD8ea
nWCmkIm9AgMBAAECggEAAnTHXEwPEx/cw5vWEn0xpuPca+ks5eSUv2RW8wuOQj+a
Wyyg4HlJSAe3ZBaD8pizCpWzVkDb3tySU3mZ2noXS7z7VLPraryhtrJxoYGf0u6k
kgEcAOkushBqnu+FaF4uNRvyMxxM+dsc+m5zv7fvFVzbOrf6Hy2y+y/Wo+LuG65a
Ky7mq2JNJkm7j9Yw4OwiSmMQDpJKz/Zm7RLpF8/Lx0Q4pdK14nfQIrBgAmESeMqH
xxgWhjytpvrckOuW6S9sopH2zklihDD/Wkaf1Hij1fyvTHHoOLX31hdHxi37vQTc
1JwpT9xWBvzNv7VBr/xSVDDilvNY3f0FCJZfnMUDswKBgQD56SR3wOUO0nlPcLMh
UG8WHLFKpuPK8qe1fW5G/dBF3zbuBJXPaIulno1GAPdvEIIIXFuwLu5fnbsUppKb
jfURKCMlkYLa6urNTxeqc/1+sjXJeaAweqWC1kiS7ayqII/uKzYFsYTCc38XBuke
X/pczO566DF0zXHv6VCDlswMrwKBgQDoMA7N6F4//PPuFbA2zkcheGhwA8EVQiX+
4amgDRbIdl2dtdpnPKSShdfyYfBD7Jdh9w7liJ8HENVOvKNzHupaA18TXybKUwO9
z3x4z4lJF2z2MIxT/ixSySsrx5z5vR+yCcHCU2lD60qiunfe8JyjMmQ+xgCSaQWn
DKexNjujUwKBgDaLjEoW7+esSI3uKyq6Q4Sv/oIsqstA6xnRpqAYBb06WuLYXVpH
lzMux+bfjyHOmJL6lYh+tchoxMxdDuKkuThlakZo3Aar/1OQT7oEVu+wNc0jnrL2
Eencmzp2ZZk8Qi3ZgJD9jdxjGPoNqBPZHuviTqrEwwabUKLsaYZPA3pBAoGBAOXd
FfrxjcVJdnCBFjfb1X2kR7iFbvTNzPHdlGF4M9L3o8yLiZHk7oSEbvptzUBhjKkW
vq+spsuG9bYCeMpyk83TQp/Z9nwc3TpfnDm6NI6g22WLQJGys0yuDchE0PpJKoTG
tgTdMPxlhzk844lZqajDLY0b1tsbj9YGaEm/iCEzAoGBAPG9vJ71p8FDAYq5ii4u
ycE/PNbYEiGPcR3bI00rq8DZS6TvSPH1d3wtsZHYCIqX5G2Co0DW5xnKEGuJwyIe
SnGJglY4LtX1xAKojSE/kxhjsCZN/40zkA9yFR1Vo1yOjWQaAJcGNuqc7yOp1U6E
y5j/vlyS9gAFJmk0rc7N5Zpr
-----END PRIVATE KEY-----
<!--
* Copyright 2020 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.
-->
<script src="api_not_available.js"></script>
// Copyright 2020 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.
chrome.test.assertTrue(
!chrome.enterprise || !chrome.enterprise.networkingAttributes);
chrome.test.notifyPass();
{
// chrome-extension://pkhdjpcjgonhlomdjmnddhbfpgkdhgle
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4qozNx/Ly/K+BZ+jHR1PRonQse5jRsQ2D+R8gP4/QOV7gPxahFrAnBYkGPWeeINS89S23cPYPx99SH1x4RlU84scEE/UQhr1PnrNGC8Z+Y87K+xL8rq0zxNKzl183aqImw+sB2PS4F6/An+N6O9oGuTgi5RmT9dxkd5pwuyXnxWYZK+GK2KfG+0JOG9/c/gzkIqosOXmfH71usa8GwYmVCNieC3mcWkm9cb7QbXW3fqPI7mDJjt48XAU9wDiy8EiOypH7iXhK0CCFfqcqM9oTnrHSBPierC/WsNNUrq9pBsdSH2ryio+mfc7K+b9ZvFabAZI6VnqYA/Hmp1gppCJvQIDAQAB",
"name": "enterprise.networkingAttributes API test extension",
"version": "1.0",
"manifest_version": 2,
"permissions": [
"enterprise.networkingAttributes"
]
}
<!--
* Copyright 2020 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.
-->
<script src="test.js"></script>
// Copyright 2020 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.
// TODO(https://crbug.com/1090941) automate packing procedure
// Must be packed to ../enterprise_networking_attributes.crx using the private
// key ../enterprise_networking_attributes.pem .
let expectedErrorMessage, expectedResult;
const availableTests = [
function failure() {
chrome.enterprise.networkingAttributes.getNetworkDetails((details) => {
chrome.test.assertLastError(expectedErrorMessage);
chrome.test.succeed();
});
},
function success() {
chrome.enterprise.networkingAttributes.getNetworkDetails((details) => {
chrome.test.assertNoLastError();
chrome.test.assertEq(expectedResult, details);
chrome.test.succeed();
});
},
];
chrome.test.getConfig(function(config) {
const args = JSON.parse(config.customArg);
expectedResult = args.expectedResult;
expectedErrorMessage = args.expectedErrorMessage;
const testName = args.testName;
const tests = availableTests.filter((testFunc) => {
return testFunc.name === testName;
});
if (tests.length !== 1) {
chrome.test.notifyFail('Test not found ' + testName);
return;
}
chrome.test.runTests(tests);
});
<?xml version='1.0' encoding='UTF-8'?>
<!--
This update manifest points to the enterprise_networking_attributes.crx file.
"mock.http" is a placeholder that gets substituted with the test server
address in runtime.
-->
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='pkhdjpcjgonhlomdjmnddhbfpgkdhgle'>
<updatecheck
codebase='http://mock.http/extensions/api_test/enterprise_networking_attributes.crx'
version='1.0' />
</app>
</gupdate>
...@@ -1542,6 +1542,7 @@ enum HistogramValue { ...@@ -1542,6 +1542,7 @@ enum HistogramValue {
INPUT_IME_SETASSISTIVEWINDOWPROPERTIES = 1479, INPUT_IME_SETASSISTIVEWINDOWPROPERTIES = 1479,
PASSWORDSPRIVATE_MOVEPASSWORDTOACCOUNT = 1480, PASSWORDSPRIVATE_MOVEPASSWORDTOACCOUNT = 1480,
AUTOTESTPRIVATE_DISABLESWITCHACCESSDIALOG = 1481, AUTOTESTPRIVATE_DISABLESWITCHACCESSDIALOG = 1481,
ENTERPRISE_NETWORKINGATTRIBUTES_GETNETWORKDETAILS = 1482,
// Last entry: Add new entries above, then run: // Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py // python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -268,6 +268,7 @@ class APIPermission { ...@@ -268,6 +268,7 @@ class APIPermission {
kPrinting = 224, kPrinting = 224,
kCrashReportPrivate = 225, kCrashReportPrivate = 225,
kAutofillAssistantPrivate = 226, kAutofillAssistantPrivate = 226,
kEnterpriseNetworkingAttributes = 227,
// Last entry: Add new entries above and ensure to update the // Last entry: Add new entries above and ensure to update the
// "ExtensionPermission3" enum in tools/metrics/histograms/enums.xml // "ExtensionPermission3" enum in tools/metrics/histograms/enums.xml
// (by running update_extension_permission.py). // (by running update_extension_permission.py).
......
...@@ -23340,6 +23340,7 @@ Called by update_extension_histograms.py.--> ...@@ -23340,6 +23340,7 @@ Called by update_extension_histograms.py.-->
<int value="1479" label="INPUT_IME_SETASSISTIVEWINDOWPROPERTIES"/> <int value="1479" label="INPUT_IME_SETASSISTIVEWINDOWPROPERTIES"/>
<int value="1480" label="PASSWORDSPRIVATE_MOVEPASSWORDTOACCOUNT"/> <int value="1480" label="PASSWORDSPRIVATE_MOVEPASSWORDTOACCOUNT"/>
<int value="1481" label="AUTOTESTPRIVATE_DISABLESWITCHACCESSDIALOG"/> <int value="1481" label="AUTOTESTPRIVATE_DISABLESWITCHACCESSDIALOG"/>
<int value="1482" label="ENTERPRISE_NETWORKINGATTRIBUTES_GETNETWORKDETAILS"/>
</enum> </enum>
<enum name="ExtensionIconState"> <enum name="ExtensionIconState">
...@@ -23903,6 +23904,7 @@ Called by update_extension_histograms.py.--> ...@@ -23903,6 +23904,7 @@ Called by update_extension_histograms.py.-->
<int value="224" label="kPrinting"/> <int value="224" label="kPrinting"/>
<int value="225" label="kCrashReportPrivate"/> <int value="225" label="kCrashReportPrivate"/>
<int value="226" label="kAutofillAssistantPrivate"/> <int value="226" label="kAutofillAssistantPrivate"/>
<int value="227" label="kEnterpriseNetworkingAttributes"/>
</enum> </enum>
<enum name="ExtensionPolicyReinstallReason"> <enum name="ExtensionPolicyReinstallReason">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment