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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #include "components/omnibox/browser/autocomplete_controller.h" | 92 #include "components/omnibox/browser/autocomplete_controller.h" |
93 #include "components/omnibox/browser/omnibox_edit_model.h" | 93 #include "components/omnibox/browser/omnibox_edit_model.h" |
94 #include "components/omnibox/browser/omnibox_view.h" | 94 #include "components/omnibox/browser/omnibox_view.h" |
95 #include "components/policy/core/browser/browser_policy_connector.h" | 95 #include "components/policy/core/browser/browser_policy_connector.h" |
96 #include "components/policy/core/common/external_data_fetcher.h" | 96 #include "components/policy/core/common/external_data_fetcher.h" |
97 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 97 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
98 #include "components/policy/core/common/policy_map.h" | 98 #include "components/policy/core/common/policy_map.h" |
99 #include "components/policy/core/common/policy_pref_names.h" | 99 #include "components/policy/core/common/policy_pref_names.h" |
100 #include "components/policy/core/common/policy_service.h" | 100 #include "components/policy/core/common/policy_service.h" |
101 #include "components/policy/core/common/policy_service_impl.h" | 101 #include "components/policy/core/common/policy_service_impl.h" |
| 102 #include "components/policy/core/common/policy_types.h" |
102 #include "components/search/search.h" | 103 #include "components/search/search.h" |
103 #include "components/search_engines/template_url.h" | 104 #include "components/search_engines/template_url.h" |
104 #include "components/search_engines/template_url_service.h" | 105 #include "components/search_engines/template_url_service.h" |
105 #include "components/translate/core/browser/language_state.h" | 106 #include "components/translate/core/browser/language_state.h" |
106 #include "components/translate/core/browser/translate_infobar_delegate.h" | 107 #include "components/translate/core/browser/translate_infobar_delegate.h" |
107 #include "components/variations/service/variations_service.h" | 108 #include "components/variations/service/variations_service.h" |
108 #include "components/version_info/version_info.h" | 109 #include "components/version_info/version_info.h" |
109 #include "content/public/browser/browser_child_process_host_iterator.h" | 110 #include "content/public/browser/browser_child_process_host_iterator.h" |
110 #include "content/public/browser/browser_context.h" | 111 #include "content/public/browser/browser_context.h" |
111 #include "content/public/browser/browser_thread.h" | 112 #include "content/public/browser/browser_thread.h" |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 make_scoped_refptr(BrowserThread::GetBlockingPool())), | 667 make_scoped_refptr(BrowserThread::GetBlockingPool())), |
667 base::MessageLoop::current()->QuitWhenIdleClosure()); | 668 base::MessageLoop::current()->QuitWhenIdleClosure()); |
668 content::RunMessageLoop(); | 669 content::RunMessageLoop(); |
669 } | 670 } |
670 | 671 |
671 void SetScreenshotPolicy(bool enabled) { | 672 void SetScreenshotPolicy(bool enabled) { |
672 PolicyMap policies; | 673 PolicyMap policies; |
673 policies.Set(key::kDisableScreenshots, | 674 policies.Set(key::kDisableScreenshots, |
674 POLICY_LEVEL_MANDATORY, | 675 POLICY_LEVEL_MANDATORY, |
675 POLICY_SCOPE_USER, | 676 POLICY_SCOPE_USER, |
| 677 POLICY_SOURCE_CLOUD, |
676 new base::FundamentalValue(!enabled), | 678 new base::FundamentalValue(!enabled), |
677 NULL); | 679 NULL); |
678 UpdateProviderPolicy(policies); | 680 UpdateProviderPolicy(policies); |
679 } | 681 } |
680 | 682 |
681 #if defined(OS_CHROMEOS) | 683 #if defined(OS_CHROMEOS) |
682 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { | 684 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { |
683 public: | 685 public: |
684 void OnScreenshotCompleted( | 686 void OnScreenshotCompleted( |
685 ScreenshotGrabberObserver::Result screenshot_result, | 687 ScreenshotGrabberObserver::Result screenshot_result, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); | 816 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); |
815 click_event.type = blink::WebInputEvent::MouseUp; | 817 click_event.type = blink::WebInputEvent::MouseUp; |
816 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); | 818 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); |
817 } | 819 } |
818 | 820 |
819 void SetPolicy(PolicyMap* policies, const char* key, base::Value* value) { | 821 void SetPolicy(PolicyMap* policies, const char* key, base::Value* value) { |
820 if (value) { | 822 if (value) { |
821 policies->Set(key, | 823 policies->Set(key, |
822 POLICY_LEVEL_MANDATORY, | 824 POLICY_LEVEL_MANDATORY, |
823 POLICY_SCOPE_USER, | 825 POLICY_SCOPE_USER, |
| 826 POLICY_SOURCE_CLOUD, |
824 value, | 827 value, |
825 nullptr); | 828 nullptr); |
826 } else { | 829 } else { |
827 policies->Erase(key); | 830 policies->Erase(key); |
828 } | 831 } |
829 } | 832 } |
830 | 833 |
831 void ApplySafeSearchPolicy(base::FundamentalValue* legacy_safe_search, | 834 void ApplySafeSearchPolicy(base::FundamentalValue* legacy_safe_search, |
832 base::FundamentalValue* google_safe_search, | 835 base::FundamentalValue* google_safe_search, |
833 base::FundamentalValue* youtube_safety_mode) { | 836 base::FundamentalValue* youtube_safety_mode) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 public: | 875 public: |
873 LocalePolicyTest() {} | 876 LocalePolicyTest() {} |
874 ~LocalePolicyTest() override {} | 877 ~LocalePolicyTest() override {} |
875 | 878 |
876 void SetUpInProcessBrowserTestFixture() override { | 879 void SetUpInProcessBrowserTestFixture() override { |
877 PolicyTest::SetUpInProcessBrowserTestFixture(); | 880 PolicyTest::SetUpInProcessBrowserTestFixture(); |
878 PolicyMap policies; | 881 PolicyMap policies; |
879 policies.Set(key::kApplicationLocaleValue, | 882 policies.Set(key::kApplicationLocaleValue, |
880 POLICY_LEVEL_MANDATORY, | 883 POLICY_LEVEL_MANDATORY, |
881 POLICY_SCOPE_USER, | 884 POLICY_SCOPE_USER, |
| 885 POLICY_SOURCE_CLOUD, |
882 new base::StringValue("fr"), | 886 new base::StringValue("fr"), |
883 NULL); | 887 NULL); |
884 provider_.UpdateChromePolicy(policies); | 888 provider_.UpdateChromePolicy(policies); |
885 // The "en-US" ResourceBundle is always loaded before this step for tests, | 889 // The "en-US" ResourceBundle is always loaded before this step for tests, |
886 // but in this test we want the browser to load the bundle as it | 890 // but in this test we want the browser to load the bundle as it |
887 // normally would. | 891 // normally would. |
888 ResourceBundle::CleanupSharedInstance(); | 892 ResourceBundle::CleanupSharedInstance(); |
889 } | 893 } |
890 }; | 894 }; |
891 | 895 |
(...skipping 28 matching lines...) Expand all Loading... |
920 // Test starts in about:blank. | 924 // Test starts in about:blank. |
921 PrefService* prefs = browser()->profile()->GetPrefs(); | 925 PrefService* prefs = browser()->profile()->GetPrefs(); |
922 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 926 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
923 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 927 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
924 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 928 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
925 | 929 |
926 PolicyMap policies; | 930 PolicyMap policies; |
927 policies.Set(key::kBookmarkBarEnabled, | 931 policies.Set(key::kBookmarkBarEnabled, |
928 POLICY_LEVEL_MANDATORY, | 932 POLICY_LEVEL_MANDATORY, |
929 POLICY_SCOPE_USER, | 933 POLICY_SCOPE_USER, |
| 934 POLICY_SOURCE_CLOUD, |
930 new base::FundamentalValue(true), | 935 new base::FundamentalValue(true), |
931 NULL); | 936 NULL); |
932 UpdateProviderPolicy(policies); | 937 UpdateProviderPolicy(policies); |
933 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 938 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
934 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 939 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
935 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 940 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
936 | 941 |
937 // The NTP has special handling of the bookmark bar. | 942 // The NTP has special handling of the bookmark bar. |
938 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 943 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
939 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 944 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
940 | 945 |
941 policies.Set(key::kBookmarkBarEnabled, | 946 policies.Set(key::kBookmarkBarEnabled, |
942 POLICY_LEVEL_MANDATORY, | 947 POLICY_LEVEL_MANDATORY, |
943 POLICY_SCOPE_USER, | 948 POLICY_SCOPE_USER, |
| 949 POLICY_SOURCE_CLOUD, |
944 new base::FundamentalValue(false), | 950 new base::FundamentalValue(false), |
945 NULL); | 951 NULL); |
946 UpdateProviderPolicy(policies); | 952 UpdateProviderPolicy(policies); |
947 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 953 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
948 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 954 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
949 // The bookmark bar is hidden in the NTP when disabled by policy. | 955 // The bookmark bar is hidden in the NTP when disabled by policy. |
950 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 956 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
951 | 957 |
952 policies.Clear(); | 958 policies.Clear(); |
953 UpdateProviderPolicy(policies); | 959 UpdateProviderPolicy(policies); |
(...skipping 19 matching lines...) Expand all Loading... |
973 } | 979 } |
974 | 980 |
975 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { | 981 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { |
976 // Verify that the cookie persists across restarts. | 982 // Verify that the cookie persists across restarts. |
977 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); | 983 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); |
978 // Now set the policy and the cookie should be gone after another restart. | 984 // Now set the policy and the cookie should be gone after another restart. |
979 PolicyMap policies; | 985 PolicyMap policies; |
980 policies.Set(key::kDefaultCookiesSetting, | 986 policies.Set(key::kDefaultCookiesSetting, |
981 POLICY_LEVEL_MANDATORY, | 987 POLICY_LEVEL_MANDATORY, |
982 POLICY_SCOPE_USER, | 988 POLICY_SCOPE_USER, |
| 989 POLICY_SOURCE_CLOUD, |
983 new base::FundamentalValue(4), | 990 new base::FundamentalValue(4), |
984 NULL); | 991 NULL); |
985 UpdateProviderPolicy(policies); | 992 UpdateProviderPolicy(policies); |
986 } | 993 } |
987 | 994 |
988 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { | 995 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { |
989 // Verify that the cookie is gone. | 996 // Verify that the cookie is gone. |
990 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); | 997 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); |
991 } | 998 } |
992 | 999 |
(...skipping 28 matching lines...) Expand all Loading... |
1021 kSearchTermsReplacementKey && | 1028 kSearchTermsReplacementKey && |
1022 default_search->image_url() == kImageURL && | 1029 default_search->image_url() == kImageURL && |
1023 default_search->image_url_post_params() == kImageURLPostParams && | 1030 default_search->image_url_post_params() == kImageURLPostParams && |
1024 default_search->new_tab_url() == kNewTabURL); | 1031 default_search->new_tab_url() == kNewTabURL); |
1025 | 1032 |
1026 // Override the default search provider using policies. | 1033 // Override the default search provider using policies. |
1027 PolicyMap policies; | 1034 PolicyMap policies; |
1028 policies.Set(key::kDefaultSearchProviderEnabled, | 1035 policies.Set(key::kDefaultSearchProviderEnabled, |
1029 POLICY_LEVEL_MANDATORY, | 1036 POLICY_LEVEL_MANDATORY, |
1030 POLICY_SCOPE_USER, | 1037 POLICY_SCOPE_USER, |
| 1038 POLICY_SOURCE_CLOUD, |
1031 new base::FundamentalValue(true), | 1039 new base::FundamentalValue(true), |
1032 NULL); | 1040 NULL); |
1033 policies.Set(key::kDefaultSearchProviderKeyword, | 1041 policies.Set(key::kDefaultSearchProviderKeyword, |
1034 POLICY_LEVEL_MANDATORY, | 1042 POLICY_LEVEL_MANDATORY, |
1035 POLICY_SCOPE_USER, | 1043 POLICY_SCOPE_USER, |
| 1044 POLICY_SOURCE_CLOUD, |
1036 new base::StringValue(kKeyword), | 1045 new base::StringValue(kKeyword), |
1037 NULL); | 1046 NULL); |
1038 policies.Set(key::kDefaultSearchProviderSearchURL, | 1047 policies.Set(key::kDefaultSearchProviderSearchURL, |
1039 POLICY_LEVEL_MANDATORY, | 1048 POLICY_LEVEL_MANDATORY, |
1040 POLICY_SCOPE_USER, | 1049 POLICY_SCOPE_USER, |
| 1050 POLICY_SOURCE_CLOUD, |
1041 new base::StringValue(kSearchURL), | 1051 new base::StringValue(kSearchURL), |
1042 NULL); | 1052 NULL); |
1043 base::ListValue* alternate_urls = new base::ListValue(); | 1053 base::ListValue* alternate_urls = new base::ListValue(); |
1044 alternate_urls->AppendString(kAlternateURL0); | 1054 alternate_urls->AppendString(kAlternateURL0); |
1045 alternate_urls->AppendString(kAlternateURL1); | 1055 alternate_urls->AppendString(kAlternateURL1); |
1046 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, | 1056 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, |
1047 POLICY_SCOPE_USER, alternate_urls, NULL); | 1057 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, alternate_urls, nullptr); |
1048 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, | 1058 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, |
1049 POLICY_LEVEL_MANDATORY, | 1059 POLICY_LEVEL_MANDATORY, |
1050 POLICY_SCOPE_USER, | 1060 POLICY_SCOPE_USER, |
| 1061 POLICY_SOURCE_CLOUD, |
1051 new base::StringValue(kSearchTermsReplacementKey), | 1062 new base::StringValue(kSearchTermsReplacementKey), |
1052 NULL); | 1063 NULL); |
1053 policies.Set(key::kDefaultSearchProviderImageURL, | 1064 policies.Set(key::kDefaultSearchProviderImageURL, |
1054 POLICY_LEVEL_MANDATORY, | 1065 POLICY_LEVEL_MANDATORY, |
1055 POLICY_SCOPE_USER, | 1066 POLICY_SCOPE_USER, |
| 1067 POLICY_SOURCE_CLOUD, |
1056 new base::StringValue(kImageURL), | 1068 new base::StringValue(kImageURL), |
1057 NULL); | 1069 NULL); |
1058 policies.Set(key::kDefaultSearchProviderImageURLPostParams, | 1070 policies.Set(key::kDefaultSearchProviderImageURLPostParams, |
1059 POLICY_LEVEL_MANDATORY, | 1071 POLICY_LEVEL_MANDATORY, |
1060 POLICY_SCOPE_USER, | 1072 POLICY_SCOPE_USER, |
| 1073 POLICY_SOURCE_CLOUD, |
1061 new base::StringValue(kImageURLPostParams), | 1074 new base::StringValue(kImageURLPostParams), |
1062 NULL); | 1075 NULL); |
1063 policies.Set(key::kDefaultSearchProviderNewTabURL, | 1076 policies.Set(key::kDefaultSearchProviderNewTabURL, |
1064 POLICY_LEVEL_MANDATORY, | 1077 POLICY_LEVEL_MANDATORY, |
1065 POLICY_SCOPE_USER, | 1078 POLICY_SCOPE_USER, |
| 1079 POLICY_SOURCE_CLOUD, |
1066 new base::StringValue(kNewTabURL), | 1080 new base::StringValue(kNewTabURL), |
1067 NULL); | 1081 NULL); |
1068 UpdateProviderPolicy(policies); | 1082 UpdateProviderPolicy(policies); |
1069 default_search = service->GetDefaultSearchProvider(); | 1083 default_search = service->GetDefaultSearchProvider(); |
1070 ASSERT_TRUE(default_search); | 1084 ASSERT_TRUE(default_search); |
1071 EXPECT_EQ(kKeyword, default_search->keyword()); | 1085 EXPECT_EQ(kKeyword, default_search->keyword()); |
1072 EXPECT_EQ(kSearchURL, default_search->url()); | 1086 EXPECT_EQ(kSearchURL, default_search->url()); |
1073 EXPECT_EQ(2U, default_search->alternate_urls().size()); | 1087 EXPECT_EQ(2U, default_search->alternate_urls().size()); |
1074 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); | 1088 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); |
1075 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); | 1089 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); |
(...skipping 12 matching lines...) Expand all Loading... |
1088 content::WebContents* web_contents = | 1102 content::WebContents* web_contents = |
1089 browser()->tab_strip_model()->GetActiveWebContents(); | 1103 browser()->tab_strip_model()->GetActiveWebContents(); |
1090 GURL expected("http://search.example/search?q=stuff+to+search+for"); | 1104 GURL expected("http://search.example/search?q=stuff+to+search+for"); |
1091 EXPECT_EQ(expected, web_contents->GetURL()); | 1105 EXPECT_EQ(expected, web_contents->GetURL()); |
1092 | 1106 |
1093 // Verify that searching from the omnibox can be disabled. | 1107 // Verify that searching from the omnibox can be disabled. |
1094 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1108 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
1095 policies.Set(key::kDefaultSearchProviderEnabled, | 1109 policies.Set(key::kDefaultSearchProviderEnabled, |
1096 POLICY_LEVEL_MANDATORY, | 1110 POLICY_LEVEL_MANDATORY, |
1097 POLICY_SCOPE_USER, | 1111 POLICY_SCOPE_USER, |
| 1112 POLICY_SOURCE_CLOUD, |
1098 new base::FundamentalValue(false), | 1113 new base::FundamentalValue(false), |
1099 NULL); | 1114 NULL); |
1100 EXPECT_TRUE(service->GetDefaultSearchProvider()); | 1115 EXPECT_TRUE(service->GetDefaultSearchProvider()); |
1101 UpdateProviderPolicy(policies); | 1116 UpdateProviderPolicy(policies); |
1102 EXPECT_FALSE(service->GetDefaultSearchProvider()); | 1117 EXPECT_FALSE(service->GetDefaultSearchProvider()); |
1103 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); | 1118 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); |
1104 // This means that submitting won't trigger any action. | 1119 // This means that submitting won't trigger any action. |
1105 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1120 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); |
1106 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); | 1121 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); |
1107 } | 1122 } |
1108 | 1123 |
1109 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { | 1124 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { |
1110 // Add an individual proxy policy value. | 1125 // Add an individual proxy policy value. |
1111 PolicyMap policies; | 1126 PolicyMap policies; |
1112 policies.Set(key::kProxyServerMode, | 1127 policies.Set(key::kProxyServerMode, |
1113 POLICY_LEVEL_MANDATORY, | 1128 POLICY_LEVEL_MANDATORY, |
1114 POLICY_SCOPE_USER, | 1129 POLICY_SCOPE_USER, |
| 1130 POLICY_SOURCE_CLOUD, |
1115 new base::FundamentalValue(3), | 1131 new base::FundamentalValue(3), |
1116 NULL); | 1132 NULL); |
1117 UpdateProviderPolicy(policies); | 1133 UpdateProviderPolicy(policies); |
1118 | 1134 |
1119 // It should be removed and replaced with a dictionary. | 1135 // It should be removed and replaced with a dictionary. |
1120 PolicyMap expected; | 1136 PolicyMap expected; |
1121 scoped_ptr<base::DictionaryValue> expected_value(new base::DictionaryValue); | 1137 scoped_ptr<base::DictionaryValue> expected_value(new base::DictionaryValue); |
1122 expected_value->SetInteger(key::kProxyServerMode, 3); | 1138 expected_value->SetInteger(key::kProxyServerMode, 3); |
1123 expected.Set(key::kProxySettings, | 1139 expected.Set(key::kProxySettings, |
1124 POLICY_LEVEL_MANDATORY, | 1140 POLICY_LEVEL_MANDATORY, |
1125 POLICY_SCOPE_USER, | 1141 POLICY_SCOPE_USER, |
| 1142 POLICY_SOURCE_CLOUD, |
1126 expected_value.release(), | 1143 expected_value.release(), |
1127 NULL); | 1144 NULL); |
1128 | 1145 |
1129 // Check both the browser and the profile. | 1146 // Check both the browser and the profile. |
1130 const PolicyMap& actual_from_browser = | 1147 const PolicyMap& actual_from_browser = |
1131 g_browser_process->browser_policy_connector() | 1148 g_browser_process->browser_policy_connector() |
1132 ->GetPolicyService() | 1149 ->GetPolicyService() |
1133 ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | 1150 ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
1134 EXPECT_TRUE(expected.Equals(actual_from_browser)); | 1151 EXPECT_TRUE(expected.Equals(actual_from_browser)); |
1135 const PolicyMap& actual_from_profile = | 1152 const PolicyMap& actual_from_profile = |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 EXPECT_FALSE( | 1225 EXPECT_FALSE( |
1209 default_search->alternate_urls().size() == 2 && | 1226 default_search->alternate_urls().size() == 2 && |
1210 default_search->alternate_urls()[0] == kAlternateURL0 && | 1227 default_search->alternate_urls()[0] == kAlternateURL0 && |
1211 default_search->alternate_urls()[1] == kAlternateURL1); | 1228 default_search->alternate_urls()[1] == kAlternateURL1); |
1212 | 1229 |
1213 // Override the default search provider using policies. | 1230 // Override the default search provider using policies. |
1214 PolicyMap policies; | 1231 PolicyMap policies; |
1215 policies.Set(key::kDefaultSearchProviderEnabled, | 1232 policies.Set(key::kDefaultSearchProviderEnabled, |
1216 POLICY_LEVEL_MANDATORY, | 1233 POLICY_LEVEL_MANDATORY, |
1217 POLICY_SCOPE_USER, | 1234 POLICY_SCOPE_USER, |
| 1235 POLICY_SOURCE_CLOUD, |
1218 new base::FundamentalValue(true), | 1236 new base::FundamentalValue(true), |
1219 NULL); | 1237 NULL); |
1220 policies.Set(key::kDefaultSearchProviderKeyword, | 1238 policies.Set(key::kDefaultSearchProviderKeyword, |
1221 POLICY_LEVEL_MANDATORY, | 1239 POLICY_LEVEL_MANDATORY, |
1222 POLICY_SCOPE_USER, | 1240 POLICY_SCOPE_USER, |
| 1241 POLICY_SOURCE_CLOUD, |
1223 new base::StringValue(kKeyword), | 1242 new base::StringValue(kKeyword), |
1224 NULL); | 1243 NULL); |
1225 policies.Set(key::kDefaultSearchProviderSearchURL, | 1244 policies.Set(key::kDefaultSearchProviderSearchURL, |
1226 POLICY_LEVEL_MANDATORY, | 1245 POLICY_LEVEL_MANDATORY, |
1227 POLICY_SCOPE_USER, | 1246 POLICY_SCOPE_USER, |
| 1247 POLICY_SOURCE_CLOUD, |
1228 new base::StringValue(kSearchURL), | 1248 new base::StringValue(kSearchURL), |
1229 NULL); | 1249 NULL); |
1230 policies.Set(key::kDefaultSearchProviderInstantURL, | 1250 policies.Set(key::kDefaultSearchProviderInstantURL, |
1231 POLICY_LEVEL_MANDATORY, | 1251 POLICY_LEVEL_MANDATORY, |
1232 POLICY_SCOPE_USER, | 1252 POLICY_SCOPE_USER, |
| 1253 POLICY_SOURCE_CLOUD, |
1233 new base::StringValue(kInstantURL), | 1254 new base::StringValue(kInstantURL), |
1234 NULL); | 1255 NULL); |
1235 base::ListValue* alternate_urls = new base::ListValue(); | 1256 base::ListValue* alternate_urls = new base::ListValue(); |
1236 alternate_urls->AppendString(kAlternateURL0); | 1257 alternate_urls->AppendString(kAlternateURL0); |
1237 alternate_urls->AppendString(kAlternateURL1); | 1258 alternate_urls->AppendString(kAlternateURL1); |
1238 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, | 1259 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, |
1239 POLICY_SCOPE_USER, alternate_urls, NULL); | 1260 POLICY_SCOPE_USER, |
| 1261 POLICY_SOURCE_CLOUD, alternate_urls, nullptr); |
1240 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, | 1262 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, |
1241 POLICY_LEVEL_MANDATORY, | 1263 POLICY_LEVEL_MANDATORY, |
1242 POLICY_SCOPE_USER, | 1264 POLICY_SCOPE_USER, |
| 1265 POLICY_SOURCE_CLOUD, |
1243 new base::StringValue(kSearchTermsReplacementKey), | 1266 new base::StringValue(kSearchTermsReplacementKey), |
1244 NULL); | 1267 NULL); |
1245 UpdateProviderPolicy(policies); | 1268 UpdateProviderPolicy(policies); |
1246 default_search = service->GetDefaultSearchProvider(); | 1269 default_search = service->GetDefaultSearchProvider(); |
1247 ASSERT_TRUE(default_search); | 1270 ASSERT_TRUE(default_search); |
1248 EXPECT_EQ(kKeyword, default_search->keyword()); | 1271 EXPECT_EQ(kKeyword, default_search->keyword()); |
1249 EXPECT_EQ(kSearchURL, default_search->url()); | 1272 EXPECT_EQ(kSearchURL, default_search->url()); |
1250 EXPECT_EQ(kInstantURL, default_search->instant_url()); | 1273 EXPECT_EQ(kInstantURL, default_search->instant_url()); |
1251 EXPECT_EQ(2U, default_search->alternate_urls().size()); | 1274 EXPECT_EQ(2U, default_search->alternate_urls().size()); |
1252 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); | 1275 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1337 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
1315 // WebGL is enabled by default. | 1338 // WebGL is enabled by default. |
1316 content::WebContents* contents = | 1339 content::WebContents* contents = |
1317 browser()->tab_strip_model()->GetActiveWebContents(); | 1340 browser()->tab_strip_model()->GetActiveWebContents(); |
1318 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1341 EXPECT_TRUE(IsWebGLEnabled(contents)); |
1319 // Disable with a policy. | 1342 // Disable with a policy. |
1320 PolicyMap policies; | 1343 PolicyMap policies; |
1321 policies.Set(key::kDisable3DAPIs, | 1344 policies.Set(key::kDisable3DAPIs, |
1322 POLICY_LEVEL_MANDATORY, | 1345 POLICY_LEVEL_MANDATORY, |
1323 POLICY_SCOPE_USER, | 1346 POLICY_SCOPE_USER, |
| 1347 POLICY_SOURCE_CLOUD, |
1324 new base::FundamentalValue(true), | 1348 new base::FundamentalValue(true), |
1325 NULL); | 1349 NULL); |
1326 UpdateProviderPolicy(policies); | 1350 UpdateProviderPolicy(policies); |
1327 // Crash and reload the tab to get a new renderer. | 1351 // Crash and reload the tab to get a new renderer. |
1328 content::CrashTab(contents); | 1352 content::CrashTab(contents); |
1329 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1353 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
1330 EXPECT_FALSE(IsWebGLEnabled(contents)); | 1354 EXPECT_FALSE(IsWebGLEnabled(contents)); |
1331 // Enable with a policy. | 1355 // Enable with a policy. |
1332 policies.Set(key::kDisable3DAPIs, | 1356 policies.Set(key::kDisable3DAPIs, |
1333 POLICY_LEVEL_MANDATORY, | 1357 POLICY_LEVEL_MANDATORY, |
1334 POLICY_SCOPE_USER, | 1358 POLICY_SCOPE_USER, |
| 1359 POLICY_SOURCE_CLOUD, |
1335 new base::FundamentalValue(false), | 1360 new base::FundamentalValue(false), |
1336 NULL); | 1361 NULL); |
1337 UpdateProviderPolicy(policies); | 1362 UpdateProviderPolicy(policies); |
1338 content::CrashTab(contents); | 1363 content::CrashTab(contents); |
1339 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1364 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
1340 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1365 EXPECT_TRUE(IsWebGLEnabled(contents)); |
1341 } | 1366 } |
1342 | 1367 |
1343 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) { | 1368 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) { |
1344 // Verifies that SPDY can be disable by policy. | 1369 // Verifies that SPDY can be disable by policy. |
1345 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); | 1370 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); |
1346 PolicyMap policies; | 1371 PolicyMap policies; |
1347 policies.Set(key::kDisableSpdy, | 1372 policies.Set(key::kDisableSpdy, |
1348 POLICY_LEVEL_MANDATORY, | 1373 POLICY_LEVEL_MANDATORY, |
1349 POLICY_SCOPE_USER, | 1374 POLICY_SCOPE_USER, |
| 1375 POLICY_SOURCE_CLOUD, |
1350 new base::FundamentalValue(true), | 1376 new base::FundamentalValue(true), |
1351 NULL); | 1377 NULL); |
1352 UpdateProviderPolicy(policies); | 1378 UpdateProviderPolicy(policies); |
1353 content::RunAllPendingInMessageLoop(); | 1379 content::RunAllPendingInMessageLoop(); |
1354 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); | 1380 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); |
1355 // Verify that it can be force-enabled too. | 1381 // Verify that it can be force-enabled too. |
1356 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); | 1382 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); |
1357 policies.Set(key::kDisableSpdy, | 1383 policies.Set(key::kDisableSpdy, |
1358 POLICY_LEVEL_MANDATORY, | 1384 POLICY_LEVEL_MANDATORY, |
1359 POLICY_SCOPE_USER, | 1385 POLICY_SCOPE_USER, |
| 1386 POLICY_SOURCE_CLOUD, |
1360 new base::FundamentalValue(false), | 1387 new base::FundamentalValue(false), |
1361 NULL); | 1388 NULL); |
1362 UpdateProviderPolicy(policies); | 1389 UpdateProviderPolicy(policies); |
1363 content::RunAllPendingInMessageLoop(); | 1390 content::RunAllPendingInMessageLoop(); |
1364 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); | 1391 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); |
1365 } | 1392 } |
1366 | 1393 |
1367 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { | 1394 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { |
1368 // Verifies that plugins can be forced to be disabled by policy. | 1395 // Verifies that plugins can be forced to be disabled by policy. |
1369 | 1396 |
1370 // Verify that the Flash plugin exists and that it can be enabled and disabled | 1397 // Verify that the Flash plugin exists and that it can be enabled and disabled |
1371 // by the user. | 1398 // by the user. |
1372 std::vector<content::WebPluginInfo> plugins; | 1399 std::vector<content::WebPluginInfo> plugins; |
1373 GetPluginList(&plugins); | 1400 GetPluginList(&plugins); |
1374 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1401 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1375 if (!flash) | 1402 if (!flash) |
1376 return; | 1403 return; |
1377 PluginPrefs* plugin_prefs = | 1404 PluginPrefs* plugin_prefs = |
1378 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1405 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1379 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1406 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1380 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1407 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1381 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1408 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1382 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | 1409 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); |
1383 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1410 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1384 | 1411 |
1385 // Now disable it with a policy. | 1412 // Now disable it with a policy. |
1386 base::ListValue disabled_plugins; | 1413 base::ListValue disabled_plugins; |
1387 disabled_plugins.Append(new base::StringValue("*Flash*")); | 1414 disabled_plugins.Append(new base::StringValue("*Flash*")); |
1388 PolicyMap policies; | 1415 PolicyMap policies; |
1389 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1416 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1390 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); | 1417 POLICY_SOURCE_CLOUD, disabled_plugins.DeepCopy(), nullptr); |
1391 UpdateProviderPolicy(policies); | 1418 UpdateProviderPolicy(policies); |
1392 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1419 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1393 // The user shouldn't be able to enable it. | 1420 // The user shouldn't be able to enable it. |
1394 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | 1421 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); |
1395 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1422 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1396 } | 1423 } |
1397 | 1424 |
1398 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { | 1425 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { |
1399 // Verifies that plugins with an exception in the blacklist can be enabled. | 1426 // Verifies that plugins with an exception in the blacklist can be enabled. |
1400 | 1427 |
1401 // Verify that the Flash plugin exists and that it can be enabled and disabled | 1428 // Verify that the Flash plugin exists and that it can be enabled and disabled |
1402 // by the user. | 1429 // by the user. |
1403 std::vector<content::WebPluginInfo> plugins; | 1430 std::vector<content::WebPluginInfo> plugins; |
1404 GetPluginList(&plugins); | 1431 GetPluginList(&plugins); |
1405 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1432 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1406 if (!flash) | 1433 if (!flash) |
1407 return; | 1434 return; |
1408 PluginPrefs* plugin_prefs = | 1435 PluginPrefs* plugin_prefs = |
1409 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1436 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1410 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1437 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1411 | 1438 |
1412 // Disable all plugins. | 1439 // Disable all plugins. |
1413 base::ListValue disabled_plugins; | 1440 base::ListValue disabled_plugins; |
1414 disabled_plugins.Append(new base::StringValue("*")); | 1441 disabled_plugins.Append(new base::StringValue("*")); |
1415 PolicyMap policies; | 1442 PolicyMap policies; |
1416 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1443 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1417 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); | 1444 POLICY_SOURCE_CLOUD, disabled_plugins.DeepCopy(), nullptr); |
1418 UpdateProviderPolicy(policies); | 1445 UpdateProviderPolicy(policies); |
1419 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1446 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1420 // The user shouldn't be able to enable it. | 1447 // The user shouldn't be able to enable it. |
1421 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | 1448 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); |
1422 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1449 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1423 | 1450 |
1424 // Now open an exception for flash. | 1451 // Now open an exception for flash. |
1425 base::ListValue disabled_plugins_exceptions; | 1452 base::ListValue disabled_plugins_exceptions; |
1426 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*")); | 1453 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*")); |
1427 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, | 1454 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, |
1428 POLICY_SCOPE_USER, disabled_plugins_exceptions.DeepCopy(), NULL); | 1455 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1456 disabled_plugins_exceptions.DeepCopy(), nullptr); |
1429 UpdateProviderPolicy(policies); | 1457 UpdateProviderPolicy(policies); |
1430 // It should revert to the user's preference automatically. | 1458 // It should revert to the user's preference automatically. |
1431 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1459 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1432 // And the user should be able to disable and enable again. | 1460 // And the user should be able to disable and enable again. |
1433 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1461 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1434 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1462 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1435 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | 1463 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); |
1436 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1464 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1437 } | 1465 } |
1438 | 1466 |
1439 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { | 1467 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { |
1440 // Verifies that a plugin can be force-installed with a policy. | 1468 // Verifies that a plugin can be force-installed with a policy. |
1441 std::vector<content::WebPluginInfo> plugins; | 1469 std::vector<content::WebPluginInfo> plugins; |
1442 GetPluginList(&plugins); | 1470 GetPluginList(&plugins); |
1443 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1471 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1444 if (!flash) | 1472 if (!flash) |
1445 return; | 1473 return; |
1446 PluginPrefs* plugin_prefs = | 1474 PluginPrefs* plugin_prefs = |
1447 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1475 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1448 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1476 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1449 | 1477 |
1450 // The user disables it and then a policy forces it to be enabled. | 1478 // The user disables it and then a policy forces it to be enabled. |
1451 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1479 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1452 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1480 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1453 base::ListValue plugin_list; | 1481 base::ListValue plugin_list; |
1454 plugin_list.Append(new base::StringValue(content::kFlashPluginName)); | 1482 plugin_list.Append(new base::StringValue(content::kFlashPluginName)); |
1455 PolicyMap policies; | 1483 PolicyMap policies; |
1456 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, | 1484 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, |
1457 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL); | 1485 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, plugin_list.DeepCopy(), |
| 1486 nullptr); |
1458 UpdateProviderPolicy(policies); | 1487 UpdateProviderPolicy(policies); |
1459 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1488 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1460 // The user can't disable it anymore. | 1489 // The user can't disable it anymore. |
1461 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); | 1490 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); |
1462 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1491 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1463 | 1492 |
1464 // When a plugin is both enabled and disabled, the whitelist takes precedence. | 1493 // When a plugin is both enabled and disabled, the whitelist takes precedence. |
1465 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1494 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, |
1466 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL); | 1495 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, plugin_list.DeepCopy(), |
| 1496 nullptr); |
1467 UpdateProviderPolicy(policies); | 1497 UpdateProviderPolicy(policies); |
1468 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1498 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1469 } | 1499 } |
1470 | 1500 |
1471 IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { | 1501 IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { |
1472 // Verifies that dangerous plugins can be always authorized to run with | 1502 // Verifies that dangerous plugins can be always authorized to run with |
1473 // a policy. | 1503 // a policy. |
1474 | 1504 |
1475 // Verify that the test page exists. It is only present in checkouts with | 1505 // Verify that the test page exists. It is only present in checkouts with |
1476 // src-internal. | 1506 // src-internal. |
(...skipping 24 matching lines...) Expand all Loading... |
1501 EXPECT_TRUE( | 1531 EXPECT_TRUE( |
1502 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); | 1532 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); |
1503 // And the plugin isn't running. | 1533 // And the plugin isn't running. |
1504 EXPECT_EQ(0, CountPlugins()); | 1534 EXPECT_EQ(0, CountPlugins()); |
1505 | 1535 |
1506 // Now set a policy to always authorize this. | 1536 // Now set a policy to always authorize this. |
1507 PolicyMap policies; | 1537 PolicyMap policies; |
1508 policies.Set(key::kAlwaysAuthorizePlugins, | 1538 policies.Set(key::kAlwaysAuthorizePlugins, |
1509 POLICY_LEVEL_MANDATORY, | 1539 POLICY_LEVEL_MANDATORY, |
1510 POLICY_SCOPE_USER, | 1540 POLICY_SCOPE_USER, |
| 1541 POLICY_SOURCE_CLOUD, |
1511 new base::FundamentalValue(true), | 1542 new base::FundamentalValue(true), |
1512 NULL); | 1543 NULL); |
1513 UpdateProviderPolicy(policies); | 1544 UpdateProviderPolicy(policies); |
1514 // Reloading the page shouldn't trigger the infobar this time. | 1545 // Reloading the page shouldn't trigger the infobar this time. |
1515 ui_test_utils::NavigateToURL(browser(), url); | 1546 ui_test_utils::NavigateToURL(browser(), url); |
1516 EXPECT_EQ(0u, infobar_service->infobar_count()); | 1547 EXPECT_EQ(0u, infobar_service->infobar_count()); |
1517 // And the plugin started automatically. | 1548 // And the plugin started automatically. |
1518 EXPECT_EQ(1, CountPlugins()); | 1549 EXPECT_EQ(1, CountPlugins()); |
1519 } | 1550 } |
1520 | 1551 |
1521 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { | 1552 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { |
1522 // Verifies that access to the developer tools can be disabled. | 1553 // Verifies that access to the developer tools can be disabled. |
1523 | 1554 |
1524 // Open devtools. | 1555 // Open devtools. |
1525 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1556 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
1526 content::WebContents* contents = | 1557 content::WebContents* contents = |
1527 browser()->tab_strip_model()->GetActiveWebContents(); | 1558 browser()->tab_strip_model()->GetActiveWebContents(); |
1528 DevToolsWindow* devtools_window = | 1559 DevToolsWindow* devtools_window = |
1529 DevToolsWindow::GetInstanceForInspectedWebContents(contents); | 1560 DevToolsWindow::GetInstanceForInspectedWebContents(contents); |
1530 EXPECT_TRUE(devtools_window); | 1561 EXPECT_TRUE(devtools_window); |
1531 | 1562 |
1532 // Disable devtools via policy. | 1563 // Disable devtools via policy. |
1533 PolicyMap policies; | 1564 PolicyMap policies; |
1534 policies.Set(key::kDeveloperToolsDisabled, | 1565 policies.Set(key::kDeveloperToolsDisabled, |
1535 POLICY_LEVEL_MANDATORY, | 1566 POLICY_LEVEL_MANDATORY, |
1536 POLICY_SCOPE_USER, | 1567 POLICY_SCOPE_USER, |
| 1568 POLICY_SOURCE_CLOUD, |
1537 new base::FundamentalValue(true), | 1569 new base::FundamentalValue(true), |
1538 NULL); | 1570 NULL); |
1539 content::WindowedNotificationObserver close_observer( | 1571 content::WindowedNotificationObserver close_observer( |
1540 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1572 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
1541 content::Source<content::WebContents>( | 1573 content::Source<content::WebContents>( |
1542 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); | 1574 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); |
1543 UpdateProviderPolicy(policies); | 1575 UpdateProviderPolicy(policies); |
1544 // wait for devtools close | 1576 // wait for devtools close |
1545 close_observer.Wait(); | 1577 close_observer.Wait(); |
1546 // The existing devtools window should have closed. | 1578 // The existing devtools window should have closed. |
(...skipping 27 matching lines...) Expand all Loading... |
1574 | 1606 |
1575 // The next NTP has no footer. | 1607 // The next NTP has no footer. |
1576 if (ContainsVisibleElement(contents, "footer")) | 1608 if (ContainsVisibleElement(contents, "footer")) |
1577 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1609 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
1578 | 1610 |
1579 // Turn off the web store icons. | 1611 // Turn off the web store icons. |
1580 PolicyMap policies; | 1612 PolicyMap policies; |
1581 policies.Set(key::kHideWebStoreIcon, | 1613 policies.Set(key::kHideWebStoreIcon, |
1582 POLICY_LEVEL_MANDATORY, | 1614 POLICY_LEVEL_MANDATORY, |
1583 POLICY_SCOPE_USER, | 1615 POLICY_SCOPE_USER, |
| 1616 POLICY_SOURCE_CLOUD, |
1584 new base::FundamentalValue(true), | 1617 new base::FundamentalValue(true), |
1585 NULL); | 1618 NULL); |
1586 UpdateProviderPolicy(policies); | 1619 UpdateProviderPolicy(policies); |
1587 | 1620 |
1588 // The web store icons should now be hidden. | 1621 // The web store icons should now be hidden. |
1589 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1622 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
1590 EXPECT_FALSE(ContainsVisibleElement(contents, | 1623 EXPECT_FALSE(ContainsVisibleElement(contents, |
1591 "ahfgeienlihckogmohjhadlkjgocpleb")); | 1624 "ahfgeienlihckogmohjhadlkjgocpleb")); |
1592 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1625 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
1593 } | 1626 } |
(...skipping 15 matching lines...) Expand all Loading... |
1609 DownloadAndVerifyFile(browser(), initial_dir.path(), file); | 1642 DownloadAndVerifyFile(browser(), initial_dir.path(), file); |
1610 base::DieFileDie(initial_dir.path().Append(file), false); | 1643 base::DieFileDie(initial_dir.path().Append(file), false); |
1611 | 1644 |
1612 // Override the download directory with the policy and verify a download. | 1645 // Override the download directory with the policy and verify a download. |
1613 base::ScopedTempDir forced_dir; | 1646 base::ScopedTempDir forced_dir; |
1614 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); | 1647 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); |
1615 PolicyMap policies; | 1648 PolicyMap policies; |
1616 policies.Set(key::kDownloadDirectory, | 1649 policies.Set(key::kDownloadDirectory, |
1617 POLICY_LEVEL_MANDATORY, | 1650 POLICY_LEVEL_MANDATORY, |
1618 POLICY_SCOPE_USER, | 1651 POLICY_SCOPE_USER, |
| 1652 POLICY_SOURCE_CLOUD, |
1619 new base::StringValue(forced_dir.path().value()), | 1653 new base::StringValue(forced_dir.path().value()), |
1620 NULL); | 1654 NULL); |
1621 UpdateProviderPolicy(policies); | 1655 UpdateProviderPolicy(policies); |
1622 DownloadAndVerifyFile(browser(), forced_dir.path(), file); | 1656 DownloadAndVerifyFile(browser(), forced_dir.path(), file); |
1623 // Verify that the first download location wasn't affected. | 1657 // Verify that the first download location wasn't affected. |
1624 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); | 1658 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); |
1625 } | 1659 } |
1626 | 1660 |
1627 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) { | 1661 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) { |
1628 // Verifies that blacklisted extensions can't be installed. | 1662 // Verifies that blacklisted extensions can't be installed. |
1629 ExtensionService* service = extension_service(); | 1663 ExtensionService* service = extension_service(); |
1630 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1664 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1631 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1665 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1632 base::ListValue blacklist; | 1666 base::ListValue blacklist; |
1633 blacklist.Append(new base::StringValue(kGoodCrxId)); | 1667 blacklist.Append(new base::StringValue(kGoodCrxId)); |
1634 PolicyMap policies; | 1668 PolicyMap policies; |
1635 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1669 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1636 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1670 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 1671 nullptr); |
1637 UpdateProviderPolicy(policies); | 1672 UpdateProviderPolicy(policies); |
1638 | 1673 |
1639 // "good.crx" is blacklisted. | 1674 // "good.crx" is blacklisted. |
1640 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1675 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1641 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1676 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1642 | 1677 |
1643 // "adblock.crx" is not. | 1678 // "adblock.crx" is not. |
1644 const extensions::Extension* adblock = InstallExtension(kAdBlockCrxName); | 1679 const extensions::Extension* adblock = InstallExtension(kAdBlockCrxName); |
1645 ASSERT_TRUE(adblock); | 1680 ASSERT_TRUE(adblock); |
1646 EXPECT_EQ(kAdBlockCrxId, adblock->id()); | 1681 EXPECT_EQ(kAdBlockCrxId, adblock->id()); |
(...skipping 10 matching lines...) Expand all Loading... |
1657 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { | 1692 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { |
1658 // Verify that a wildcard blacklist takes effect. | 1693 // Verify that a wildcard blacklist takes effect. |
1659 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); | 1694 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); |
1660 ExtensionService* service = extension_service(); | 1695 ExtensionService* service = extension_service(); |
1661 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1696 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1662 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); | 1697 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); |
1663 base::ListValue blacklist; | 1698 base::ListValue blacklist; |
1664 blacklist.Append(new base::StringValue("*")); | 1699 blacklist.Append(new base::StringValue("*")); |
1665 PolicyMap policies; | 1700 PolicyMap policies; |
1666 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1701 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1667 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1702 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 1703 nullptr); |
1668 UpdateProviderPolicy(policies); | 1704 UpdateProviderPolicy(policies); |
1669 | 1705 |
1670 // AdBlock was automatically removed. | 1706 // AdBlock was automatically removed. |
1671 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1707 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1672 | 1708 |
1673 // And can't be installed again, nor can good.crx. | 1709 // And can't be installed again, nor can good.crx. |
1674 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1710 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
1675 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1711 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1676 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1712 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1677 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1713 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
(...skipping 26 matching lines...) Expand all Loading... |
1704 | 1740 |
1705 // Blacklist "*" but force-install the importer extension. The shared module | 1741 // Blacklist "*" but force-install the importer extension. The shared module |
1706 // should be automatically installed too. | 1742 // should be automatically installed too. |
1707 base::ListValue blacklist; | 1743 base::ListValue blacklist; |
1708 blacklist.AppendString("*"); | 1744 blacklist.AppendString("*"); |
1709 base::ListValue forcelist; | 1745 base::ListValue forcelist; |
1710 forcelist.AppendString( | 1746 forcelist.AppendString( |
1711 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str())); | 1747 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str())); |
1712 PolicyMap policies; | 1748 PolicyMap policies; |
1713 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1749 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1714 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1750 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 1751 nullptr); |
1715 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | 1752 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
1716 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); | 1753 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, forcelist.DeepCopy(), |
| 1754 nullptr); |
1717 | 1755 |
1718 extensions::ExtensionRegistry* registry = | 1756 extensions::ExtensionRegistry* registry = |
1719 extensions::ExtensionRegistry::Get(browser()->profile()); | 1757 extensions::ExtensionRegistry::Get(browser()->profile()); |
1720 extensions::TestExtensionRegistryObserver observe_importer( | 1758 extensions::TestExtensionRegistryObserver observe_importer( |
1721 registry, kImporterId); | 1759 registry, kImporterId); |
1722 extensions::TestExtensionRegistryObserver observe_shared_module( | 1760 extensions::TestExtensionRegistryObserver observe_shared_module( |
1723 registry, kSharedModuleId); | 1761 registry, kSharedModuleId); |
1724 UpdateProviderPolicy(policies); | 1762 UpdateProviderPolicy(policies); |
1725 observe_importer.WaitForExtensionLoaded(); | 1763 observe_importer.WaitForExtensionLoaded(); |
1726 observe_shared_module.WaitForExtensionLoaded(); | 1764 observe_shared_module.WaitForExtensionLoaded(); |
(...skipping 26 matching lines...) Expand all Loading... |
1753 // Verifies that the whitelist can open exceptions to the blacklist. | 1791 // Verifies that the whitelist can open exceptions to the blacklist. |
1754 ExtensionService* service = extension_service(); | 1792 ExtensionService* service = extension_service(); |
1755 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1793 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1756 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1794 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1757 base::ListValue blacklist; | 1795 base::ListValue blacklist; |
1758 blacklist.Append(new base::StringValue("*")); | 1796 blacklist.Append(new base::StringValue("*")); |
1759 base::ListValue whitelist; | 1797 base::ListValue whitelist; |
1760 whitelist.Append(new base::StringValue(kGoodCrxId)); | 1798 whitelist.Append(new base::StringValue(kGoodCrxId)); |
1761 PolicyMap policies; | 1799 PolicyMap policies; |
1762 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1800 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1763 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1801 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 1802 nullptr); |
1764 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, | 1803 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, |
1765 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 1804 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), |
| 1805 nullptr); |
1766 UpdateProviderPolicy(policies); | 1806 UpdateProviderPolicy(policies); |
1767 // "adblock.crx" is blacklisted. | 1807 // "adblock.crx" is blacklisted. |
1768 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1808 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
1769 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1809 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1770 // "good.crx" has a whitelist exception. | 1810 // "good.crx" has a whitelist exception. |
1771 const extensions::Extension* good = InstallExtension(kGoodCrxName); | 1811 const extensions::Extension* good = InstallExtension(kGoodCrxName); |
1772 ASSERT_TRUE(good); | 1812 ASSERT_TRUE(good); |
1773 EXPECT_EQ(kGoodCrxId, good->id()); | 1813 EXPECT_EQ(kGoodCrxId, good->id()); |
1774 EXPECT_EQ(good, service->GetExtensionById(kGoodCrxId, true)); | 1814 EXPECT_EQ(good, service->GetExtensionById(kGoodCrxId, true)); |
1775 // The user can also remove this extension. | 1815 // The user can also remove this extension. |
(...skipping 12 matching lines...) Expand all Loading... |
1788 base::FilePath path = | 1828 base::FilePath path = |
1789 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); | 1829 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); |
1790 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); | 1830 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); |
1791 | 1831 |
1792 // Setting the forcelist extension should install "good_v1.crx". | 1832 // Setting the forcelist extension should install "good_v1.crx". |
1793 base::ListValue forcelist; | 1833 base::ListValue forcelist; |
1794 forcelist.Append(new base::StringValue( | 1834 forcelist.Append(new base::StringValue( |
1795 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str()))); | 1835 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str()))); |
1796 PolicyMap policies; | 1836 PolicyMap policies; |
1797 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | 1837 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
1798 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); | 1838 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, forcelist.DeepCopy(), |
| 1839 nullptr); |
1799 content::WindowedNotificationObserver observer( | 1840 content::WindowedNotificationObserver observer( |
1800 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 1841 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
1801 content::NotificationService::AllSources()); | 1842 content::NotificationService::AllSources()); |
1802 UpdateProviderPolicy(policies); | 1843 UpdateProviderPolicy(policies); |
1803 observer.Wait(); | 1844 observer.Wait(); |
1804 // Note: Cannot check that the notification details match the expected | 1845 // Note: Cannot check that the notification details match the expected |
1805 // exception, since the details object has already been freed prior to | 1846 // exception, since the details object has already been freed prior to |
1806 // the completion of observer.Wait(). | 1847 // the completion of observer.Wait(). |
1807 | 1848 |
1808 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); | 1849 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 dict_value.SetString(std::string(kGoodCrxId) + "." + | 1948 dict_value.SetString(std::string(kGoodCrxId) + "." + |
1908 extensions::schema_constants::kInstallationMode, | 1949 extensions::schema_constants::kInstallationMode, |
1909 extensions::schema_constants::kNormalInstalled); | 1950 extensions::schema_constants::kNormalInstalled); |
1910 dict_value.SetString( | 1951 dict_value.SetString( |
1911 std::string(kGoodCrxId) + "." + extensions::schema_constants::kUpdateUrl, | 1952 std::string(kGoodCrxId) + "." + extensions::schema_constants::kUpdateUrl, |
1912 url.spec()); | 1953 url.spec()); |
1913 PolicyMap policies; | 1954 PolicyMap policies; |
1914 policies.Set(key::kExtensionSettings, | 1955 policies.Set(key::kExtensionSettings, |
1915 POLICY_LEVEL_MANDATORY, | 1956 POLICY_LEVEL_MANDATORY, |
1916 POLICY_SCOPE_USER, | 1957 POLICY_SCOPE_USER, |
| 1958 POLICY_SOURCE_CLOUD, |
1917 dict_value.DeepCopy(), | 1959 dict_value.DeepCopy(), |
1918 NULL); | 1960 NULL); |
1919 content::WindowedNotificationObserver observer( | 1961 content::WindowedNotificationObserver observer( |
1920 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 1962 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
1921 content::NotificationService::AllSources()); | 1963 content::NotificationService::AllSources()); |
1922 UpdateProviderPolicy(policies); | 1964 UpdateProviderPolicy(policies); |
1923 observer.Wait(); | 1965 observer.Wait(); |
1924 | 1966 |
1925 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); | 1967 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); |
1926 | 1968 |
(...skipping 13 matching lines...) Expand all Loading... |
1940 // Verifies that extensions are blocked if policy specifies an allowed types | 1982 // Verifies that extensions are blocked if policy specifies an allowed types |
1941 // list and the extension's type is not on that list. | 1983 // list and the extension's type is not on that list. |
1942 ExtensionService* service = extension_service(); | 1984 ExtensionService* service = extension_service(); |
1943 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1985 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1944 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); | 1986 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); |
1945 | 1987 |
1946 base::ListValue allowed_types; | 1988 base::ListValue allowed_types; |
1947 allowed_types.AppendString("hosted_app"); | 1989 allowed_types.AppendString("hosted_app"); |
1948 PolicyMap policies; | 1990 PolicyMap policies; |
1949 policies.Set(key::kExtensionAllowedTypes, POLICY_LEVEL_MANDATORY, | 1991 policies.Set(key::kExtensionAllowedTypes, POLICY_LEVEL_MANDATORY, |
1950 POLICY_SCOPE_USER, allowed_types.DeepCopy(), NULL); | 1992 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, allowed_types.DeepCopy(), |
| 1993 nullptr); |
1951 UpdateProviderPolicy(policies); | 1994 UpdateProviderPolicy(policies); |
1952 | 1995 |
1953 // "good.crx" is blocked. | 1996 // "good.crx" is blocked. |
1954 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1997 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1955 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1998 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1956 | 1999 |
1957 // "hosted_app.crx" is of a whitelisted type. | 2000 // "hosted_app.crx" is of a whitelisted type. |
1958 const extensions::Extension* hosted_app = InstallExtension(kHostedAppCrxName); | 2001 const extensions::Extension* hosted_app = InstallExtension(kHostedAppCrxName); |
1959 ASSERT_TRUE(hosted_app); | 2002 ASSERT_TRUE(hosted_app); |
1960 EXPECT_EQ(kHostedAppCrxId, hosted_app->id()); | 2003 EXPECT_EQ(kHostedAppCrxId, hosted_app->id()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY); | 2041 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY); |
1999 PerformClick(0, 0); | 2042 PerformClick(0, 0); |
2000 download_observer.WaitForFinished(); | 2043 download_observer.WaitForFinished(); |
2001 | 2044 |
2002 // Install the policy and trigger another download. | 2045 // Install the policy and trigger another download. |
2003 base::ListValue install_sources; | 2046 base::ListValue install_sources; |
2004 install_sources.AppendString(install_source_url.spec()); | 2047 install_sources.AppendString(install_source_url.spec()); |
2005 install_sources.AppendString(referrer_url.spec()); | 2048 install_sources.AppendString(referrer_url.spec()); |
2006 PolicyMap policies; | 2049 PolicyMap policies; |
2007 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, | 2050 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, |
2008 POLICY_SCOPE_USER, install_sources.DeepCopy(), NULL); | 2051 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2052 install_sources.DeepCopy(), nullptr); |
2009 UpdateProviderPolicy(policies); | 2053 UpdateProviderPolicy(policies); |
2010 | 2054 |
2011 content::WindowedNotificationObserver observer( | 2055 content::WindowedNotificationObserver observer( |
2012 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 2056 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
2013 content::NotificationService::AllSources()); | 2057 content::NotificationService::AllSources()); |
2014 PerformClick(1, 0); | 2058 PerformClick(1, 0); |
2015 observer.Wait(); | 2059 observer.Wait(); |
2016 // Note: Cannot check that the notification details match the expected | 2060 // Note: Cannot check that the notification details match the expected |
2017 // exception, since the details object has already been freed prior to | 2061 // exception, since the details object has already been freed prior to |
2018 // the completion of observer.Wait(). | 2062 // the completion of observer.Wait(). |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 browser()->tab_strip_model()->GetActiveWebContents(); | 2272 browser()->tab_strip_model()->GetActiveWebContents(); |
2229 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); | 2273 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); |
2230 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2274 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
2231 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); | 2275 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); |
2232 | 2276 |
2233 // Now override with policy. | 2277 // Now override with policy. |
2234 PolicyMap policies; | 2278 PolicyMap policies; |
2235 policies.Set(key::kHomepageLocation, | 2279 policies.Set(key::kHomepageLocation, |
2236 POLICY_LEVEL_MANDATORY, | 2280 POLICY_LEVEL_MANDATORY, |
2237 POLICY_SCOPE_USER, | 2281 POLICY_SCOPE_USER, |
| 2282 POLICY_SOURCE_CLOUD, |
2238 new base::StringValue(chrome::kChromeUICreditsURL), | 2283 new base::StringValue(chrome::kChromeUICreditsURL), |
2239 NULL); | 2284 NULL); |
2240 UpdateProviderPolicy(policies); | 2285 UpdateProviderPolicy(policies); |
2241 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2286 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
2242 content::WaitForLoadStop(contents); | 2287 content::WaitForLoadStop(contents); |
2243 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); | 2288 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); |
2244 | 2289 |
2245 policies.Set(key::kHomepageIsNewTabPage, | 2290 policies.Set(key::kHomepageIsNewTabPage, |
2246 POLICY_LEVEL_MANDATORY, | 2291 POLICY_LEVEL_MANDATORY, |
2247 POLICY_SCOPE_USER, | 2292 POLICY_SCOPE_USER, |
| 2293 POLICY_SOURCE_CLOUD, |
2248 new base::FundamentalValue(true), | 2294 new base::FundamentalValue(true), |
2249 NULL); | 2295 NULL); |
2250 UpdateProviderPolicy(policies); | 2296 UpdateProviderPolicy(policies); |
2251 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2297 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
2252 content::WaitForLoadStop(contents); | 2298 content::WaitForLoadStop(contents); |
2253 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); | 2299 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); |
2254 } | 2300 } |
2255 | 2301 |
2256 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { | 2302 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
2257 // Verifies that incognito windows can't be opened when disabled by policy. | 2303 // Verifies that incognito windows can't be opened when disabled by policy. |
2258 | 2304 |
2259 const BrowserList* active_browser_list = | 2305 const BrowserList* active_browser_list = |
2260 BrowserList::GetInstance(chrome::GetActiveDesktop()); | 2306 BrowserList::GetInstance(chrome::GetActiveDesktop()); |
2261 | 2307 |
2262 // Disable incognito via policy and verify that incognito windows can't be | 2308 // Disable incognito via policy and verify that incognito windows can't be |
2263 // opened. | 2309 // opened. |
2264 EXPECT_EQ(1u, active_browser_list->size()); | 2310 EXPECT_EQ(1u, active_browser_list->size()); |
2265 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 2311 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); |
2266 PolicyMap policies; | 2312 PolicyMap policies; |
2267 policies.Set(key::kIncognitoEnabled, | 2313 policies.Set(key::kIncognitoEnabled, |
2268 POLICY_LEVEL_MANDATORY, | 2314 POLICY_LEVEL_MANDATORY, |
2269 POLICY_SCOPE_USER, | 2315 POLICY_SCOPE_USER, |
| 2316 POLICY_SOURCE_CLOUD, |
2270 new base::FundamentalValue(false), | 2317 new base::FundamentalValue(false), |
2271 NULL); | 2318 NULL); |
2272 UpdateProviderPolicy(policies); | 2319 UpdateProviderPolicy(policies); |
2273 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2320 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
2274 EXPECT_EQ(1u, active_browser_list->size()); | 2321 EXPECT_EQ(1u, active_browser_list->size()); |
2275 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 2322 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); |
2276 | 2323 |
2277 // Enable via policy and verify that incognito windows can be opened. | 2324 // Enable via policy and verify that incognito windows can be opened. |
2278 policies.Set(key::kIncognitoEnabled, | 2325 policies.Set(key::kIncognitoEnabled, |
2279 POLICY_LEVEL_MANDATORY, | 2326 POLICY_LEVEL_MANDATORY, |
2280 POLICY_SCOPE_USER, | 2327 POLICY_SCOPE_USER, |
| 2328 POLICY_SOURCE_CLOUD, |
2281 new base::FundamentalValue(true), | 2329 new base::FundamentalValue(true), |
2282 NULL); | 2330 NULL); |
2283 UpdateProviderPolicy(policies); | 2331 UpdateProviderPolicy(policies); |
2284 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2332 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
2285 EXPECT_EQ(2u, active_browser_list->size()); | 2333 EXPECT_EQ(2u, active_browser_list->size()); |
2286 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); | 2334 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); |
2287 } | 2335 } |
2288 | 2336 |
2289 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 2337 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
2290 // Verifies that Javascript can be disabled. | 2338 // Verifies that Javascript can be disabled. |
2291 content::WebContents* contents = | 2339 content::WebContents* contents = |
2292 browser()->tab_strip_model()->GetActiveWebContents(); | 2340 browser()->tab_strip_model()->GetActiveWebContents(); |
2293 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2341 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
2294 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2342 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
2295 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2343 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
2296 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2344 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
2297 | 2345 |
2298 // Disable Javascript via policy. | 2346 // Disable Javascript via policy. |
2299 PolicyMap policies; | 2347 PolicyMap policies; |
2300 policies.Set(key::kJavascriptEnabled, | 2348 policies.Set(key::kJavascriptEnabled, |
2301 POLICY_LEVEL_MANDATORY, | 2349 POLICY_LEVEL_MANDATORY, |
2302 POLICY_SCOPE_USER, | 2350 POLICY_SCOPE_USER, |
| 2351 POLICY_SOURCE_CLOUD, |
2303 new base::FundamentalValue(false), | 2352 new base::FundamentalValue(false), |
2304 NULL); | 2353 NULL); |
2305 UpdateProviderPolicy(policies); | 2354 UpdateProviderPolicy(policies); |
2306 // Reload the page. | 2355 // Reload the page. |
2307 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2356 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
2308 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2357 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
2309 // Developer tools still work when javascript is disabled. | 2358 // Developer tools still work when javascript is disabled. |
2310 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2359 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
2311 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2360 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
2312 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2361 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
2313 // Javascript is always enabled for the internal pages. | 2362 // Javascript is always enabled for the internal pages. |
2314 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 2363 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
2315 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2364 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
2316 | 2365 |
2317 // The javascript content setting policy overrides the javascript policy. | 2366 // The javascript content setting policy overrides the javascript policy. |
2318 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2367 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
2319 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2368 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
2320 policies.Set(key::kDefaultJavaScriptSetting, | 2369 policies.Set(key::kDefaultJavaScriptSetting, |
2321 POLICY_LEVEL_MANDATORY, | 2370 POLICY_LEVEL_MANDATORY, |
2322 POLICY_SCOPE_USER, | 2371 POLICY_SCOPE_USER, |
| 2372 POLICY_SOURCE_CLOUD, |
2323 new base::FundamentalValue(CONTENT_SETTING_ALLOW), | 2373 new base::FundamentalValue(CONTENT_SETTING_ALLOW), |
2324 NULL); | 2374 NULL); |
2325 UpdateProviderPolicy(policies); | 2375 UpdateProviderPolicy(policies); |
2326 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2376 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
2327 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2377 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
2328 } | 2378 } |
2329 | 2379 |
2330 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { | 2380 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { |
2331 PrefService* prefs = browser()->profile()->GetPrefs(); | 2381 PrefService* prefs = browser()->profile()->GetPrefs(); |
2332 | 2382 |
2333 // Enabled by default. | 2383 // Enabled by default. |
2334 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2384 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
2335 | 2385 |
2336 // Disable by old, deprecated policy. | 2386 // Disable by old, deprecated policy. |
2337 PolicyMap policies; | 2387 PolicyMap policies; |
2338 policies.Set(key::kDnsPrefetchingEnabled, | 2388 policies.Set(key::kDnsPrefetchingEnabled, |
2339 POLICY_LEVEL_MANDATORY, | 2389 POLICY_LEVEL_MANDATORY, |
2340 POLICY_SCOPE_USER, | 2390 POLICY_SCOPE_USER, |
| 2391 POLICY_SOURCE_CLOUD, |
2341 new base::FundamentalValue(false), | 2392 new base::FundamentalValue(false), |
2342 NULL); | 2393 NULL); |
2343 UpdateProviderPolicy(policies); | 2394 UpdateProviderPolicy(policies); |
2344 | 2395 |
2345 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); | 2396 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); |
2346 | 2397 |
2347 // Enabled by new policy, this should override old one. | 2398 // Enabled by new policy, this should override old one. |
2348 policies.Set( | 2399 policies.Set( |
2349 key::kNetworkPredictionOptions, | 2400 key::kNetworkPredictionOptions, |
2350 POLICY_LEVEL_MANDATORY, | 2401 POLICY_LEVEL_MANDATORY, |
2351 POLICY_SCOPE_USER, | 2402 POLICY_SCOPE_USER, |
| 2403 POLICY_SOURCE_CLOUD, |
2352 new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS), | 2404 new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS), |
2353 NULL); | 2405 NULL); |
2354 UpdateProviderPolicy(policies); | 2406 UpdateProviderPolicy(policies); |
2355 | 2407 |
2356 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2408 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
2357 } | 2409 } |
2358 | 2410 |
2359 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { | 2411 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { |
2360 // Verifies that browsing history is not saved. | 2412 // Verifies that browsing history is not saved. |
2361 PolicyMap policies; | 2413 PolicyMap policies; |
2362 policies.Set(key::kSavingBrowserHistoryDisabled, | 2414 policies.Set(key::kSavingBrowserHistoryDisabled, |
2363 POLICY_LEVEL_MANDATORY, | 2415 POLICY_LEVEL_MANDATORY, |
2364 POLICY_SCOPE_USER, | 2416 POLICY_SCOPE_USER, |
| 2417 POLICY_SOURCE_CLOUD, |
2365 new base::FundamentalValue(true), | 2418 new base::FundamentalValue(true), |
2366 NULL); | 2419 NULL); |
2367 UpdateProviderPolicy(policies); | 2420 UpdateProviderPolicy(policies); |
2368 GURL url = ui_test_utils::GetTestUrl( | 2421 GURL url = ui_test_utils::GetTestUrl( |
2369 base::FilePath(base::FilePath::kCurrentDirectory), | 2422 base::FilePath(base::FilePath::kCurrentDirectory), |
2370 base::FilePath(FILE_PATH_LITERAL("empty.html"))); | 2423 base::FilePath(FILE_PATH_LITERAL("empty.html"))); |
2371 ui_test_utils::NavigateToURL(browser(), url); | 2424 ui_test_utils::NavigateToURL(browser(), url); |
2372 // Verify that the navigation wasn't saved in the history. | 2425 // Verify that the navigation wasn't saved in the history. |
2373 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); | 2426 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); |
2374 EXPECT_EQ(0u, enumerator1.urls().size()); | 2427 EXPECT_EQ(0u, enumerator1.urls().size()); |
2375 | 2428 |
2376 // Now flip the policy and try again. | 2429 // Now flip the policy and try again. |
2377 policies.Set(key::kSavingBrowserHistoryDisabled, | 2430 policies.Set(key::kSavingBrowserHistoryDisabled, |
2378 POLICY_LEVEL_MANDATORY, | 2431 POLICY_LEVEL_MANDATORY, |
2379 POLICY_SCOPE_USER, | 2432 POLICY_SCOPE_USER, |
| 2433 POLICY_SOURCE_CLOUD, |
2380 new base::FundamentalValue(false), | 2434 new base::FundamentalValue(false), |
2381 NULL); | 2435 NULL); |
2382 UpdateProviderPolicy(policies); | 2436 UpdateProviderPolicy(policies); |
2383 ui_test_utils::NavigateToURL(browser(), url); | 2437 ui_test_utils::NavigateToURL(browser(), url); |
2384 // Verify that the navigation was saved in the history. | 2438 // Verify that the navigation was saved in the history. |
2385 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); | 2439 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); |
2386 ASSERT_EQ(1u, enumerator2.urls().size()); | 2440 ASSERT_EQ(1u, enumerator2.urls().size()); |
2387 EXPECT_EQ(url, enumerator2.urls()[0]); | 2441 EXPECT_EQ(url, enumerator2.urls()[0]); |
2388 } | 2442 } |
2389 | 2443 |
(...skipping 15 matching lines...) Expand all Loading... |
2405 ASSERT_TRUE(contents); | 2459 ASSERT_TRUE(contents); |
2406 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); | 2460 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); |
2407 ASSERT_TRUE(infobar_service); | 2461 ASSERT_TRUE(infobar_service); |
2408 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2462 EXPECT_EQ(0u, infobar_service->infobar_count()); |
2409 | 2463 |
2410 // Force enable the translate feature. | 2464 // Force enable the translate feature. |
2411 PolicyMap policies; | 2465 PolicyMap policies; |
2412 policies.Set(key::kTranslateEnabled, | 2466 policies.Set(key::kTranslateEnabled, |
2413 POLICY_LEVEL_MANDATORY, | 2467 POLICY_LEVEL_MANDATORY, |
2414 POLICY_SCOPE_USER, | 2468 POLICY_SCOPE_USER, |
| 2469 POLICY_SOURCE_CLOUD, |
2415 new base::FundamentalValue(true), | 2470 new base::FundamentalValue(true), |
2416 NULL); | 2471 NULL); |
2417 UpdateProviderPolicy(policies); | 2472 UpdateProviderPolicy(policies); |
2418 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test | 2473 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test |
2419 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the | 2474 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the |
2420 // TranslateManager observes. This allows checking that an infobar is NOT | 2475 // TranslateManager observes. This allows checking that an infobar is NOT |
2421 // shown below, without polling for infobars for some indeterminate amount | 2476 // shown below, without polling for infobars for some indeterminate amount |
2422 // of time. | 2477 // of time. |
2423 GURL url = ui_test_utils::GetTestUrl( | 2478 GURL url = ui_test_utils::GetTestUrl( |
2424 base::FilePath(), | 2479 base::FilePath(), |
(...skipping 25 matching lines...) Expand all Loading... |
2450 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 2505 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
2451 translate_infobar_delegate->translate_step()); | 2506 translate_infobar_delegate->translate_step()); |
2452 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); | 2507 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); |
2453 | 2508 |
2454 // Now force disable translate. | 2509 // Now force disable translate. |
2455 infobar_service->RemoveInfoBar(infobar); | 2510 infobar_service->RemoveInfoBar(infobar); |
2456 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2511 EXPECT_EQ(0u, infobar_service->infobar_count()); |
2457 policies.Set(key::kTranslateEnabled, | 2512 policies.Set(key::kTranslateEnabled, |
2458 POLICY_LEVEL_MANDATORY, | 2513 POLICY_LEVEL_MANDATORY, |
2459 POLICY_SCOPE_USER, | 2514 POLICY_SCOPE_USER, |
| 2515 POLICY_SOURCE_CLOUD, |
2460 new base::FundamentalValue(false), | 2516 new base::FundamentalValue(false), |
2461 NULL); | 2517 NULL); |
2462 UpdateProviderPolicy(policies); | 2518 UpdateProviderPolicy(policies); |
2463 // Navigating to the same URL now doesn't trigger an infobar. | 2519 // Navigating to the same URL now doesn't trigger an infobar. |
2464 content::WindowedNotificationObserver language_observer2( | 2520 content::WindowedNotificationObserver language_observer2( |
2465 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 2521 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
2466 content::NotificationService::AllSources()); | 2522 content::NotificationService::AllSources()); |
2467 ui_test_utils::NavigateToURL(browser(), url); | 2523 ui_test_utils::NavigateToURL(browser(), url); |
2468 language_observer2.Wait(); | 2524 language_observer2.Wait(); |
2469 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2525 EXPECT_EQ(0u, infobar_service->infobar_count()); |
(...skipping 22 matching lines...) Expand all Loading... |
2492 } | 2548 } |
2493 | 2549 |
2494 // Verify that "bbb.com" opens before applying the blacklist. | 2550 // Verify that "bbb.com" opens before applying the blacklist. |
2495 CheckCanOpenURL(browser(), kURLS[1]); | 2551 CheckCanOpenURL(browser(), kURLS[1]); |
2496 | 2552 |
2497 // Set a blacklist. | 2553 // Set a blacklist. |
2498 base::ListValue blacklist; | 2554 base::ListValue blacklist; |
2499 blacklist.Append(new base::StringValue("bbb.com")); | 2555 blacklist.Append(new base::StringValue("bbb.com")); |
2500 PolicyMap policies; | 2556 PolicyMap policies; |
2501 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2557 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2502 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2558 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 2559 nullptr); |
2503 UpdateProviderPolicy(policies); | 2560 UpdateProviderPolicy(policies); |
2504 FlushBlacklistPolicy(); | 2561 FlushBlacklistPolicy(); |
2505 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. | 2562 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. |
2506 CheckCanOpenURL(browser(), kURLS[0]); | 2563 CheckCanOpenURL(browser(), kURLS[0]); |
2507 for (size_t i = 1; i < arraysize(kURLS); ++i) | 2564 for (size_t i = 1; i < arraysize(kURLS); ++i) |
2508 CheckURLIsBlocked(browser(), kURLS[i]); | 2565 CheckURLIsBlocked(browser(), kURLS[i]); |
2509 | 2566 |
2510 // Whitelist some sites of bbb.com. | 2567 // Whitelist some sites of bbb.com. |
2511 base::ListValue whitelist; | 2568 base::ListValue whitelist; |
2512 whitelist.Append(new base::StringValue("sub.bbb.com")); | 2569 whitelist.Append(new base::StringValue("sub.bbb.com")); |
2513 whitelist.Append(new base::StringValue("bbb.com/policy")); | 2570 whitelist.Append(new base::StringValue("bbb.com/policy")); |
2514 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, | 2571 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, |
2515 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 2572 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), |
| 2573 nullptr); |
2516 UpdateProviderPolicy(policies); | 2574 UpdateProviderPolicy(policies); |
2517 FlushBlacklistPolicy(); | 2575 FlushBlacklistPolicy(); |
2518 CheckURLIsBlocked(browser(), kURLS[1]); | 2576 CheckURLIsBlocked(browser(), kURLS[1]); |
2519 CheckCanOpenURL(browser(), kURLS[2]); | 2577 CheckCanOpenURL(browser(), kURLS[2]); |
2520 CheckCanOpenURL(browser(), kURLS[3]); | 2578 CheckCanOpenURL(browser(), kURLS[3]); |
2521 CheckCanOpenURL(browser(), kURLS[4]); | 2579 CheckCanOpenURL(browser(), kURLS[4]); |
2522 | 2580 |
2523 { | 2581 { |
2524 base::RunLoop loop; | 2582 base::RunLoop loop; |
2525 BrowserThread::PostTaskAndReply( | 2583 BrowserThread::PostTaskAndReply( |
(...skipping 15 matching lines...) Expand all Loading... |
2541 GURL subframe_url = URLRequestMockHTTPJob::GetMockUrl( | 2599 GURL subframe_url = URLRequestMockHTTPJob::GetMockUrl( |
2542 base::FilePath(FILE_PATH_LITERAL("policy/blank.html"))); | 2600 base::FilePath(FILE_PATH_LITERAL("policy/blank.html"))); |
2543 | 2601 |
2544 // Set a blacklist containing the image and the iframe which are used by the | 2602 // Set a blacklist containing the image and the iframe which are used by the |
2545 // main document. | 2603 // main document. |
2546 base::ListValue blacklist; | 2604 base::ListValue blacklist; |
2547 blacklist.Append(new base::StringValue(image_url.spec().c_str())); | 2605 blacklist.Append(new base::StringValue(image_url.spec().c_str())); |
2548 blacklist.Append(new base::StringValue(subframe_url.spec().c_str())); | 2606 blacklist.Append(new base::StringValue(subframe_url.spec().c_str())); |
2549 PolicyMap policies; | 2607 PolicyMap policies; |
2550 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2608 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2551 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2609 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 2610 nullptr); |
2552 UpdateProviderPolicy(policies); | 2611 UpdateProviderPolicy(policies); |
2553 FlushBlacklistPolicy(); | 2612 FlushBlacklistPolicy(); |
2554 | 2613 |
2555 std::string blacklisted_image_load_result; | 2614 std::string blacklisted_image_load_result; |
2556 ui_test_utils::NavigateToURL(browser(), main_url); | 2615 ui_test_utils::NavigateToURL(browser(), main_url); |
2557 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2616 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2558 browser()->tab_strip_model()->GetActiveWebContents(), | 2617 browser()->tab_strip_model()->GetActiveWebContents(), |
2559 "window.domAutomationController.send(imageLoadResult)", | 2618 "window.domAutomationController.send(imageLoadResult)", |
2560 &blacklisted_image_load_result)); | 2619 &blacklisted_image_load_result)); |
2561 EXPECT_EQ("success", blacklisted_image_load_result); | 2620 EXPECT_EQ("success", blacklisted_image_load_result); |
(...skipping 25 matching lines...) Expand all Loading... |
2587 const std::string file_path2 = folder_path + "basic.html"; | 2646 const std::string file_path2 = folder_path + "basic.html"; |
2588 | 2647 |
2589 CheckCanOpenURL(browser(), file_path1.c_str()); | 2648 CheckCanOpenURL(browser(), file_path1.c_str()); |
2590 CheckCanOpenURL(browser(), file_path2.c_str()); | 2649 CheckCanOpenURL(browser(), file_path2.c_str()); |
2591 | 2650 |
2592 // Set a blacklist for all the files. | 2651 // Set a blacklist for all the files. |
2593 base::ListValue blacklist; | 2652 base::ListValue blacklist; |
2594 blacklist.Append(new base::StringValue("file://*")); | 2653 blacklist.Append(new base::StringValue("file://*")); |
2595 PolicyMap policies; | 2654 PolicyMap policies; |
2596 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2655 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2597 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2656 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 2657 nullptr); |
2598 UpdateProviderPolicy(policies); | 2658 UpdateProviderPolicy(policies); |
2599 FlushBlacklistPolicy(); | 2659 FlushBlacklistPolicy(); |
2600 | 2660 |
2601 CheckURLIsBlocked(browser(), file_path1.c_str()); | 2661 CheckURLIsBlocked(browser(), file_path1.c_str()); |
2602 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2662 CheckURLIsBlocked(browser(), file_path2.c_str()); |
2603 | 2663 |
2604 // Replace the URLblacklist with disabling the file scheme. | 2664 // Replace the URLblacklist with disabling the file scheme. |
2605 blacklist.Remove(base::StringValue("file://*"), NULL); | 2665 blacklist.Remove(base::StringValue("file://*"), NULL); |
2606 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2666 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2607 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2667 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 2668 nullptr); |
2608 UpdateProviderPolicy(policies); | 2669 UpdateProviderPolicy(policies); |
2609 FlushBlacklistPolicy(); | 2670 FlushBlacklistPolicy(); |
2610 | 2671 |
2611 PrefService* prefs = browser()->profile()->GetPrefs(); | 2672 PrefService* prefs = browser()->profile()->GetPrefs(); |
2612 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); | 2673 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); |
2613 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), | 2674 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), |
2614 list_url->end()); | 2675 list_url->end()); |
2615 | 2676 |
2616 base::ListValue disabledscheme; | 2677 base::ListValue disabledscheme; |
2617 disabledscheme.Append(new base::StringValue("file")); | 2678 disabledscheme.Append(new base::StringValue("file")); |
2618 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, | 2679 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, |
2619 POLICY_SCOPE_USER, disabledscheme.DeepCopy(), NULL); | 2680 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2681 disabledscheme.DeepCopy(), nullptr); |
2620 UpdateProviderPolicy(policies); | 2682 UpdateProviderPolicy(policies); |
2621 FlushBlacklistPolicy(); | 2683 FlushBlacklistPolicy(); |
2622 | 2684 |
2623 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); | 2685 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); |
2624 EXPECT_NE(list_url->Find(base::StringValue("file://*")), | 2686 EXPECT_NE(list_url->Find(base::StringValue("file://*")), |
2625 list_url->end()); | 2687 list_url->end()); |
2626 | 2688 |
2627 // Whitelist one folder and blacklist an another just inside. | 2689 // Whitelist one folder and blacklist an another just inside. |
2628 base::ListValue whitelist; | 2690 base::ListValue whitelist; |
2629 whitelist.Append(new base::StringValue(base_path)); | 2691 whitelist.Append(new base::StringValue(base_path)); |
2630 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, | 2692 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, |
2631 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 2693 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), |
| 2694 nullptr); |
2632 blacklist.Append(new base::StringValue(folder_path)); | 2695 blacklist.Append(new base::StringValue(folder_path)); |
2633 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2696 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2634 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2697 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 2698 nullptr); |
2635 UpdateProviderPolicy(policies); | 2699 UpdateProviderPolicy(policies); |
2636 FlushBlacklistPolicy(); | 2700 FlushBlacklistPolicy(); |
2637 | 2701 |
2638 CheckCanOpenURL(browser(), file_path1.c_str()); | 2702 CheckCanOpenURL(browser(), file_path1.c_str()); |
2639 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2703 CheckURLIsBlocked(browser(), file_path2.c_str()); |
2640 } | 2704 } |
2641 | 2705 |
2642 namespace { | 2706 namespace { |
2643 | 2707 |
2644 void GetSSLVersionFallbackMinOnIOThread( | 2708 void GetSSLVersionFallbackMinOnIOThread( |
(...skipping 28 matching lines...) Expand all Loading... |
2673 prefs->GetString(prefs::kSSLVersionFallbackMin)); | 2737 prefs->GetString(prefs::kSSLVersionFallbackMin)); |
2674 | 2738 |
2675 EXPECT_NE(default_value, new_value); | 2739 EXPECT_NE(default_value, new_value); |
2676 EXPECT_NE(net::SSL_PROTOCOL_VERSION_TLS1_2, | 2740 EXPECT_NE(net::SSL_PROTOCOL_VERSION_TLS1_2, |
2677 GetSSLVersionFallbackMin(browser()->profile())); | 2741 GetSSLVersionFallbackMin(browser()->profile())); |
2678 | 2742 |
2679 PolicyMap policies; | 2743 PolicyMap policies; |
2680 policies.Set(key::kSSLVersionFallbackMin, | 2744 policies.Set(key::kSSLVersionFallbackMin, |
2681 POLICY_LEVEL_MANDATORY, | 2745 POLICY_LEVEL_MANDATORY, |
2682 POLICY_SCOPE_USER, | 2746 POLICY_SCOPE_USER, |
| 2747 POLICY_SOURCE_CLOUD, |
2683 new base::StringValue(new_value), | 2748 new base::StringValue(new_value), |
2684 NULL); | 2749 NULL); |
2685 UpdateProviderPolicy(policies); | 2750 UpdateProviderPolicy(policies); |
2686 | 2751 |
2687 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_2, | 2752 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_2, |
2688 GetSSLVersionFallbackMin(browser()->profile())); | 2753 GetSSLVersionFallbackMin(browser()->profile())); |
2689 } | 2754 } |
2690 | 2755 |
2691 #if !defined(OS_MACOSX) | 2756 #if !defined(OS_MACOSX) |
2692 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { | 2757 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { |
2693 PolicyMap policies; | 2758 PolicyMap policies; |
2694 policies.Set(key::kFullscreenAllowed, | 2759 policies.Set(key::kFullscreenAllowed, |
2695 POLICY_LEVEL_MANDATORY, | 2760 POLICY_LEVEL_MANDATORY, |
2696 POLICY_SCOPE_USER, | 2761 POLICY_SCOPE_USER, |
| 2762 POLICY_SOURCE_CLOUD, |
2697 new base::FundamentalValue(false), | 2763 new base::FundamentalValue(false), |
2698 NULL); | 2764 NULL); |
2699 UpdateProviderPolicy(policies); | 2765 UpdateProviderPolicy(policies); |
2700 | 2766 |
2701 BrowserWindow* browser_window = browser()->window(); | 2767 BrowserWindow* browser_window = browser()->window(); |
2702 ASSERT_TRUE(browser_window); | 2768 ASSERT_TRUE(browser_window); |
2703 | 2769 |
2704 EXPECT_FALSE(browser_window->IsFullscreen()); | 2770 EXPECT_FALSE(browser_window->IsFullscreen()); |
2705 chrome::ToggleFullscreenMode(browser()); | 2771 chrome::ToggleFullscreenMode(browser()); |
2706 EXPECT_FALSE(browser_window->IsFullscreen()); | 2772 EXPECT_FALSE(browser_window->IsFullscreen()); |
2707 } | 2773 } |
2708 | 2774 |
2709 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { | 2775 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { |
2710 PolicyMap policies; | 2776 PolicyMap policies; |
2711 policies.Set(key::kFullscreenAllowed, | 2777 policies.Set(key::kFullscreenAllowed, |
2712 POLICY_LEVEL_MANDATORY, | 2778 POLICY_LEVEL_MANDATORY, |
2713 POLICY_SCOPE_USER, | 2779 POLICY_SCOPE_USER, |
| 2780 POLICY_SOURCE_CLOUD, |
2714 new base::FundamentalValue(false), | 2781 new base::FundamentalValue(false), |
2715 NULL); | 2782 NULL); |
2716 UpdateProviderPolicy(policies); | 2783 UpdateProviderPolicy(policies); |
2717 | 2784 |
2718 const extensions::Extension* extension = | 2785 const extensions::Extension* extension = |
2719 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); | 2786 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); |
2720 ASSERT_TRUE(extension); | 2787 ASSERT_TRUE(extension); |
2721 | 2788 |
2722 // Launch an app that tries to open a fullscreen window. | 2789 // Launch an app that tries to open a fullscreen window. |
2723 TestAddAppWindowObserver add_window_observer( | 2790 TestAddAppWindowObserver add_window_observer( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2775 bool prior_state = audio_handler->IsOutputMuted(); | 2842 bool prior_state = audio_handler->IsOutputMuted(); |
2776 // Make sure the audio is not muted and then toggle the policy and observe | 2843 // Make sure the audio is not muted and then toggle the policy and observe |
2777 // if the output mute changed event is fired. | 2844 // if the output mute changed event is fired. |
2778 audio_handler->SetOutputMute(false); | 2845 audio_handler->SetOutputMute(false); |
2779 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2846 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
2780 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2847 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
2781 PolicyMap policies; | 2848 PolicyMap policies; |
2782 policies.Set(key::kAudioOutputAllowed, | 2849 policies.Set(key::kAudioOutputAllowed, |
2783 POLICY_LEVEL_MANDATORY, | 2850 POLICY_LEVEL_MANDATORY, |
2784 POLICY_SCOPE_USER, | 2851 POLICY_SCOPE_USER, |
| 2852 POLICY_SOURCE_CLOUD, |
2785 new base::FundamentalValue(false), | 2853 new base::FundamentalValue(false), |
2786 NULL); | 2854 NULL); |
2787 UpdateProviderPolicy(policies); | 2855 UpdateProviderPolicy(policies); |
2788 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2856 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
2789 // This should not change the state now and should not trigger output mute | 2857 // This should not change the state now and should not trigger output mute |
2790 // changed event. | 2858 // changed event. |
2791 audio_handler->SetOutputMute(false); | 2859 audio_handler->SetOutputMute(false); |
2792 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2860 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
2793 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2861 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
2794 | 2862 |
2795 // Toggle back and observe if the output mute changed event is fired. | 2863 // Toggle back and observe if the output mute changed event is fired. |
2796 policies.Set(key::kAudioOutputAllowed, | 2864 policies.Set(key::kAudioOutputAllowed, |
2797 POLICY_LEVEL_MANDATORY, | 2865 POLICY_LEVEL_MANDATORY, |
2798 POLICY_SCOPE_USER, | 2866 POLICY_SCOPE_USER, |
| 2867 POLICY_SOURCE_CLOUD, |
2799 new base::FundamentalValue(true), | 2868 new base::FundamentalValue(true), |
2800 NULL); | 2869 NULL); |
2801 UpdateProviderPolicy(policies); | 2870 UpdateProviderPolicy(policies); |
2802 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2871 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
2803 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2872 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
2804 audio_handler->SetOutputMute(true); | 2873 audio_handler->SetOutputMute(true); |
2805 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2874 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
2806 EXPECT_EQ(2, test_observer->output_mute_changed_count()); | 2875 EXPECT_EQ(2, test_observer->output_mute_changed_count()); |
2807 // Revert the prior state. | 2876 // Revert the prior state. |
2808 audio_handler->SetOutputMute(prior_state); | 2877 audio_handler->SetOutputMute(prior_state); |
(...skipping 19 matching lines...) Expand all Loading... |
2828 content::NotificationService::AllSources()); | 2897 content::NotificationService::AllSources()); |
2829 | 2898 |
2830 // Set the session length limit to 3 hours. Verify that the session is not | 2899 // Set the session length limit to 3 hours. Verify that the session is not |
2831 // terminated. | 2900 // terminated. |
2832 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2901 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
2833 .Times(0); | 2902 .Times(0); |
2834 PolicyMap policies; | 2903 PolicyMap policies; |
2835 policies.Set(key::kSessionLengthLimit, | 2904 policies.Set(key::kSessionLengthLimit, |
2836 POLICY_LEVEL_MANDATORY, | 2905 POLICY_LEVEL_MANDATORY, |
2837 POLICY_SCOPE_USER, | 2906 POLICY_SCOPE_USER, |
| 2907 POLICY_SOURCE_CLOUD, |
2838 new base::FundamentalValue(kThreeHoursInMs), | 2908 new base::FundamentalValue(kThreeHoursInMs), |
2839 NULL); | 2909 NULL); |
2840 UpdateProviderPolicy(policies); | 2910 UpdateProviderPolicy(policies); |
2841 base::RunLoop().RunUntilIdle(); | 2911 base::RunLoop().RunUntilIdle(); |
2842 Mock::VerifyAndClearExpectations(&observer); | 2912 Mock::VerifyAndClearExpectations(&observer); |
2843 | 2913 |
2844 // Decrease the session length limit to 1 hour. Verify that the session is | 2914 // Decrease the session length limit to 1 hour. Verify that the session is |
2845 // terminated immediately. | 2915 // terminated immediately. |
2846 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2916 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
2847 policies.Set(key::kSessionLengthLimit, | 2917 policies.Set(key::kSessionLengthLimit, |
2848 POLICY_LEVEL_MANDATORY, | 2918 POLICY_LEVEL_MANDATORY, |
2849 POLICY_SCOPE_USER, | 2919 POLICY_SCOPE_USER, |
| 2920 POLICY_SOURCE_CLOUD, |
2850 new base::FundamentalValue(kOneHourInMs), | 2921 new base::FundamentalValue(kOneHourInMs), |
2851 NULL); | 2922 NULL); |
2852 UpdateProviderPolicy(policies); | 2923 UpdateProviderPolicy(policies); |
2853 base::RunLoop().RunUntilIdle(); | 2924 base::RunLoop().RunUntilIdle(); |
2854 Mock::VerifyAndClearExpectations(&observer); | 2925 Mock::VerifyAndClearExpectations(&observer); |
2855 } | 2926 } |
2856 | 2927 |
2857 // Disabled, see http://crbug.com/315308. | 2928 // Disabled, see http://crbug.com/315308. |
2858 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2929 IN_PROC_BROWSER_TEST_F(PolicyTest, |
2859 DISABLED_PRE_WaitForInitialUserActivityUsatisfied) { | 2930 DISABLED_PRE_WaitForInitialUserActivityUsatisfied) { |
(...skipping 11 matching lines...) Expand all Loading... |
2871 content::MockNotificationObserver observer; | 2942 content::MockNotificationObserver observer; |
2872 content::NotificationRegistrar registrar; | 2943 content::NotificationRegistrar registrar; |
2873 registrar.Add(&observer, | 2944 registrar.Add(&observer, |
2874 chrome::NOTIFICATION_APP_TERMINATING, | 2945 chrome::NOTIFICATION_APP_TERMINATING, |
2875 content::NotificationService::AllSources()); | 2946 content::NotificationService::AllSources()); |
2876 | 2947 |
2877 // Require initial user activity. | 2948 // Require initial user activity. |
2878 PolicyMap policies; | 2949 PolicyMap policies; |
2879 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2950 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
2880 POLICY_SCOPE_USER, | 2951 POLICY_SCOPE_USER, |
| 2952 POLICY_SOURCE_CLOUD, |
2881 new base::FundamentalValue(true), | 2953 new base::FundamentalValue(true), |
2882 NULL); | 2954 NULL); |
2883 UpdateProviderPolicy(policies); | 2955 UpdateProviderPolicy(policies); |
2884 base::RunLoop().RunUntilIdle(); | 2956 base::RunLoop().RunUntilIdle(); |
2885 | 2957 |
2886 // Set the session length limit to 1 hour. Verify that the session is not | 2958 // Set the session length limit to 1 hour. Verify that the session is not |
2887 // terminated. | 2959 // terminated. |
2888 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2960 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
2889 .Times(0); | 2961 .Times(0); |
2890 policies.Set(key::kSessionLengthLimit, | 2962 policies.Set(key::kSessionLengthLimit, |
2891 POLICY_LEVEL_MANDATORY, | 2963 POLICY_LEVEL_MANDATORY, |
2892 POLICY_SCOPE_USER, | 2964 POLICY_SCOPE_USER, |
| 2965 POLICY_SOURCE_CLOUD, |
2893 new base::FundamentalValue(kOneHourInMs), | 2966 new base::FundamentalValue(kOneHourInMs), |
2894 NULL); | 2967 NULL); |
2895 UpdateProviderPolicy(policies); | 2968 UpdateProviderPolicy(policies); |
2896 base::RunLoop().RunUntilIdle(); | 2969 base::RunLoop().RunUntilIdle(); |
2897 Mock::VerifyAndClearExpectations(&observer); | 2970 Mock::VerifyAndClearExpectations(&observer); |
2898 } | 2971 } |
2899 | 2972 |
2900 // Disabled, see http://crbug.com/315308. | 2973 // Disabled, see http://crbug.com/315308. |
2901 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2974 IN_PROC_BROWSER_TEST_F(PolicyTest, |
2902 DISABLED_PRE_WaitForInitialUserActivitySatisfied) { | 2975 DISABLED_PRE_WaitForInitialUserActivitySatisfied) { |
(...skipping 16 matching lines...) Expand all Loading... |
2919 chrome::NOTIFICATION_APP_TERMINATING, | 2992 chrome::NOTIFICATION_APP_TERMINATING, |
2920 content::NotificationService::AllSources()); | 2993 content::NotificationService::AllSources()); |
2921 | 2994 |
2922 // Require initial user activity and set the session length limit to 3 hours. | 2995 // Require initial user activity and set the session length limit to 3 hours. |
2923 // Verify that the session is not terminated. | 2996 // Verify that the session is not terminated. |
2924 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2997 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
2925 .Times(0); | 2998 .Times(0); |
2926 PolicyMap policies; | 2999 PolicyMap policies; |
2927 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 3000 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
2928 POLICY_SCOPE_USER, | 3001 POLICY_SCOPE_USER, |
| 3002 POLICY_SOURCE_CLOUD, |
2929 new base::FundamentalValue(true), | 3003 new base::FundamentalValue(true), |
2930 NULL); | 3004 NULL); |
2931 policies.Set(key::kSessionLengthLimit, | 3005 policies.Set(key::kSessionLengthLimit, |
2932 POLICY_LEVEL_MANDATORY, | 3006 POLICY_LEVEL_MANDATORY, |
2933 POLICY_SCOPE_USER, | 3007 POLICY_SCOPE_USER, |
| 3008 POLICY_SOURCE_CLOUD, |
2934 new base::FundamentalValue(kThreeHoursInMs), | 3009 new base::FundamentalValue(kThreeHoursInMs), |
2935 NULL); | 3010 NULL); |
2936 UpdateProviderPolicy(policies); | 3011 UpdateProviderPolicy(policies); |
2937 base::RunLoop().RunUntilIdle(); | 3012 base::RunLoop().RunUntilIdle(); |
2938 Mock::VerifyAndClearExpectations(&observer); | 3013 Mock::VerifyAndClearExpectations(&observer); |
2939 | 3014 |
2940 // Decrease the session length limit to 1 hour. Verify that the session is | 3015 // Decrease the session length limit to 1 hour. Verify that the session is |
2941 // terminated immediately. | 3016 // terminated immediately. |
2942 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 3017 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
2943 policies.Set(key::kSessionLengthLimit, | 3018 policies.Set(key::kSessionLengthLimit, |
2944 POLICY_LEVEL_MANDATORY, | 3019 POLICY_LEVEL_MANDATORY, |
2945 POLICY_SCOPE_USER, | 3020 POLICY_SCOPE_USER, |
| 3021 POLICY_SOURCE_CLOUD, |
2946 new base::FundamentalValue(kOneHourInMs), | 3022 new base::FundamentalValue(kOneHourInMs), |
2947 NULL); | 3023 NULL); |
2948 UpdateProviderPolicy(policies); | 3024 UpdateProviderPolicy(policies); |
2949 base::RunLoop().RunUntilIdle(); | 3025 base::RunLoop().RunUntilIdle(); |
2950 Mock::VerifyAndClearExpectations(&observer); | 3026 Mock::VerifyAndClearExpectations(&observer); |
2951 } | 3027 } |
2952 | 3028 |
2953 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { | 3029 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { |
2954 // Verifies that the large cursor accessibility feature can be controlled | 3030 // Verifies that the large cursor accessibility feature can be controlled |
2955 // through policy. | 3031 // through policy. |
2956 chromeos::AccessibilityManager* accessibility_manager = | 3032 chromeos::AccessibilityManager* accessibility_manager = |
2957 chromeos::AccessibilityManager::Get(); | 3033 chromeos::AccessibilityManager::Get(); |
2958 | 3034 |
2959 // Manually enable the large cursor. | 3035 // Manually enable the large cursor. |
2960 accessibility_manager->EnableLargeCursor(true); | 3036 accessibility_manager->EnableLargeCursor(true); |
2961 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); | 3037 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); |
2962 | 3038 |
2963 // Verify that policy overrides the manual setting. | 3039 // Verify that policy overrides the manual setting. |
2964 PolicyMap policies; | 3040 PolicyMap policies; |
2965 policies.Set(key::kLargeCursorEnabled, | 3041 policies.Set(key::kLargeCursorEnabled, |
2966 POLICY_LEVEL_MANDATORY, | 3042 POLICY_LEVEL_MANDATORY, |
2967 POLICY_SCOPE_USER, | 3043 POLICY_SCOPE_USER, |
| 3044 POLICY_SOURCE_CLOUD, |
2968 new base::FundamentalValue(false), | 3045 new base::FundamentalValue(false), |
2969 NULL); | 3046 NULL); |
2970 UpdateProviderPolicy(policies); | 3047 UpdateProviderPolicy(policies); |
2971 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 3048 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
2972 | 3049 |
2973 // Verify that the large cursor cannot be enabled manually anymore. | 3050 // Verify that the large cursor cannot be enabled manually anymore. |
2974 accessibility_manager->EnableLargeCursor(true); | 3051 accessibility_manager->EnableLargeCursor(true); |
2975 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 3052 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
2976 } | 3053 } |
2977 | 3054 |
2978 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { | 3055 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { |
2979 // Verifies that the spoken feedback accessibility feature can be controlled | 3056 // Verifies that the spoken feedback accessibility feature can be controlled |
2980 // through policy. | 3057 // through policy. |
2981 chromeos::AccessibilityManager* accessibility_manager = | 3058 chromeos::AccessibilityManager* accessibility_manager = |
2982 chromeos::AccessibilityManager::Get(); | 3059 chromeos::AccessibilityManager::Get(); |
2983 | 3060 |
2984 // Manually enable spoken feedback. | 3061 // Manually enable spoken feedback. |
2985 accessibility_manager->EnableSpokenFeedback( | 3062 accessibility_manager->EnableSpokenFeedback( |
2986 true, ui::A11Y_NOTIFICATION_NONE); | 3063 true, ui::A11Y_NOTIFICATION_NONE); |
2987 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); | 3064 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); |
2988 | 3065 |
2989 // Verify that policy overrides the manual setting. | 3066 // Verify that policy overrides the manual setting. |
2990 PolicyMap policies; | 3067 PolicyMap policies; |
2991 policies.Set(key::kSpokenFeedbackEnabled, | 3068 policies.Set(key::kSpokenFeedbackEnabled, |
2992 POLICY_LEVEL_MANDATORY, | 3069 POLICY_LEVEL_MANDATORY, |
2993 POLICY_SCOPE_USER, | 3070 POLICY_SCOPE_USER, |
| 3071 POLICY_SOURCE_CLOUD, |
2994 new base::FundamentalValue(false), | 3072 new base::FundamentalValue(false), |
2995 NULL); | 3073 NULL); |
2996 UpdateProviderPolicy(policies); | 3074 UpdateProviderPolicy(policies); |
2997 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 3075 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
2998 | 3076 |
2999 // Verify that spoken feedback cannot be enabled manually anymore. | 3077 // Verify that spoken feedback cannot be enabled manually anymore. |
3000 accessibility_manager->EnableSpokenFeedback( | 3078 accessibility_manager->EnableSpokenFeedback( |
3001 true, ui::A11Y_NOTIFICATION_NONE); | 3079 true, ui::A11Y_NOTIFICATION_NONE); |
3002 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 3080 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
3003 } | 3081 } |
3004 | 3082 |
3005 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { | 3083 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { |
3006 // Verifies that the high contrast mode accessibility feature can be | 3084 // Verifies that the high contrast mode accessibility feature can be |
3007 // controlled through policy. | 3085 // controlled through policy. |
3008 chromeos::AccessibilityManager* accessibility_manager = | 3086 chromeos::AccessibilityManager* accessibility_manager = |
3009 chromeos::AccessibilityManager::Get(); | 3087 chromeos::AccessibilityManager::Get(); |
3010 | 3088 |
3011 // Manually enable high contrast mode. | 3089 // Manually enable high contrast mode. |
3012 accessibility_manager->EnableHighContrast(true); | 3090 accessibility_manager->EnableHighContrast(true); |
3013 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); | 3091 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); |
3014 | 3092 |
3015 // Verify that policy overrides the manual setting. | 3093 // Verify that policy overrides the manual setting. |
3016 PolicyMap policies; | 3094 PolicyMap policies; |
3017 policies.Set(key::kHighContrastEnabled, | 3095 policies.Set(key::kHighContrastEnabled, |
3018 POLICY_LEVEL_MANDATORY, | 3096 POLICY_LEVEL_MANDATORY, |
3019 POLICY_SCOPE_USER, | 3097 POLICY_SCOPE_USER, |
| 3098 POLICY_SOURCE_CLOUD, |
3020 new base::FundamentalValue(false), | 3099 new base::FundamentalValue(false), |
3021 NULL); | 3100 NULL); |
3022 UpdateProviderPolicy(policies); | 3101 UpdateProviderPolicy(policies); |
3023 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 3102 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
3024 | 3103 |
3025 // Verify that high contrast mode cannot be enabled manually anymore. | 3104 // Verify that high contrast mode cannot be enabled manually anymore. |
3026 accessibility_manager->EnableHighContrast(true); | 3105 accessibility_manager->EnableHighContrast(true); |
3027 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 3106 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
3028 } | 3107 } |
3029 | 3108 |
3030 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { | 3109 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { |
3031 // Verifies that the screen magnifier can be disabled through policy. | 3110 // Verifies that the screen magnifier can be disabled through policy. |
3032 chromeos::MagnificationManager* magnification_manager = | 3111 chromeos::MagnificationManager* magnification_manager = |
3033 chromeos::MagnificationManager::Get(); | 3112 chromeos::MagnificationManager::Get(); |
3034 | 3113 |
3035 // Manually enable the full-screen magnifier. | 3114 // Manually enable the full-screen magnifier. |
3036 magnification_manager->SetMagnifierType(ui::MAGNIFIER_FULL); | 3115 magnification_manager->SetMagnifierType(ui::MAGNIFIER_FULL); |
3037 magnification_manager->SetMagnifierEnabled(true); | 3116 magnification_manager->SetMagnifierEnabled(true); |
3038 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 3117 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
3039 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 3118 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
3040 | 3119 |
3041 // Verify that policy overrides the manual setting. | 3120 // Verify that policy overrides the manual setting. |
3042 PolicyMap policies; | 3121 PolicyMap policies; |
3043 policies.Set(key::kScreenMagnifierType, | 3122 policies.Set(key::kScreenMagnifierType, |
3044 POLICY_LEVEL_MANDATORY, | 3123 POLICY_LEVEL_MANDATORY, |
3045 POLICY_SCOPE_USER, | 3124 POLICY_SCOPE_USER, |
| 3125 POLICY_SOURCE_CLOUD, |
3046 new base::FundamentalValue(0), | 3126 new base::FundamentalValue(0), |
3047 NULL); | 3127 NULL); |
3048 UpdateProviderPolicy(policies); | 3128 UpdateProviderPolicy(policies); |
3049 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 3129 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
3050 | 3130 |
3051 // Verify that the screen magnifier cannot be enabled manually anymore. | 3131 // Verify that the screen magnifier cannot be enabled manually anymore. |
3052 magnification_manager->SetMagnifierEnabled(true); | 3132 magnification_manager->SetMagnifierEnabled(true); |
3053 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 3133 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
3054 } | 3134 } |
3055 | 3135 |
3056 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { | 3136 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { |
3057 // Verifies that the full-screen magnifier can be enabled through policy. | 3137 // Verifies that the full-screen magnifier can be enabled through policy. |
3058 chromeos::MagnificationManager* magnification_manager = | 3138 chromeos::MagnificationManager* magnification_manager = |
3059 chromeos::MagnificationManager::Get(); | 3139 chromeos::MagnificationManager::Get(); |
3060 | 3140 |
3061 // Verify that the screen magnifier is initially disabled. | 3141 // Verify that the screen magnifier is initially disabled. |
3062 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 3142 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
3063 | 3143 |
3064 // Verify that policy can enable the full-screen magnifier. | 3144 // Verify that policy can enable the full-screen magnifier. |
3065 PolicyMap policies; | 3145 PolicyMap policies; |
3066 policies.Set(key::kScreenMagnifierType, | 3146 policies.Set(key::kScreenMagnifierType, |
3067 POLICY_LEVEL_MANDATORY, | 3147 POLICY_LEVEL_MANDATORY, |
3068 POLICY_SCOPE_USER, | 3148 POLICY_SCOPE_USER, |
| 3149 POLICY_SOURCE_CLOUD, |
3069 new base::FundamentalValue(ui::MAGNIFIER_FULL), | 3150 new base::FundamentalValue(ui::MAGNIFIER_FULL), |
3070 NULL); | 3151 NULL); |
3071 UpdateProviderPolicy(policies); | 3152 UpdateProviderPolicy(policies); |
3072 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 3153 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
3073 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 3154 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
3074 | 3155 |
3075 // Verify that the screen magnifier cannot be disabled manually anymore. | 3156 // Verify that the screen magnifier cannot be disabled manually anymore. |
3076 magnification_manager->SetMagnifierEnabled(false); | 3157 magnification_manager->SetMagnifierEnabled(false); |
3077 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 3158 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
3078 } | 3159 } |
3079 | 3160 |
3080 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { | 3161 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { |
3081 // Verifies that the on-screen keyboard accessibility feature can be | 3162 // Verifies that the on-screen keyboard accessibility feature can be |
3082 // controlled through policy. | 3163 // controlled through policy. |
3083 chromeos::AccessibilityManager* accessibility_manager = | 3164 chromeos::AccessibilityManager* accessibility_manager = |
3084 chromeos::AccessibilityManager::Get(); | 3165 chromeos::AccessibilityManager::Get(); |
3085 | 3166 |
3086 // Manually enable the on-screen keyboard. | 3167 // Manually enable the on-screen keyboard. |
3087 accessibility_manager->EnableVirtualKeyboard(true); | 3168 accessibility_manager->EnableVirtualKeyboard(true); |
3088 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); | 3169 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); |
3089 | 3170 |
3090 // Verify that policy overrides the manual setting. | 3171 // Verify that policy overrides the manual setting. |
3091 PolicyMap policies; | 3172 PolicyMap policies; |
3092 policies.Set(key::kVirtualKeyboardEnabled, | 3173 policies.Set(key::kVirtualKeyboardEnabled, |
3093 POLICY_LEVEL_MANDATORY, | 3174 POLICY_LEVEL_MANDATORY, |
3094 POLICY_SCOPE_USER, | 3175 POLICY_SCOPE_USER, |
| 3176 POLICY_SOURCE_CLOUD, |
3095 new base::FundamentalValue(false), | 3177 new base::FundamentalValue(false), |
3096 NULL); | 3178 NULL); |
3097 UpdateProviderPolicy(policies); | 3179 UpdateProviderPolicy(policies); |
3098 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 3180 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
3099 | 3181 |
3100 // Verify that the on-screen keyboard cannot be enabled manually anymore. | 3182 // Verify that the on-screen keyboard cannot be enabled manually anymore. |
3101 accessibility_manager->EnableVirtualKeyboard(true); | 3183 accessibility_manager->EnableVirtualKeyboard(true); |
3102 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 3184 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
3103 } | 3185 } |
3104 | 3186 |
3105 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { | 3187 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { |
3106 // Verify keyboard disabled by default. | 3188 // Verify keyboard disabled by default. |
3107 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3189 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3108 // Verify keyboard can be toggled by default. | 3190 // Verify keyboard can be toggled by default. |
3109 keyboard::SetTouchKeyboardEnabled(true); | 3191 keyboard::SetTouchKeyboardEnabled(true); |
3110 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 3192 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
3111 keyboard::SetTouchKeyboardEnabled(false); | 3193 keyboard::SetTouchKeyboardEnabled(false); |
3112 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3194 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3113 | 3195 |
3114 // Verify enabling the policy takes effect immediately and that that user | 3196 // Verify enabling the policy takes effect immediately and that that user |
3115 // cannot disable the keyboard.. | 3197 // cannot disable the keyboard.. |
3116 PolicyMap policies; | 3198 PolicyMap policies; |
3117 policies.Set(key::kTouchVirtualKeyboardEnabled, | 3199 policies.Set(key::kTouchVirtualKeyboardEnabled, |
3118 POLICY_LEVEL_MANDATORY, | 3200 POLICY_LEVEL_MANDATORY, |
3119 POLICY_SCOPE_USER, | 3201 POLICY_SCOPE_USER, |
| 3202 POLICY_SOURCE_CLOUD, |
3120 new base::FundamentalValue(true), | 3203 new base::FundamentalValue(true), |
3121 NULL); | 3204 NULL); |
3122 UpdateProviderPolicy(policies); | 3205 UpdateProviderPolicy(policies); |
3123 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 3206 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
3124 keyboard::SetTouchKeyboardEnabled(false); | 3207 keyboard::SetTouchKeyboardEnabled(false); |
3125 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 3208 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
3126 | 3209 |
3127 // Verify that disabling the policy takes effect immediately and that the user | 3210 // Verify that disabling the policy takes effect immediately and that the user |
3128 // cannot enable the keyboard. | 3211 // cannot enable the keyboard. |
3129 policies.Set(key::kTouchVirtualKeyboardEnabled, | 3212 policies.Set(key::kTouchVirtualKeyboardEnabled, |
3130 POLICY_LEVEL_MANDATORY, | 3213 POLICY_LEVEL_MANDATORY, |
3131 POLICY_SCOPE_USER, | 3214 POLICY_SCOPE_USER, |
| 3215 POLICY_SOURCE_CLOUD, |
3132 new base::FundamentalValue(false), | 3216 new base::FundamentalValue(false), |
3133 NULL); | 3217 NULL); |
3134 UpdateProviderPolicy(policies); | 3218 UpdateProviderPolicy(policies); |
3135 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3219 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3136 keyboard::SetTouchKeyboardEnabled(true); | 3220 keyboard::SetTouchKeyboardEnabled(true); |
3137 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3221 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3138 } | 3222 } |
3139 | 3223 |
3140 #endif | 3224 #endif |
3141 | 3225 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3196 } | 3280 } |
3197 | 3281 |
3198 void HomepageIsNotNTP() { | 3282 void HomepageIsNotNTP() { |
3199 // Verifies that policy can set the startup pages to the homepage, when | 3283 // Verifies that policy can set the startup pages to the homepage, when |
3200 // the homepage is not the NTP. | 3284 // the homepage is not the NTP. |
3201 PolicyMap policies; | 3285 PolicyMap policies; |
3202 policies.Set( | 3286 policies.Set( |
3203 key::kRestoreOnStartup, | 3287 key::kRestoreOnStartup, |
3204 POLICY_LEVEL_MANDATORY, | 3288 POLICY_LEVEL_MANDATORY, |
3205 POLICY_SCOPE_USER, | 3289 POLICY_SCOPE_USER, |
| 3290 POLICY_SOURCE_CLOUD, |
3206 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), | 3291 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), |
3207 NULL); | 3292 NULL); |
3208 policies.Set(key::kHomepageIsNewTabPage, | 3293 policies.Set(key::kHomepageIsNewTabPage, |
3209 POLICY_LEVEL_MANDATORY, | 3294 POLICY_LEVEL_MANDATORY, |
3210 POLICY_SCOPE_USER, | 3295 POLICY_SCOPE_USER, |
| 3296 POLICY_SOURCE_CLOUD, |
3211 new base::FundamentalValue(false), | 3297 new base::FundamentalValue(false), |
3212 NULL); | 3298 NULL); |
3213 policies.Set(key::kHomepageLocation, | 3299 policies.Set(key::kHomepageLocation, |
3214 POLICY_LEVEL_MANDATORY, | 3300 POLICY_LEVEL_MANDATORY, |
3215 POLICY_SCOPE_USER, | 3301 POLICY_SCOPE_USER, |
| 3302 POLICY_SOURCE_CLOUD, |
3216 new base::StringValue(kRestoredURLs[1]), | 3303 new base::StringValue(kRestoredURLs[1]), |
3217 NULL); | 3304 NULL); |
3218 provider_.UpdateChromePolicy(policies); | 3305 provider_.UpdateChromePolicy(policies); |
3219 | 3306 |
3220 expected_urls_.push_back(GURL(kRestoredURLs[1])); | 3307 expected_urls_.push_back(GURL(kRestoredURLs[1])); |
3221 } | 3308 } |
3222 | 3309 |
3223 void HomepageIsNTP() { | 3310 void HomepageIsNTP() { |
3224 // Verifies that policy can set the startup pages to the homepage, when | 3311 // Verifies that policy can set the startup pages to the homepage, when |
3225 // the homepage is the NTP. | 3312 // the homepage is the NTP. |
3226 PolicyMap policies; | 3313 PolicyMap policies; |
3227 policies.Set( | 3314 policies.Set( |
3228 key::kRestoreOnStartup, | 3315 key::kRestoreOnStartup, |
3229 POLICY_LEVEL_MANDATORY, | 3316 POLICY_LEVEL_MANDATORY, |
3230 POLICY_SCOPE_USER, | 3317 POLICY_SCOPE_USER, |
| 3318 POLICY_SOURCE_CLOUD, |
3231 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), | 3319 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), |
3232 NULL); | 3320 NULL); |
3233 policies.Set(key::kHomepageIsNewTabPage, | 3321 policies.Set(key::kHomepageIsNewTabPage, |
3234 POLICY_LEVEL_MANDATORY, | 3322 POLICY_LEVEL_MANDATORY, |
3235 POLICY_SCOPE_USER, | 3323 POLICY_SCOPE_USER, |
| 3324 POLICY_SOURCE_CLOUD, |
3236 new base::FundamentalValue(true), | 3325 new base::FundamentalValue(true), |
3237 NULL); | 3326 NULL); |
3238 provider_.UpdateChromePolicy(policies); | 3327 provider_.UpdateChromePolicy(policies); |
3239 | 3328 |
3240 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); | 3329 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); |
3241 } | 3330 } |
3242 | 3331 |
3243 void ListOfURLs() { | 3332 void ListOfURLs() { |
3244 // Verifies that policy can set the startup pages to a list of URLs. | 3333 // Verifies that policy can set the startup pages to a list of URLs. |
3245 base::ListValue urls; | 3334 base::ListValue urls; |
3246 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { | 3335 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { |
3247 urls.Append(new base::StringValue(kRestoredURLs[i])); | 3336 urls.Append(new base::StringValue(kRestoredURLs[i])); |
3248 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 3337 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
3249 } | 3338 } |
3250 PolicyMap policies; | 3339 PolicyMap policies; |
3251 policies.Set(key::kRestoreOnStartup, | 3340 policies.Set(key::kRestoreOnStartup, |
3252 POLICY_LEVEL_MANDATORY, | 3341 POLICY_LEVEL_MANDATORY, |
3253 POLICY_SCOPE_USER, | 3342 POLICY_SCOPE_USER, |
| 3343 POLICY_SOURCE_CLOUD, |
3254 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), | 3344 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), |
3255 NULL); | 3345 NULL); |
3256 policies.Set( | 3346 policies.Set( |
3257 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3347 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
3258 urls.DeepCopy(), NULL); | 3348 POLICY_SOURCE_CLOUD, urls.DeepCopy(), nullptr); |
3259 provider_.UpdateChromePolicy(policies); | 3349 provider_.UpdateChromePolicy(policies); |
3260 } | 3350 } |
3261 | 3351 |
3262 void NTP() { | 3352 void NTP() { |
3263 // Verifies that policy can set the startup page to the NTP. | 3353 // Verifies that policy can set the startup page to the NTP. |
3264 PolicyMap policies; | 3354 PolicyMap policies; |
3265 policies.Set( | 3355 policies.Set( |
3266 key::kRestoreOnStartup, | 3356 key::kRestoreOnStartup, |
3267 POLICY_LEVEL_MANDATORY, | 3357 POLICY_LEVEL_MANDATORY, |
3268 POLICY_SCOPE_USER, | 3358 POLICY_SCOPE_USER, |
| 3359 POLICY_SOURCE_CLOUD, |
3269 new base::FundamentalValue(SessionStartupPref::kPrefValueNewTab), | 3360 new base::FundamentalValue(SessionStartupPref::kPrefValueNewTab), |
3270 NULL); | 3361 NULL); |
3271 provider_.UpdateChromePolicy(policies); | 3362 provider_.UpdateChromePolicy(policies); |
3272 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); | 3363 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); |
3273 } | 3364 } |
3274 | 3365 |
3275 void Last() { | 3366 void Last() { |
3276 // Verifies that policy can set the startup pages to the last session. | 3367 // Verifies that policy can set the startup pages to the last session. |
3277 PolicyMap policies; | 3368 PolicyMap policies; |
3278 policies.Set(key::kRestoreOnStartup, | 3369 policies.Set(key::kRestoreOnStartup, |
3279 POLICY_LEVEL_MANDATORY, | 3370 POLICY_LEVEL_MANDATORY, |
3280 POLICY_SCOPE_USER, | 3371 POLICY_SCOPE_USER, |
| 3372 POLICY_SOURCE_CLOUD, |
3281 new base::FundamentalValue(SessionStartupPref::kPrefValueLast), | 3373 new base::FundamentalValue(SessionStartupPref::kPrefValueLast), |
3282 NULL); | 3374 NULL); |
3283 provider_.UpdateChromePolicy(policies); | 3375 provider_.UpdateChromePolicy(policies); |
3284 // This should restore the tabs opened at PRE_RunTest below. | 3376 // This should restore the tabs opened at PRE_RunTest below. |
3285 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) | 3377 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) |
3286 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 3378 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
3287 } | 3379 } |
3288 | 3380 |
3289 std::vector<GURL> expected_urls_; | 3381 std::vector<GURL> expected_urls_; |
3290 }; | 3382 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3335 public: | 3427 public: |
3336 PolicyStatisticsCollectorTest() {} | 3428 PolicyStatisticsCollectorTest() {} |
3337 ~PolicyStatisticsCollectorTest() override {} | 3429 ~PolicyStatisticsCollectorTest() override {} |
3338 | 3430 |
3339 void SetUpInProcessBrowserTestFixture() override { | 3431 void SetUpInProcessBrowserTestFixture() override { |
3340 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3432 PolicyTest::SetUpInProcessBrowserTestFixture(); |
3341 PolicyMap policies; | 3433 PolicyMap policies; |
3342 policies.Set(key::kShowHomeButton, | 3434 policies.Set(key::kShowHomeButton, |
3343 POLICY_LEVEL_MANDATORY, | 3435 POLICY_LEVEL_MANDATORY, |
3344 POLICY_SCOPE_USER, | 3436 POLICY_SCOPE_USER, |
| 3437 POLICY_SOURCE_CLOUD, |
3345 new base::FundamentalValue(true), | 3438 new base::FundamentalValue(true), |
3346 NULL); | 3439 NULL); |
3347 policies.Set(key::kBookmarkBarEnabled, | 3440 policies.Set(key::kBookmarkBarEnabled, |
3348 POLICY_LEVEL_MANDATORY, | 3441 POLICY_LEVEL_MANDATORY, |
3349 POLICY_SCOPE_USER, | 3442 POLICY_SCOPE_USER, |
| 3443 POLICY_SOURCE_CLOUD, |
3350 new base::FundamentalValue(false), | 3444 new base::FundamentalValue(false), |
3351 NULL); | 3445 NULL); |
3352 policies.Set(key::kHomepageLocation, | 3446 policies.Set(key::kHomepageLocation, |
3353 POLICY_LEVEL_MANDATORY, | 3447 POLICY_LEVEL_MANDATORY, |
3354 POLICY_SCOPE_USER, | 3448 POLICY_SCOPE_USER, |
| 3449 POLICY_SOURCE_CLOUD, |
3355 new base::StringValue("http://chromium.org"), | 3450 new base::StringValue("http://chromium.org"), |
3356 NULL); | 3451 NULL); |
3357 provider_.UpdateChromePolicy(policies); | 3452 provider_.UpdateChromePolicy(policies); |
3358 } | 3453 } |
3359 }; | 3454 }; |
3360 | 3455 |
3361 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { | 3456 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { |
3362 // Verifies that policy usage histograms are collected at startup. | 3457 // Verifies that policy usage histograms are collected at startup. |
3363 | 3458 |
3364 // BrowserPolicyConnector::Init() has already been called. Make sure the | 3459 // BrowserPolicyConnector::Init() has already been called. Make sure the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3412 // audio or video capture allow policy and must never be NULL. | 3507 // audio or video capture allow policy and must never be NULL. |
3413 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist | 3508 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist |
3414 // policy is set. If non-NULL, the whitelist policy is set to contain either | 3509 // policy is set. If non-NULL, the whitelist policy is set to contain either |
3415 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. | 3510 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. |
3416 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, | 3511 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, |
3417 const char* whitelist_policy, | 3512 const char* whitelist_policy, |
3418 const char* allow_rule) { | 3513 const char* allow_rule) { |
3419 policies->Set(policy_name, | 3514 policies->Set(policy_name, |
3420 POLICY_LEVEL_MANDATORY, | 3515 POLICY_LEVEL_MANDATORY, |
3421 POLICY_SCOPE_USER, | 3516 POLICY_SCOPE_USER, |
| 3517 POLICY_SOURCE_CLOUD, |
3422 new base::FundamentalValue(policy_value_), | 3518 new base::FundamentalValue(policy_value_), |
3423 NULL); | 3519 NULL); |
3424 | 3520 |
3425 if (whitelist_policy) { | 3521 if (whitelist_policy) { |
3426 // Add an entry to the whitelist that allows the specified URL regardless | 3522 // Add an entry to the whitelist that allows the specified URL regardless |
3427 // of the setting of kAudioCapturedAllowed. | 3523 // of the setting of kAudioCapturedAllowed. |
3428 base::ListValue* list = new base::ListValue(); | 3524 base::ListValue* list = new base::ListValue(); |
3429 if (allow_rule) { | 3525 if (allow_rule) { |
3430 list->AppendString(allow_rule); | 3526 list->AppendString(allow_rule); |
3431 request_url_allowed_via_whitelist_ = true; | 3527 request_url_allowed_via_whitelist_ = true; |
3432 } else { | 3528 } else { |
3433 list->AppendString(ContentSettingsPattern::Wildcard().ToString()); | 3529 list->AppendString(ContentSettingsPattern::Wildcard().ToString()); |
3434 // We should ignore all wildcard entries in the whitelist, so even | 3530 // We should ignore all wildcard entries in the whitelist, so even |
3435 // though we've added an entry, it should be ignored and our expectation | 3531 // though we've added an entry, it should be ignored and our expectation |
3436 // is that the request has not been allowed via the whitelist. | 3532 // is that the request has not been allowed via the whitelist. |
3437 request_url_allowed_via_whitelist_ = false; | 3533 request_url_allowed_via_whitelist_ = false; |
3438 } | 3534 } |
3439 policies->Set(whitelist_policy, POLICY_LEVEL_MANDATORY, | 3535 policies->Set(whitelist_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
3440 POLICY_SCOPE_USER, list, NULL); | 3536 POLICY_SOURCE_CLOUD, list, nullptr); |
3441 } | 3537 } |
3442 } | 3538 } |
3443 | 3539 |
3444 void Accept(const content::MediaStreamDevices& devices, | 3540 void Accept(const content::MediaStreamDevices& devices, |
3445 content::MediaStreamRequestResult result, | 3541 content::MediaStreamRequestResult result, |
3446 scoped_ptr<content::MediaStreamUI> ui) { | 3542 scoped_ptr<content::MediaStreamUI> ui) { |
3447 if (policy_value_ || request_url_allowed_via_whitelist_) { | 3543 if (policy_value_ || request_url_allowed_via_whitelist_) { |
3448 ASSERT_EQ(1U, devices.size()); | 3544 ASSERT_EQ(1U, devices.size()); |
3449 ASSERT_EQ("fake_dev", devices[0].id); | 3545 ASSERT_EQ("fake_dev", devices[0].id); |
3450 } else { | 3546 } else { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3625 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | 3721 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), |
3626 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 3722 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
3627 ASSERT_TRUE(https_server_expired.Start()); | 3723 ASSERT_TRUE(https_server_expired.Start()); |
3628 | 3724 |
3629 // Set the enterprise policy to disallow opt-in. | 3725 // Set the enterprise policy to disallow opt-in. |
3630 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3726 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
3631 EXPECT_TRUE( | 3727 EXPECT_TRUE( |
3632 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3728 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
3633 PolicyMap policies; | 3729 PolicyMap policies; |
3634 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, | 3730 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, |
3635 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3731 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3636 new base::FundamentalValue(false), NULL); | 3732 new base::FundamentalValue(false), nullptr); |
3637 UpdateProviderPolicy(policies); | 3733 UpdateProviderPolicy(policies); |
3638 EXPECT_FALSE( | 3734 EXPECT_FALSE( |
3639 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3735 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
3640 | 3736 |
3641 // Navigate to an SSL error page. | 3737 // Navigate to an SSL error page. |
3642 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3738 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
3643 | 3739 |
3644 const content::InterstitialPage* const interstitial = | 3740 const content::InterstitialPage* const interstitial = |
3645 content::InterstitialPage::GetInterstitialPage( | 3741 content::InterstitialPage::GetInterstitialPage( |
3646 browser()->tab_strip_model()->GetActiveWebContents()); | 3742 browser()->tab_strip_model()->GetActiveWebContents()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3709 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | 3805 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), |
3710 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 3806 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
3711 ASSERT_TRUE(https_server_expired.Start()); | 3807 ASSERT_TRUE(https_server_expired.Start()); |
3712 | 3808 |
3713 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3809 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
3714 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3810 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
3715 | 3811 |
3716 // Disallowing the proceed link by setting the policy to |false|. | 3812 // Disallowing the proceed link by setting the policy to |false|. |
3717 PolicyMap policies; | 3813 PolicyMap policies; |
3718 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, | 3814 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, |
3719 POLICY_SCOPE_USER, new base::FundamentalValue(false), NULL); | 3815 POLICY_SCOPE_USER,POLICY_SOURCE_CLOUD, |
| 3816 new base::FundamentalValue(false), nullptr); |
3720 UpdateProviderPolicy(policies); | 3817 UpdateProviderPolicy(policies); |
3721 | 3818 |
3722 // Policy should not allow overriding anymore. | 3819 // Policy should not allow overriding anymore. |
3723 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3820 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
3724 | 3821 |
3725 // Policy disallows overriding - navigate to an SSL error page and expect no | 3822 // Policy disallows overriding - navigate to an SSL error page and expect no |
3726 // proceed link. | 3823 // proceed link. |
3727 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3824 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
3728 const content::InterstitialPage* const interstitial = | 3825 const content::InterstitialPage* const interstitial = |
3729 content::InterstitialPage::GetInterstitialPage( | 3826 content::InterstitialPage::GetInterstitialPage( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3789 std::string value; | 3886 std::string value; |
3790 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 3887 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
3791 EXPECT_EQ("restricted", value); | 3888 EXPECT_EQ("restricted", value); |
3792 } | 3889 } |
3793 | 3890 |
3794 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { | 3891 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { |
3795 base::ListValue blacklist; | 3892 base::ListValue blacklist; |
3796 blacklist.Append(new base::StringValue("host.name")); | 3893 blacklist.Append(new base::StringValue("host.name")); |
3797 PolicyMap policies; | 3894 PolicyMap policies; |
3798 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3895 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
3799 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 3896 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 3897 nullptr); |
3800 UpdateProviderPolicy(policies); | 3898 UpdateProviderPolicy(policies); |
3801 | 3899 |
3802 PrefService* prefs = browser()->profile()->GetPrefs(); | 3900 PrefService* prefs = browser()->profile()->GetPrefs(); |
3803 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3901 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3804 prefs, "host.name")); | 3902 prefs, "host.name")); |
3805 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3903 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3806 prefs, "other.host.name")); | 3904 prefs, "other.host.name")); |
3807 } | 3905 } |
3808 | 3906 |
3809 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { | 3907 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { |
3810 base::ListValue blacklist; | 3908 base::ListValue blacklist; |
3811 blacklist.Append(new base::StringValue("*")); | 3909 blacklist.Append(new base::StringValue("*")); |
3812 PolicyMap policies; | 3910 PolicyMap policies; |
3813 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3911 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
3814 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 3912 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 3913 nullptr); |
3815 UpdateProviderPolicy(policies); | 3914 UpdateProviderPolicy(policies); |
3816 | 3915 |
3817 PrefService* prefs = browser()->profile()->GetPrefs(); | 3916 PrefService* prefs = browser()->profile()->GetPrefs(); |
3818 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3917 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3819 prefs, "host.name")); | 3918 prefs, "host.name")); |
3820 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3919 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3821 prefs, "other.host.name")); | 3920 prefs, "other.host.name")); |
3822 } | 3921 } |
3823 | 3922 |
3824 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { | 3923 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { |
3825 base::ListValue blacklist; | 3924 base::ListValue blacklist; |
3826 blacklist.Append(new base::StringValue("*")); | 3925 blacklist.Append(new base::StringValue("*")); |
3827 base::ListValue whitelist; | 3926 base::ListValue whitelist; |
3828 whitelist.Append(new base::StringValue("host.name")); | 3927 whitelist.Append(new base::StringValue("host.name")); |
3829 PolicyMap policies; | 3928 PolicyMap policies; |
3830 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3929 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
3831 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 3930 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), |
| 3931 nullptr); |
3832 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, | 3932 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, |
3833 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 3933 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), |
| 3934 nullptr); |
3834 UpdateProviderPolicy(policies); | 3935 UpdateProviderPolicy(policies); |
3835 | 3936 |
3836 PrefService* prefs = browser()->profile()->GetPrefs(); | 3937 PrefService* prefs = browser()->profile()->GetPrefs(); |
3837 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3938 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3838 prefs, "host.name")); | 3939 prefs, "host.name")); |
3839 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3940 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3840 prefs, "other.host.name")); | 3941 prefs, "other.host.name")); |
3841 } | 3942 } |
3842 | 3943 |
3843 #endif // !defined(CHROME_OS) | 3944 #endif // !defined(CHROME_OS) |
3844 | 3945 |
3845 | 3946 |
3846 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 3947 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
3847 // Sets the hardware acceleration mode policy before the browser is started. | 3948 // Sets the hardware acceleration mode policy before the browser is started. |
3848 class HardwareAccelerationModePolicyTest : public PolicyTest { | 3949 class HardwareAccelerationModePolicyTest : public PolicyTest { |
3849 public: | 3950 public: |
3850 HardwareAccelerationModePolicyTest() {} | 3951 HardwareAccelerationModePolicyTest() {} |
3851 | 3952 |
3852 void SetUpInProcessBrowserTestFixture() override { | 3953 void SetUpInProcessBrowserTestFixture() override { |
3853 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3954 PolicyTest::SetUpInProcessBrowserTestFixture(); |
3854 PolicyMap policies; | 3955 PolicyMap policies; |
3855 policies.Set(key::kHardwareAccelerationModeEnabled, | 3956 policies.Set(key::kHardwareAccelerationModeEnabled, |
3856 POLICY_LEVEL_MANDATORY, | 3957 POLICY_LEVEL_MANDATORY, |
3857 POLICY_SCOPE_USER, | 3958 POLICY_SCOPE_USER, |
| 3959 POLICY_SOURCE_CLOUD, |
3858 new base::FundamentalValue(false), | 3960 new base::FundamentalValue(false), |
3859 NULL); | 3961 NULL); |
3860 provider_.UpdateChromePolicy(policies); | 3962 provider_.UpdateChromePolicy(policies); |
3861 } | 3963 } |
3862 }; | 3964 }; |
3863 | 3965 |
3864 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, | 3966 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, |
3865 HardwareAccelerationDisabled) { | 3967 HardwareAccelerationDisabled) { |
3866 // Verifies that hardware acceleration can be disabled with policy. | 3968 // Verifies that hardware acceleration can be disabled with policy. |
3867 EXPECT_FALSE( | 3969 EXPECT_FALSE( |
3868 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); | 3970 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); |
3869 } | 3971 } |
3870 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 3972 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
3871 | 3973 |
3872 } // namespace policy | 3974 } // namespace policy |
OLD | NEW |