OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
27 #include "base/values.h" | 27 #include "base/values.h" |
28 #include "chrome/app/chrome_command_ids.h" | 28 #include "chrome/app/chrome_command_ids.h" |
29 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 29 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
30 #include "chrome/browser/background/background_contents_service.h" | 30 #include "chrome/browser/background/background_contents_service.h" |
31 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
32 #include "chrome/browser/chrome_notification_types.h" | 32 #include "chrome/browser/chrome_notification_types.h" |
33 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 33 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
34 #include "chrome/browser/devtools/devtools_window.h" | 34 #include "chrome/browser/devtools/devtools_window.h" |
35 #include "chrome/browser/download/download_prefs.h" | 35 #include "chrome/browser/download/download_prefs.h" |
| 36 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" |
36 #include "chrome/browser/extensions/crx_installer.h" | 37 #include "chrome/browser/extensions/crx_installer.h" |
37 #include "chrome/browser/extensions/extension_host.h" | 38 #include "chrome/browser/extensions/extension_host.h" |
38 #include "chrome/browser/extensions/extension_service.h" | 39 #include "chrome/browser/extensions/extension_service.h" |
39 #include "chrome/browser/extensions/extension_system.h" | 40 #include "chrome/browser/extensions/extension_system.h" |
40 #include "chrome/browser/extensions/unpacked_installer.h" | 41 #include "chrome/browser/extensions/unpacked_installer.h" |
41 #include "chrome/browser/extensions/updater/extension_updater.h" | 42 #include "chrome/browser/extensions/updater/extension_updater.h" |
42 #include "chrome/browser/infobars/infobar.h" | 43 #include "chrome/browser/infobars/infobar.h" |
43 #include "chrome/browser/infobars/infobar_service.h" | 44 #include "chrome/browser/infobars/infobar_service.h" |
44 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 45 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
45 #include "chrome/browser/media/media_stream_devices_controller.h" | 46 #include "chrome/browser/media/media_stream_devices_controller.h" |
(...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 GetDefaultVariationsServerURLForTesting(); | 2870 GetDefaultVariationsServerURLForTesting(); |
2870 | 2871 |
2871 const GURL url = | 2872 const GURL url = |
2872 chrome_variations::VariationsService::GetVariationsServerURL( | 2873 chrome_variations::VariationsService::GetVariationsServerURL( |
2873 g_browser_process->local_state()); | 2874 g_browser_process->local_state()); |
2874 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); | 2875 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); |
2875 std::string value; | 2876 std::string value; |
2876 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 2877 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
2877 EXPECT_EQ("restricted", value); | 2878 EXPECT_EQ("restricted", value); |
2878 } | 2879 } |
2879 #endif | 2880 |
| 2881 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { |
| 2882 base::ListValue blacklist; |
| 2883 blacklist.Append(base::Value::CreateStringValue("host.name")); |
| 2884 PolicyMap policies; |
| 2885 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
| 2886 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
| 2887 UpdateProviderPolicy(policies); |
| 2888 |
| 2889 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2890 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2891 prefs, "host.name")); |
| 2892 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2893 prefs, "other.host.name")); |
| 2894 } |
| 2895 |
| 2896 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { |
| 2897 base::ListValue blacklist; |
| 2898 blacklist.Append(base::Value::CreateStringValue("*")); |
| 2899 PolicyMap policies; |
| 2900 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
| 2901 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
| 2902 UpdateProviderPolicy(policies); |
| 2903 |
| 2904 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2905 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2906 prefs, "host.name")); |
| 2907 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2908 prefs, "other.host.name")); |
| 2909 } |
| 2910 |
| 2911 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { |
| 2912 base::ListValue blacklist; |
| 2913 blacklist.Append(base::Value::CreateStringValue("*")); |
| 2914 base::ListValue whitelist; |
| 2915 whitelist.Append(base::Value::CreateStringValue("host.name")); |
| 2916 PolicyMap policies; |
| 2917 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
| 2918 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
| 2919 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, |
| 2920 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); |
| 2921 UpdateProviderPolicy(policies); |
| 2922 |
| 2923 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2924 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2925 prefs, "host.name")); |
| 2926 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2927 prefs, "other.host.name")); |
| 2928 } |
| 2929 |
| 2930 #endif // !defined(CHROME_OS) |
2880 | 2931 |
2881 } // namespace policy | 2932 } // namespace policy |
OLD | NEW |