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 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 #endif |
2880 | 2881 |
| 2882 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { |
| 2883 base::ListValue blacklist; |
| 2884 blacklist.Append(base::Value::CreateStringValue("host.name")); |
| 2885 PolicyMap policies; |
| 2886 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
| 2887 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
| 2888 UpdateProviderPolicy(policies); |
| 2889 |
| 2890 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2891 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2892 prefs, "host.name")); |
| 2893 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2894 prefs, "other.host.name")); |
| 2895 } |
| 2896 |
| 2897 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { |
| 2898 base::ListValue blacklist; |
| 2899 blacklist.Append(base::Value::CreateStringValue("*")); |
| 2900 PolicyMap policies; |
| 2901 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
| 2902 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
| 2903 UpdateProviderPolicy(policies); |
| 2904 |
| 2905 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2906 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2907 prefs, "host.name")); |
| 2908 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2909 prefs, "other.host.name")); |
| 2910 } |
| 2911 |
| 2912 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { |
| 2913 base::ListValue blacklist; |
| 2914 blacklist.Append(base::Value::CreateStringValue("*")); |
| 2915 base::ListValue whitelist; |
| 2916 whitelist.Append(base::Value::CreateStringValue("host.name")); |
| 2917 PolicyMap policies; |
| 2918 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
| 2919 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
| 2920 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, |
| 2921 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); |
| 2922 UpdateProviderPolicy(policies); |
| 2923 |
| 2924 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2925 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2926 prefs, "host.name")); |
| 2927 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2928 prefs, "other.host.name")); |
| 2929 } |
| 2930 |
2881 } // namespace policy | 2931 } // namespace policy |
OLD | NEW |