Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1539)

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 118253005: Add managed policies for Native Messaging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index ac2c45cbeae1be97029e2faf89e44c5869388dcd..37d5ebbc8d80f8001db9c636b3085a9cb628cb70 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/download/download_prefs.h"
+#include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -2876,6 +2877,56 @@ IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) {
EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
EXPECT_EQ("restricted", value);
}
-#endif
+
+IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) {
+ base::ListValue blacklist;
+ blacklist.Append(base::Value::CreateStringValue("host.name"));
+ PolicyMap policies;
+ policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
+ UpdateProviderPolicy(policies);
+
+ PrefService* prefs = browser()->profile()->GetPrefs();
+ EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
+ prefs, "host.name"));
+ EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed(
+ prefs, "other.host.name"));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) {
+ base::ListValue blacklist;
+ blacklist.Append(base::Value::CreateStringValue("*"));
+ PolicyMap policies;
+ policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
+ UpdateProviderPolicy(policies);
+
+ PrefService* prefs = browser()->profile()->GetPrefs();
+ EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
+ prefs, "host.name"));
+ EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
+ prefs, "other.host.name"));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) {
+ base::ListValue blacklist;
+ blacklist.Append(base::Value::CreateStringValue("*"));
+ base::ListValue whitelist;
+ whitelist.Append(base::Value::CreateStringValue("host.name"));
+ PolicyMap policies;
+ policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
+ policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL);
+ UpdateProviderPolicy(policies);
+
+ PrefService* prefs = browser()->profile()->GetPrefs();
+ EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed(
+ prefs, "host.name"));
+ EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
+ prefs, "other.host.name"));
+}
+
+#endif // !defined(CHROME_OS)
} // namespace policy
« no previous file with comments | « chrome/browser/policy/configuration_policy_handler_list_factory.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698