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