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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 BrowserThread::PostTaskAndReply( | 695 BrowserThread::PostTaskAndReply( |
696 BrowserThread::IO, FROM_HERE, | 696 BrowserThread::IO, FROM_HERE, |
697 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, | 697 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, |
698 make_scoped_refptr(BrowserThread::GetBlockingPool())), | 698 make_scoped_refptr(BrowserThread::GetBlockingPool())), |
699 base::MessageLoop::current()->QuitWhenIdleClosure()); | 699 base::MessageLoop::current()->QuitWhenIdleClosure()); |
700 content::RunMessageLoop(); | 700 content::RunMessageLoop(); |
701 } | 701 } |
702 | 702 |
703 void SetScreenshotPolicy(bool enabled) { | 703 void SetScreenshotPolicy(bool enabled) { |
704 PolicyMap policies; | 704 PolicyMap policies; |
705 policies.Set(key::kDisableScreenshots, | 705 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, |
706 POLICY_LEVEL_MANDATORY, | 706 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
707 POLICY_SCOPE_USER, | 707 base::WrapUnique(new base::FundamentalValue(!enabled)), |
708 POLICY_SOURCE_CLOUD, | 708 nullptr); |
709 new base::FundamentalValue(!enabled), | |
710 NULL); | |
711 UpdateProviderPolicy(policies); | 709 UpdateProviderPolicy(policies); |
712 } | 710 } |
713 | 711 |
714 #if defined(OS_CHROMEOS) | 712 #if defined(OS_CHROMEOS) |
715 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { | 713 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { |
716 public: | 714 public: |
717 void OnScreenshotCompleted( | 715 void OnScreenshotCompleted( |
718 ScreenshotGrabberObserver::Result screenshot_result, | 716 ScreenshotGrabberObserver::Result screenshot_result, |
719 const base::FilePath& screenshot_path) override { | 717 const base::FilePath& screenshot_path) override { |
720 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, | 718 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 click_event.type = blink::WebInputEvent::MouseDown; | 839 click_event.type = blink::WebInputEvent::MouseDown; |
842 click_event.button = blink::WebMouseEvent::ButtonLeft; | 840 click_event.button = blink::WebMouseEvent::ButtonLeft; |
843 click_event.clickCount = 1; | 841 click_event.clickCount = 1; |
844 click_event.x = x; | 842 click_event.x = x; |
845 click_event.y = y; | 843 click_event.y = y; |
846 contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(click_event); | 844 contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(click_event); |
847 click_event.type = blink::WebInputEvent::MouseUp; | 845 click_event.type = blink::WebInputEvent::MouseUp; |
848 contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(click_event); | 846 contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(click_event); |
849 } | 847 } |
850 | 848 |
851 void SetPolicy(PolicyMap* policies, const char* key, base::Value* value) { | 849 void SetPolicy(PolicyMap* policies, |
| 850 const char* key, |
| 851 std::unique_ptr<base::Value> value) { |
852 if (value) { | 852 if (value) { |
853 policies->Set(key, | 853 policies->Set(key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
854 POLICY_LEVEL_MANDATORY, | 854 POLICY_SOURCE_CLOUD, std::move(value), nullptr); |
855 POLICY_SCOPE_USER, | |
856 POLICY_SOURCE_CLOUD, | |
857 value, | |
858 nullptr); | |
859 } else { | 855 } else { |
860 policies->Erase(key); | 856 policies->Erase(key); |
861 } | 857 } |
862 } | 858 } |
863 | 859 |
864 void ApplySafeSearchPolicy(base::FundamentalValue* legacy_safe_search, | 860 void ApplySafeSearchPolicy( |
865 base::FundamentalValue* google_safe_search, | 861 std::unique_ptr<base::FundamentalValue> legacy_safe_search, |
866 base::FundamentalValue* youtube_safety_mode) { | 862 std::unique_ptr<base::FundamentalValue> google_safe_search, |
| 863 std::unique_ptr<base::FundamentalValue> youtube_safety_mode) { |
867 PolicyMap policies; | 864 PolicyMap policies; |
868 SetPolicy(&policies, key::kForceSafeSearch, legacy_safe_search); | 865 SetPolicy(&policies, key::kForceSafeSearch, std::move(legacy_safe_search)); |
869 SetPolicy(&policies, key::kForceGoogleSafeSearch, google_safe_search); | 866 SetPolicy(&policies, key::kForceGoogleSafeSearch, |
870 SetPolicy(&policies, key::kForceYouTubeSafetyMode, youtube_safety_mode); | 867 std::move(google_safe_search)); |
| 868 SetPolicy(&policies, key::kForceYouTubeSafetyMode, |
| 869 std::move(youtube_safety_mode)); |
871 UpdateProviderPolicy(policies); | 870 UpdateProviderPolicy(policies); |
872 } | 871 } |
873 | 872 |
874 void CheckSafeSearch(bool expect_safe_search) { | 873 void CheckSafeSearch(bool expect_safe_search) { |
875 content::WebContents* web_contents = | 874 content::WebContents* web_contents = |
876 browser()->tab_strip_model()->GetActiveWebContents(); | 875 browser()->tab_strip_model()->GetActiveWebContents(); |
877 content::TestNavigationObserver observer(web_contents); | 876 content::TestNavigationObserver observer(web_contents); |
878 chrome::FocusLocationBar(browser()); | 877 chrome::FocusLocationBar(browser()); |
879 LocationBar* location_bar = browser()->window()->GetLocationBar(); | 878 LocationBar* location_bar = browser()->window()->GetLocationBar(); |
880 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); | 879 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 | 950 |
952 // Verifies that the bookmarks bar can be forced to always or never show up. | 951 // Verifies that the bookmarks bar can be forced to always or never show up. |
953 | 952 |
954 // Test starts in about:blank. | 953 // Test starts in about:blank. |
955 PrefService* prefs = browser()->profile()->GetPrefs(); | 954 PrefService* prefs = browser()->profile()->GetPrefs(); |
956 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 955 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
957 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 956 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
958 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 957 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
959 | 958 |
960 PolicyMap policies; | 959 PolicyMap policies; |
961 policies.Set(key::kBookmarkBarEnabled, | 960 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
962 POLICY_LEVEL_MANDATORY, | 961 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
963 POLICY_SCOPE_USER, | 962 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
964 POLICY_SOURCE_CLOUD, | |
965 new base::FundamentalValue(true), | |
966 NULL); | |
967 UpdateProviderPolicy(policies); | 963 UpdateProviderPolicy(policies); |
968 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 964 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
969 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 965 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
970 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 966 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
971 | 967 |
972 // The NTP has special handling of the bookmark bar. | 968 // The NTP has special handling of the bookmark bar. |
973 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 969 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
974 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 970 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
975 | 971 |
976 policies.Set(key::kBookmarkBarEnabled, | 972 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
977 POLICY_LEVEL_MANDATORY, | 973 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
978 POLICY_SCOPE_USER, | 974 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
979 POLICY_SOURCE_CLOUD, | |
980 new base::FundamentalValue(false), | |
981 NULL); | |
982 UpdateProviderPolicy(policies); | 975 UpdateProviderPolicy(policies); |
983 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 976 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
984 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 977 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
985 // The bookmark bar is hidden in the NTP when disabled by policy. | 978 // The bookmark bar is hidden in the NTP when disabled by policy. |
986 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 979 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
987 | 980 |
988 policies.Clear(); | 981 policies.Clear(); |
989 UpdateProviderPolicy(policies); | 982 UpdateProviderPolicy(policies); |
990 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 983 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
991 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 984 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
(...skipping 14 matching lines...) Expand all Loading... |
1006 EXPECT_TRUE(content::SetCookie(profile, url, value)); | 999 EXPECT_TRUE(content::SetCookie(profile, url, value)); |
1007 // Verify it was set. | 1000 // Verify it was set. |
1008 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); | 1001 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); |
1009 } | 1002 } |
1010 | 1003 |
1011 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { | 1004 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { |
1012 // Verify that the cookie persists across restarts. | 1005 // Verify that the cookie persists across restarts. |
1013 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); | 1006 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); |
1014 // Now set the policy and the cookie should be gone after another restart. | 1007 // Now set the policy and the cookie should be gone after another restart. |
1015 PolicyMap policies; | 1008 PolicyMap policies; |
1016 policies.Set(key::kDefaultCookiesSetting, | 1009 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, |
1017 POLICY_LEVEL_MANDATORY, | 1010 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1018 POLICY_SCOPE_USER, | 1011 base::WrapUnique(new base::FundamentalValue(4)), nullptr); |
1019 POLICY_SOURCE_CLOUD, | |
1020 new base::FundamentalValue(4), | |
1021 NULL); | |
1022 UpdateProviderPolicy(policies); | 1012 UpdateProviderPolicy(policies); |
1023 } | 1013 } |
1024 | 1014 |
1025 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { | 1015 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { |
1026 // Verify that the cookie is gone. | 1016 // Verify that the cookie is gone. |
1027 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); | 1017 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); |
1028 } | 1018 } |
1029 | 1019 |
1030 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { | 1020 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { |
1031 MakeRequestFail make_request_fail("search.example"); | 1021 MakeRequestFail make_request_fail("search.example"); |
(...skipping 23 matching lines...) Expand all Loading... |
1055 default_search->alternate_urls()[0] == kAlternateURL0 && | 1045 default_search->alternate_urls()[0] == kAlternateURL0 && |
1056 default_search->alternate_urls()[1] == kAlternateURL1 && | 1046 default_search->alternate_urls()[1] == kAlternateURL1 && |
1057 default_search->search_terms_replacement_key() == | 1047 default_search->search_terms_replacement_key() == |
1058 kSearchTermsReplacementKey && | 1048 kSearchTermsReplacementKey && |
1059 default_search->image_url() == kImageURL && | 1049 default_search->image_url() == kImageURL && |
1060 default_search->image_url_post_params() == kImageURLPostParams && | 1050 default_search->image_url_post_params() == kImageURLPostParams && |
1061 default_search->new_tab_url() == kNewTabURL); | 1051 default_search->new_tab_url() == kNewTabURL); |
1062 | 1052 |
1063 // Override the default search provider using policies. | 1053 // Override the default search provider using policies. |
1064 PolicyMap policies; | 1054 PolicyMap policies; |
1065 policies.Set(key::kDefaultSearchProviderEnabled, | 1055 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
1066 POLICY_LEVEL_MANDATORY, | 1056 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1067 POLICY_SCOPE_USER, | 1057 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
1068 POLICY_SOURCE_CLOUD, | 1058 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, |
1069 new base::FundamentalValue(true), | 1059 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1070 NULL); | 1060 base::WrapUnique(new base::StringValue(kKeyword)), nullptr); |
1071 policies.Set(key::kDefaultSearchProviderKeyword, | 1061 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, |
1072 POLICY_LEVEL_MANDATORY, | 1062 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1073 POLICY_SCOPE_USER, | 1063 base::WrapUnique(new base::StringValue(kSearchURL)), nullptr); |
1074 POLICY_SOURCE_CLOUD, | 1064 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); |
1075 new base::StringValue(kKeyword), | |
1076 NULL); | |
1077 policies.Set(key::kDefaultSearchProviderSearchURL, | |
1078 POLICY_LEVEL_MANDATORY, | |
1079 POLICY_SCOPE_USER, | |
1080 POLICY_SOURCE_CLOUD, | |
1081 new base::StringValue(kSearchURL), | |
1082 NULL); | |
1083 base::ListValue* alternate_urls = new base::ListValue(); | |
1084 alternate_urls->AppendString(kAlternateURL0); | 1065 alternate_urls->AppendString(kAlternateURL0); |
1085 alternate_urls->AppendString(kAlternateURL1); | 1066 alternate_urls->AppendString(kAlternateURL1); |
1086 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, | 1067 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, |
1087 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, alternate_urls, nullptr); | 1068 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1088 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, | 1069 std::move(alternate_urls), nullptr); |
1089 POLICY_LEVEL_MANDATORY, | 1070 policies.Set( |
1090 POLICY_SCOPE_USER, | 1071 key::kDefaultSearchProviderSearchTermsReplacementKey, |
1091 POLICY_SOURCE_CLOUD, | 1072 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1092 new base::StringValue(kSearchTermsReplacementKey), | 1073 base::WrapUnique(new base::StringValue(kSearchTermsReplacementKey)), |
1093 NULL); | 1074 nullptr); |
1094 policies.Set(key::kDefaultSearchProviderImageURL, | 1075 policies.Set(key::kDefaultSearchProviderImageURL, POLICY_LEVEL_MANDATORY, |
1095 POLICY_LEVEL_MANDATORY, | 1076 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1096 POLICY_SCOPE_USER, | 1077 base::WrapUnique(new base::StringValue(kImageURL)), nullptr); |
1097 POLICY_SOURCE_CLOUD, | |
1098 new base::StringValue(kImageURL), | |
1099 NULL); | |
1100 policies.Set(key::kDefaultSearchProviderImageURLPostParams, | 1078 policies.Set(key::kDefaultSearchProviderImageURLPostParams, |
1101 POLICY_LEVEL_MANDATORY, | 1079 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1102 POLICY_SCOPE_USER, | 1080 base::WrapUnique(new base::StringValue(kImageURLPostParams)), |
1103 POLICY_SOURCE_CLOUD, | 1081 nullptr); |
1104 new base::StringValue(kImageURLPostParams), | 1082 policies.Set(key::kDefaultSearchProviderNewTabURL, POLICY_LEVEL_MANDATORY, |
1105 NULL); | 1083 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1106 policies.Set(key::kDefaultSearchProviderNewTabURL, | 1084 base::WrapUnique(new base::StringValue(kNewTabURL)), nullptr); |
1107 POLICY_LEVEL_MANDATORY, | |
1108 POLICY_SCOPE_USER, | |
1109 POLICY_SOURCE_CLOUD, | |
1110 new base::StringValue(kNewTabURL), | |
1111 NULL); | |
1112 UpdateProviderPolicy(policies); | 1085 UpdateProviderPolicy(policies); |
1113 default_search = service->GetDefaultSearchProvider(); | 1086 default_search = service->GetDefaultSearchProvider(); |
1114 ASSERT_TRUE(default_search); | 1087 ASSERT_TRUE(default_search); |
1115 EXPECT_EQ(kKeyword, default_search->keyword()); | 1088 EXPECT_EQ(kKeyword, default_search->keyword()); |
1116 EXPECT_EQ(kSearchURL, default_search->url()); | 1089 EXPECT_EQ(kSearchURL, default_search->url()); |
1117 EXPECT_EQ(2U, default_search->alternate_urls().size()); | 1090 EXPECT_EQ(2U, default_search->alternate_urls().size()); |
1118 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); | 1091 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); |
1119 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); | 1092 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); |
1120 EXPECT_EQ(kSearchTermsReplacementKey, | 1093 EXPECT_EQ(kSearchTermsReplacementKey, |
1121 default_search->search_terms_replacement_key()); | 1094 default_search->search_terms_replacement_key()); |
1122 EXPECT_EQ(kImageURL, default_search->image_url()); | 1095 EXPECT_EQ(kImageURL, default_search->image_url()); |
1123 EXPECT_EQ(kImageURLPostParams, default_search->image_url_post_params()); | 1096 EXPECT_EQ(kImageURLPostParams, default_search->image_url_post_params()); |
1124 EXPECT_EQ(kNewTabURL, default_search->new_tab_url()); | 1097 EXPECT_EQ(kNewTabURL, default_search->new_tab_url()); |
1125 | 1098 |
1126 // Verify that searching from the omnibox uses kSearchURL. | 1099 // Verify that searching from the omnibox uses kSearchURL. |
1127 chrome::FocusLocationBar(browser()); | 1100 chrome::FocusLocationBar(browser()); |
1128 LocationBar* location_bar = browser()->window()->GetLocationBar(); | 1101 LocationBar* location_bar = browser()->window()->GetLocationBar(); |
1129 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "stuff to search for"); | 1102 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "stuff to search for"); |
1130 OmniboxEditModel* model = location_bar->GetOmniboxView()->model(); | 1103 OmniboxEditModel* model = location_bar->GetOmniboxView()->model(); |
1131 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1104 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); |
1132 content::WebContents* web_contents = | 1105 content::WebContents* web_contents = |
1133 browser()->tab_strip_model()->GetActiveWebContents(); | 1106 browser()->tab_strip_model()->GetActiveWebContents(); |
1134 GURL expected("http://search.example/search?q=stuff+to+search+for"); | 1107 GURL expected("http://search.example/search?q=stuff+to+search+for"); |
1135 EXPECT_EQ(expected, web_contents->GetURL()); | 1108 EXPECT_EQ(expected, web_contents->GetURL()); |
1136 | 1109 |
1137 // Verify that searching from the omnibox can be disabled. | 1110 // Verify that searching from the omnibox can be disabled. |
1138 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1111 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
1139 policies.Set(key::kDefaultSearchProviderEnabled, | 1112 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
1140 POLICY_LEVEL_MANDATORY, | 1113 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1141 POLICY_SCOPE_USER, | 1114 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
1142 POLICY_SOURCE_CLOUD, | |
1143 new base::FundamentalValue(false), | |
1144 NULL); | |
1145 EXPECT_TRUE(service->GetDefaultSearchProvider()); | 1115 EXPECT_TRUE(service->GetDefaultSearchProvider()); |
1146 UpdateProviderPolicy(policies); | 1116 UpdateProviderPolicy(policies); |
1147 EXPECT_FALSE(service->GetDefaultSearchProvider()); | 1117 EXPECT_FALSE(service->GetDefaultSearchProvider()); |
1148 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); | 1118 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); |
1149 // This means that submitting won't trigger any action. | 1119 // This means that submitting won't trigger any action. |
1150 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1120 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); |
1151 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); | 1121 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); |
1152 } | 1122 } |
1153 | 1123 |
1154 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { | 1124 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { |
1155 // Add an individual proxy policy value. | 1125 // Add an individual proxy policy value. |
1156 PolicyMap policies; | 1126 PolicyMap policies; |
1157 policies.Set(key::kProxyServerMode, | 1127 policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1158 POLICY_LEVEL_MANDATORY, | |
1159 POLICY_SCOPE_USER, | |
1160 POLICY_SOURCE_CLOUD, | 1128 POLICY_SOURCE_CLOUD, |
1161 new base::FundamentalValue(3), | 1129 base::WrapUnique(new base::FundamentalValue(3)), nullptr); |
1162 NULL); | |
1163 UpdateProviderPolicy(policies); | 1130 UpdateProviderPolicy(policies); |
1164 | 1131 |
1165 // It should be removed and replaced with a dictionary. | 1132 // It should be removed and replaced with a dictionary. |
1166 PolicyMap expected; | 1133 PolicyMap expected; |
1167 std::unique_ptr<base::DictionaryValue> expected_value( | 1134 std::unique_ptr<base::DictionaryValue> expected_value( |
1168 new base::DictionaryValue); | 1135 new base::DictionaryValue); |
1169 expected_value->SetInteger(key::kProxyServerMode, 3); | 1136 expected_value->SetInteger(key::kProxyServerMode, 3); |
1170 expected.Set(key::kProxySettings, | 1137 expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1171 POLICY_LEVEL_MANDATORY, | 1138 POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); |
1172 POLICY_SCOPE_USER, | |
1173 POLICY_SOURCE_CLOUD, | |
1174 expected_value.release(), | |
1175 NULL); | |
1176 | 1139 |
1177 // Check both the browser and the profile. | 1140 // Check both the browser and the profile. |
1178 const PolicyMap& actual_from_browser = | 1141 const PolicyMap& actual_from_browser = |
1179 g_browser_process->browser_policy_connector() | 1142 g_browser_process->browser_policy_connector() |
1180 ->GetPolicyService() | 1143 ->GetPolicyService() |
1181 ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | 1144 ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
1182 EXPECT_TRUE(expected.Equals(actual_from_browser)); | 1145 EXPECT_TRUE(expected.Equals(actual_from_browser)); |
1183 const PolicyMap& actual_from_profile = | 1146 const PolicyMap& actual_from_profile = |
1184 ProfilePolicyConnectorFactory::GetForBrowserContext(browser()->profile()) | 1147 ProfilePolicyConnectorFactory::GetForBrowserContext(browser()->profile()) |
1185 ->policy_service() | 1148 ->policy_service() |
(...skipping 12 matching lines...) Expand all Loading... |
1198 CheckSafeSearch(false); | 1161 CheckSafeSearch(false); |
1199 | 1162 |
1200 // Go over all combinations of (undefined,true,false) for the three policies. | 1163 // Go over all combinations of (undefined,true,false) for the three policies. |
1201 for (int i = 0; i < 3 * 3 * 3; i++) { | 1164 for (int i = 0; i < 3 * 3 * 3; i++) { |
1202 int legacy = i % 3; | 1165 int legacy = i % 3; |
1203 int google = (i / 3) % 3; | 1166 int google = (i / 3) % 3; |
1204 int youtube = i / (3 * 3); | 1167 int youtube = i / (3 * 3); |
1205 | 1168 |
1206 // Override the default SafeSearch setting using policies. | 1169 // Override the default SafeSearch setting using policies. |
1207 ApplySafeSearchPolicy( | 1170 ApplySafeSearchPolicy( |
1208 legacy == 0 ? nullptr : new base::FundamentalValue(legacy == 1), | 1171 legacy == 0 ? nullptr |
1209 google == 0 ? nullptr : new base::FundamentalValue(google == 1), | 1172 : base::WrapUnique(new base::FundamentalValue(legacy == 1)), |
1210 youtube == 0 ? nullptr : new base::FundamentalValue(youtube == 1)); | 1173 google == 0 ? nullptr |
| 1174 : base::WrapUnique(new base::FundamentalValue(google == 1)), |
| 1175 youtube == 0 ? nullptr : base::WrapUnique( |
| 1176 new base::FundamentalValue(youtube == 1))); |
1211 | 1177 |
1212 // The legacy policy should only have an effect if both google and youtube | 1178 // The legacy policy should only have an effect if both google and youtube |
1213 // are undefined. | 1179 // are undefined. |
1214 bool legacy_in_effect = (google == 0 && youtube == 0 && legacy != 0); | 1180 bool legacy_in_effect = (google == 0 && youtube == 0 && legacy != 0); |
1215 bool legacy_enabled = legacy_in_effect && legacy == 1; | 1181 bool legacy_enabled = legacy_in_effect && legacy == 1; |
1216 | 1182 |
1217 PrefService* prefs = browser()->profile()->GetPrefs(); | 1183 PrefService* prefs = browser()->profile()->GetPrefs(); |
1218 EXPECT_EQ(google != 0 || legacy_in_effect, | 1184 EXPECT_EQ(google != 0 || legacy_in_effect, |
1219 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); | 1185 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); |
1220 EXPECT_EQ(google == 1 || legacy_enabled, | 1186 EXPECT_EQ(google == 1 || legacy_enabled, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 EXPECT_NE(kKeyword, default_search->keyword()); | 1219 EXPECT_NE(kKeyword, default_search->keyword()); |
1254 EXPECT_NE(kSearchURL, default_search->url()); | 1220 EXPECT_NE(kSearchURL, default_search->url()); |
1255 EXPECT_NE(kInstantURL, default_search->instant_url()); | 1221 EXPECT_NE(kInstantURL, default_search->instant_url()); |
1256 EXPECT_FALSE( | 1222 EXPECT_FALSE( |
1257 default_search->alternate_urls().size() == 2 && | 1223 default_search->alternate_urls().size() == 2 && |
1258 default_search->alternate_urls()[0] == kAlternateURL0 && | 1224 default_search->alternate_urls()[0] == kAlternateURL0 && |
1259 default_search->alternate_urls()[1] == kAlternateURL1); | 1225 default_search->alternate_urls()[1] == kAlternateURL1); |
1260 | 1226 |
1261 // Override the default search provider using policies. | 1227 // Override the default search provider using policies. |
1262 PolicyMap policies; | 1228 PolicyMap policies; |
1263 policies.Set(key::kDefaultSearchProviderEnabled, | 1229 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
1264 POLICY_LEVEL_MANDATORY, | 1230 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1265 POLICY_SCOPE_USER, | 1231 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
1266 POLICY_SOURCE_CLOUD, | 1232 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, |
1267 new base::FundamentalValue(true), | 1233 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1268 NULL); | 1234 base::WrapUnique(new base::StringValue(kKeyword)), nullptr); |
1269 policies.Set(key::kDefaultSearchProviderKeyword, | 1235 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, |
1270 POLICY_LEVEL_MANDATORY, | 1236 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1271 POLICY_SCOPE_USER, | 1237 base::WrapUnique(new base::StringValue(kSearchURL)), nullptr); |
1272 POLICY_SOURCE_CLOUD, | 1238 policies.Set(key::kDefaultSearchProviderInstantURL, POLICY_LEVEL_MANDATORY, |
1273 new base::StringValue(kKeyword), | 1239 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1274 NULL); | 1240 base::WrapUnique(new base::StringValue(kInstantURL)), nullptr); |
1275 policies.Set(key::kDefaultSearchProviderSearchURL, | 1241 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); |
1276 POLICY_LEVEL_MANDATORY, | |
1277 POLICY_SCOPE_USER, | |
1278 POLICY_SOURCE_CLOUD, | |
1279 new base::StringValue(kSearchURL), | |
1280 NULL); | |
1281 policies.Set(key::kDefaultSearchProviderInstantURL, | |
1282 POLICY_LEVEL_MANDATORY, | |
1283 POLICY_SCOPE_USER, | |
1284 POLICY_SOURCE_CLOUD, | |
1285 new base::StringValue(kInstantURL), | |
1286 NULL); | |
1287 base::ListValue* alternate_urls = new base::ListValue(); | |
1288 alternate_urls->AppendString(kAlternateURL0); | 1242 alternate_urls->AppendString(kAlternateURL0); |
1289 alternate_urls->AppendString(kAlternateURL1); | 1243 alternate_urls->AppendString(kAlternateURL1); |
1290 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, | 1244 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, |
1291 POLICY_SCOPE_USER, | 1245 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1292 POLICY_SOURCE_CLOUD, alternate_urls, nullptr); | 1246 std::move(alternate_urls), nullptr); |
1293 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, | 1247 policies.Set( |
1294 POLICY_LEVEL_MANDATORY, | 1248 key::kDefaultSearchProviderSearchTermsReplacementKey, |
1295 POLICY_SCOPE_USER, | 1249 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1296 POLICY_SOURCE_CLOUD, | 1250 base::WrapUnique(new base::StringValue(kSearchTermsReplacementKey)), |
1297 new base::StringValue(kSearchTermsReplacementKey), | 1251 nullptr); |
1298 NULL); | |
1299 UpdateProviderPolicy(policies); | 1252 UpdateProviderPolicy(policies); |
1300 default_search = service->GetDefaultSearchProvider(); | 1253 default_search = service->GetDefaultSearchProvider(); |
1301 ASSERT_TRUE(default_search); | 1254 ASSERT_TRUE(default_search); |
1302 EXPECT_EQ(kKeyword, default_search->keyword()); | 1255 EXPECT_EQ(kKeyword, default_search->keyword()); |
1303 EXPECT_EQ(kSearchURL, default_search->url()); | 1256 EXPECT_EQ(kSearchURL, default_search->url()); |
1304 EXPECT_EQ(kInstantURL, default_search->instant_url()); | 1257 EXPECT_EQ(kInstantURL, default_search->instant_url()); |
1305 EXPECT_EQ(2U, default_search->alternate_urls().size()); | 1258 EXPECT_EQ(2U, default_search->alternate_urls().size()); |
1306 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); | 1259 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); |
1307 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); | 1260 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); |
1308 | 1261 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) | 1318 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) |
1366 return; | 1319 return; |
1367 | 1320 |
1368 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1321 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
1369 // WebGL is enabled by default. | 1322 // WebGL is enabled by default. |
1370 content::WebContents* contents = | 1323 content::WebContents* contents = |
1371 browser()->tab_strip_model()->GetActiveWebContents(); | 1324 browser()->tab_strip_model()->GetActiveWebContents(); |
1372 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1325 EXPECT_TRUE(IsWebGLEnabled(contents)); |
1373 // Disable with a policy. | 1326 // Disable with a policy. |
1374 PolicyMap policies; | 1327 PolicyMap policies; |
1375 policies.Set(key::kDisable3DAPIs, | 1328 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1376 POLICY_LEVEL_MANDATORY, | |
1377 POLICY_SCOPE_USER, | |
1378 POLICY_SOURCE_CLOUD, | 1329 POLICY_SOURCE_CLOUD, |
1379 new base::FundamentalValue(true), | 1330 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
1380 NULL); | |
1381 UpdateProviderPolicy(policies); | 1331 UpdateProviderPolicy(policies); |
1382 // Crash and reload the tab to get a new renderer. | 1332 // Crash and reload the tab to get a new renderer. |
1383 content::CrashTab(contents); | 1333 content::CrashTab(contents); |
1384 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1334 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
1385 EXPECT_FALSE(IsWebGLEnabled(contents)); | 1335 EXPECT_FALSE(IsWebGLEnabled(contents)); |
1386 // Enable with a policy. | 1336 // Enable with a policy. |
1387 policies.Set(key::kDisable3DAPIs, | 1337 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1388 POLICY_LEVEL_MANDATORY, | |
1389 POLICY_SCOPE_USER, | |
1390 POLICY_SOURCE_CLOUD, | 1338 POLICY_SOURCE_CLOUD, |
1391 new base::FundamentalValue(false), | 1339 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
1392 NULL); | |
1393 UpdateProviderPolicy(policies); | 1340 UpdateProviderPolicy(policies); |
1394 content::CrashTab(contents); | 1341 content::CrashTab(contents); |
1395 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1342 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
1396 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1343 EXPECT_TRUE(IsWebGLEnabled(contents)); |
1397 } | 1344 } |
1398 | 1345 |
1399 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) { | 1346 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) { |
1400 // Verifies that SPDY can be disable by policy. | 1347 // Verifies that SPDY can be disable by policy. |
1401 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); | 1348 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); |
1402 PolicyMap policies; | 1349 PolicyMap policies; |
1403 policies.Set(key::kDisableSpdy, | 1350 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1404 POLICY_LEVEL_MANDATORY, | |
1405 POLICY_SCOPE_USER, | |
1406 POLICY_SOURCE_CLOUD, | 1351 POLICY_SOURCE_CLOUD, |
1407 new base::FundamentalValue(true), | 1352 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
1408 NULL); | |
1409 UpdateProviderPolicy(policies); | 1353 UpdateProviderPolicy(policies); |
1410 content::RunAllPendingInMessageLoop(); | 1354 content::RunAllPendingInMessageLoop(); |
1411 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); | 1355 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); |
1412 // Verify that it can be force-enabled too. | 1356 // Verify that it can be force-enabled too. |
1413 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); | 1357 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); |
1414 policies.Set(key::kDisableSpdy, | 1358 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1415 POLICY_LEVEL_MANDATORY, | |
1416 POLICY_SCOPE_USER, | |
1417 POLICY_SOURCE_CLOUD, | 1359 POLICY_SOURCE_CLOUD, |
1418 new base::FundamentalValue(false), | 1360 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
1419 NULL); | |
1420 UpdateProviderPolicy(policies); | 1361 UpdateProviderPolicy(policies); |
1421 content::RunAllPendingInMessageLoop(); | 1362 content::RunAllPendingInMessageLoop(); |
1422 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); | 1363 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); |
1423 } | 1364 } |
1424 | 1365 |
1425 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { | 1366 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { |
1426 // Verifies that plugins can be forced to be disabled by policy. | 1367 // Verifies that plugins can be forced to be disabled by policy. |
1427 | 1368 |
1428 // Verify that the Flash plugin exists and that it can be enabled and disabled | 1369 // Verify that the Flash plugin exists and that it can be enabled and disabled |
1429 // by the user. | 1370 // by the user. |
1430 std::vector<content::WebPluginInfo> plugins; | 1371 std::vector<content::WebPluginInfo> plugins; |
1431 GetPluginList(&plugins); | 1372 GetPluginList(&plugins); |
1432 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1373 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1433 if (!flash) | 1374 if (!flash) |
1434 return; | 1375 return; |
1435 PluginPrefs* plugin_prefs = | 1376 PluginPrefs* plugin_prefs = |
1436 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1377 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1437 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1378 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1438 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1379 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1439 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1380 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1440 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | 1381 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); |
1441 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1382 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1442 | 1383 |
1443 // Now disable it with a policy. | 1384 // Now disable it with a policy. |
1444 base::ListValue disabled_plugins; | 1385 base::ListValue disabled_plugins; |
1445 disabled_plugins.Append(new base::StringValue("*Flash*")); | 1386 disabled_plugins.Append(new base::StringValue("*Flash*")); |
1446 PolicyMap policies; | 1387 PolicyMap policies; |
1447 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1388 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1448 POLICY_SOURCE_CLOUD, disabled_plugins.DeepCopy(), nullptr); | 1389 POLICY_SOURCE_CLOUD, disabled_plugins.CreateDeepCopy(), nullptr); |
1449 UpdateProviderPolicy(policies); | 1390 UpdateProviderPolicy(policies); |
1450 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1391 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1451 // The user shouldn't be able to enable it. | 1392 // The user shouldn't be able to enable it. |
1452 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | 1393 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); |
1453 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1394 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1454 } | 1395 } |
1455 | 1396 |
1456 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { | 1397 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { |
1457 // Verifies that plugins with an exception in the blacklist can be enabled. | 1398 // Verifies that plugins with an exception in the blacklist can be enabled. |
1458 | 1399 |
1459 // Verify that the Flash plugin exists and that it can be enabled and disabled | 1400 // Verify that the Flash plugin exists and that it can be enabled and disabled |
1460 // by the user. | 1401 // by the user. |
1461 std::vector<content::WebPluginInfo> plugins; | 1402 std::vector<content::WebPluginInfo> plugins; |
1462 GetPluginList(&plugins); | 1403 GetPluginList(&plugins); |
1463 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1404 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1464 if (!flash) | 1405 if (!flash) |
1465 return; | 1406 return; |
1466 PluginPrefs* plugin_prefs = | 1407 PluginPrefs* plugin_prefs = |
1467 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1408 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1468 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1409 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1469 | 1410 |
1470 // Disable all plugins. | 1411 // Disable all plugins. |
1471 base::ListValue disabled_plugins; | 1412 base::ListValue disabled_plugins; |
1472 disabled_plugins.Append(new base::StringValue("*")); | 1413 disabled_plugins.Append(new base::StringValue("*")); |
1473 PolicyMap policies; | 1414 PolicyMap policies; |
1474 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1415 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1475 POLICY_SOURCE_CLOUD, disabled_plugins.DeepCopy(), nullptr); | 1416 POLICY_SOURCE_CLOUD, disabled_plugins.CreateDeepCopy(), nullptr); |
1476 UpdateProviderPolicy(policies); | 1417 UpdateProviderPolicy(policies); |
1477 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1418 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1478 // The user shouldn't be able to enable it. | 1419 // The user shouldn't be able to enable it. |
1479 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | 1420 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); |
1480 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1421 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1481 | 1422 |
1482 // Now open an exception for flash. | 1423 // Now open an exception for flash. |
1483 base::ListValue disabled_plugins_exceptions; | 1424 base::ListValue disabled_plugins_exceptions; |
1484 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*")); | 1425 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*")); |
1485 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, | 1426 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, |
1486 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1427 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1487 disabled_plugins_exceptions.DeepCopy(), nullptr); | 1428 disabled_plugins_exceptions.CreateDeepCopy(), nullptr); |
1488 UpdateProviderPolicy(policies); | 1429 UpdateProviderPolicy(policies); |
1489 // It should revert to the user's preference automatically. | 1430 // It should revert to the user's preference automatically. |
1490 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1431 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1491 // And the user should be able to disable and enable again. | 1432 // And the user should be able to disable and enable again. |
1492 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1433 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1493 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1434 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1494 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | 1435 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); |
1495 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1436 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1496 } | 1437 } |
1497 | 1438 |
1498 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { | 1439 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { |
1499 // Verifies that a plugin can be force-installed with a policy. | 1440 // Verifies that a plugin can be force-installed with a policy. |
1500 std::vector<content::WebPluginInfo> plugins; | 1441 std::vector<content::WebPluginInfo> plugins; |
1501 GetPluginList(&plugins); | 1442 GetPluginList(&plugins); |
1502 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1443 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1503 if (!flash) | 1444 if (!flash) |
1504 return; | 1445 return; |
1505 PluginPrefs* plugin_prefs = | 1446 PluginPrefs* plugin_prefs = |
1506 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1447 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1507 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1448 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1508 | 1449 |
1509 // The user disables it and then a policy forces it to be enabled. | 1450 // The user disables it and then a policy forces it to be enabled. |
1510 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1451 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1511 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1452 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1512 base::ListValue plugin_list; | 1453 base::ListValue plugin_list; |
1513 plugin_list.Append(new base::StringValue(content::kFlashPluginName)); | 1454 plugin_list.Append(new base::StringValue(content::kFlashPluginName)); |
1514 PolicyMap policies; | 1455 PolicyMap policies; |
1515 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, | 1456 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1516 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, plugin_list.DeepCopy(), | 1457 POLICY_SOURCE_CLOUD, plugin_list.CreateDeepCopy(), nullptr); |
1517 nullptr); | |
1518 UpdateProviderPolicy(policies); | 1458 UpdateProviderPolicy(policies); |
1519 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1459 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1520 // The user can't disable it anymore. | 1460 // The user can't disable it anymore. |
1521 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); | 1461 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); |
1522 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1462 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1523 | 1463 |
1524 // When a plugin is both enabled and disabled, the whitelist takes precedence. | 1464 // When a plugin is both enabled and disabled, the whitelist takes precedence. |
1525 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1465 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1526 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, plugin_list.DeepCopy(), | 1466 POLICY_SOURCE_CLOUD, plugin_list.CreateDeepCopy(), nullptr); |
1527 nullptr); | |
1528 UpdateProviderPolicy(policies); | 1467 UpdateProviderPolicy(policies); |
1529 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1468 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1530 } | 1469 } |
1531 | 1470 |
1532 IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { | 1471 IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { |
1533 // Verifies that dangerous plugins can be always authorized to run with | 1472 // Verifies that dangerous plugins can be always authorized to run with |
1534 // a policy. | 1473 // a policy. |
1535 | 1474 |
1536 // Verify that the test page exists. It is only present in checkouts with | 1475 // Verify that the test page exists. It is only present in checkouts with |
1537 // src-internal. | 1476 // src-internal. |
(...skipping 20 matching lines...) Expand all Loading... |
1558 ui_test_utils::NavigateToURL(browser(), url); | 1497 ui_test_utils::NavigateToURL(browser(), url); |
1559 // This should have triggered the dangerous plugin infobar. | 1498 // This should have triggered the dangerous plugin infobar. |
1560 ASSERT_EQ(1u, infobar_service->infobar_count()); | 1499 ASSERT_EQ(1u, infobar_service->infobar_count()); |
1561 EXPECT_TRUE( | 1500 EXPECT_TRUE( |
1562 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); | 1501 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); |
1563 // And the plugin isn't running. | 1502 // And the plugin isn't running. |
1564 EXPECT_EQ(0, CountPlugins()); | 1503 EXPECT_EQ(0, CountPlugins()); |
1565 | 1504 |
1566 // Now set a policy to always authorize this. | 1505 // Now set a policy to always authorize this. |
1567 PolicyMap policies; | 1506 PolicyMap policies; |
1568 policies.Set(key::kAlwaysAuthorizePlugins, | 1507 policies.Set(key::kAlwaysAuthorizePlugins, POLICY_LEVEL_MANDATORY, |
1569 POLICY_LEVEL_MANDATORY, | 1508 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1570 POLICY_SCOPE_USER, | 1509 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
1571 POLICY_SOURCE_CLOUD, | |
1572 new base::FundamentalValue(true), | |
1573 NULL); | |
1574 UpdateProviderPolicy(policies); | 1510 UpdateProviderPolicy(policies); |
1575 // Reloading the page shouldn't trigger the infobar this time. | 1511 // Reloading the page shouldn't trigger the infobar this time. |
1576 ui_test_utils::NavigateToURL(browser(), url); | 1512 ui_test_utils::NavigateToURL(browser(), url); |
1577 EXPECT_EQ(0u, infobar_service->infobar_count()); | 1513 EXPECT_EQ(0u, infobar_service->infobar_count()); |
1578 // And the plugin started automatically. | 1514 // And the plugin started automatically. |
1579 EXPECT_EQ(1, CountPlugins()); | 1515 EXPECT_EQ(1, CountPlugins()); |
1580 } | 1516 } |
1581 | 1517 |
1582 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { | 1518 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { |
1583 // Verifies that access to the developer tools can be disabled. | 1519 // Verifies that access to the developer tools can be disabled. |
1584 | 1520 |
1585 // Open devtools. | 1521 // Open devtools. |
1586 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1522 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
1587 content::WebContents* contents = | 1523 content::WebContents* contents = |
1588 browser()->tab_strip_model()->GetActiveWebContents(); | 1524 browser()->tab_strip_model()->GetActiveWebContents(); |
1589 DevToolsWindow* devtools_window = | 1525 DevToolsWindow* devtools_window = |
1590 DevToolsWindow::GetInstanceForInspectedWebContents(contents); | 1526 DevToolsWindow::GetInstanceForInspectedWebContents(contents); |
1591 EXPECT_TRUE(devtools_window); | 1527 EXPECT_TRUE(devtools_window); |
1592 | 1528 |
1593 // Disable devtools via policy. | 1529 // Disable devtools via policy. |
1594 PolicyMap policies; | 1530 PolicyMap policies; |
1595 policies.Set(key::kDeveloperToolsDisabled, | 1531 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, |
1596 POLICY_LEVEL_MANDATORY, | 1532 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1597 POLICY_SCOPE_USER, | 1533 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
1598 POLICY_SOURCE_CLOUD, | |
1599 new base::FundamentalValue(true), | |
1600 NULL); | |
1601 content::WindowedNotificationObserver close_observer( | 1534 content::WindowedNotificationObserver close_observer( |
1602 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1535 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
1603 content::Source<content::WebContents>( | 1536 content::Source<content::WebContents>( |
1604 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); | 1537 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); |
1605 UpdateProviderPolicy(policies); | 1538 UpdateProviderPolicy(policies); |
1606 // wait for devtools close | 1539 // wait for devtools close |
1607 close_observer.Wait(); | 1540 close_observer.Wait(); |
1608 // The existing devtools window should have closed. | 1541 // The existing devtools window should have closed. |
1609 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); | 1542 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); |
1610 // And it's not possible to open it again. | 1543 // And it's not possible to open it again. |
(...skipping 22 matching lines...) Expand all Loading... |
1633 EXPECT_TRUE(ContainsVisibleElement(contents, | 1566 EXPECT_TRUE(ContainsVisibleElement(contents, |
1634 "ahfgeienlihckogmohjhadlkjgocpleb")); | 1567 "ahfgeienlihckogmohjhadlkjgocpleb")); |
1635 #endif | 1568 #endif |
1636 | 1569 |
1637 // The next NTP has no footer. | 1570 // The next NTP has no footer. |
1638 if (ContainsVisibleElement(contents, "footer")) | 1571 if (ContainsVisibleElement(contents, "footer")) |
1639 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1572 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
1640 | 1573 |
1641 // Turn off the web store icons. | 1574 // Turn off the web store icons. |
1642 PolicyMap policies; | 1575 PolicyMap policies; |
1643 policies.Set(key::kHideWebStoreIcon, | 1576 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY, |
1644 POLICY_LEVEL_MANDATORY, | 1577 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1645 POLICY_SCOPE_USER, | 1578 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
1646 POLICY_SOURCE_CLOUD, | |
1647 new base::FundamentalValue(true), | |
1648 NULL); | |
1649 UpdateProviderPolicy(policies); | 1579 UpdateProviderPolicy(policies); |
1650 | 1580 |
1651 // The web store icons should now be hidden. | 1581 // The web store icons should now be hidden. |
1652 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1582 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
1653 EXPECT_FALSE(ContainsVisibleElement(contents, | 1583 EXPECT_FALSE(ContainsVisibleElement(contents, |
1654 "ahfgeienlihckogmohjhadlkjgocpleb")); | 1584 "ahfgeienlihckogmohjhadlkjgocpleb")); |
1655 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1585 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
1656 } | 1586 } |
1657 | 1587 |
1658 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { | 1588 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { |
(...skipping 10 matching lines...) Expand all Loading... |
1669 | 1599 |
1670 // Verify that downloads end up on the default directory. | 1600 // Verify that downloads end up on the default directory. |
1671 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1601 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1672 DownloadAndVerifyFile(browser(), initial_dir.path(), file); | 1602 DownloadAndVerifyFile(browser(), initial_dir.path(), file); |
1673 base::DieFileDie(initial_dir.path().Append(file), false); | 1603 base::DieFileDie(initial_dir.path().Append(file), false); |
1674 | 1604 |
1675 // Override the download directory with the policy and verify a download. | 1605 // Override the download directory with the policy and verify a download. |
1676 base::ScopedTempDir forced_dir; | 1606 base::ScopedTempDir forced_dir; |
1677 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); | 1607 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); |
1678 PolicyMap policies; | 1608 PolicyMap policies; |
1679 policies.Set(key::kDownloadDirectory, | 1609 policies.Set( |
1680 POLICY_LEVEL_MANDATORY, | 1610 key::kDownloadDirectory, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
1681 POLICY_SCOPE_USER, | 1611 POLICY_SOURCE_CLOUD, |
1682 POLICY_SOURCE_CLOUD, | 1612 base::WrapUnique(new base::StringValue(forced_dir.path().value())), |
1683 new base::StringValue(forced_dir.path().value()), | 1613 nullptr); |
1684 NULL); | |
1685 UpdateProviderPolicy(policies); | 1614 UpdateProviderPolicy(policies); |
1686 DownloadAndVerifyFile(browser(), forced_dir.path(), file); | 1615 DownloadAndVerifyFile(browser(), forced_dir.path(), file); |
1687 // Verify that the first download location wasn't affected. | 1616 // Verify that the first download location wasn't affected. |
1688 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); | 1617 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); |
1689 } | 1618 } |
1690 | 1619 |
1691 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) { | 1620 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) { |
1692 // Verifies that blacklisted extensions can't be installed. | 1621 // Verifies that blacklisted extensions can't be installed. |
1693 ExtensionService* service = extension_service(); | 1622 ExtensionService* service = extension_service(); |
1694 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1623 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1695 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1624 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1696 base::ListValue blacklist; | 1625 base::ListValue blacklist; |
1697 blacklist.Append(new base::StringValue(kGoodCrxId)); | 1626 blacklist.Append(new base::StringValue(kGoodCrxId)); |
1698 PolicyMap policies; | 1627 PolicyMap policies; |
1699 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1628 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1700 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 1629 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1701 nullptr); | 1630 blacklist.CreateDeepCopy(), nullptr); |
1702 UpdateProviderPolicy(policies); | 1631 UpdateProviderPolicy(policies); |
1703 | 1632 |
1704 // "good.crx" is blacklisted. | 1633 // "good.crx" is blacklisted. |
1705 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1634 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1706 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1635 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1707 | 1636 |
1708 // "adblock.crx" is not. | 1637 // "adblock.crx" is not. |
1709 const extensions::Extension* adblock = InstallExtension(kAdBlockCrxName); | 1638 const extensions::Extension* adblock = InstallExtension(kAdBlockCrxName); |
1710 ASSERT_TRUE(adblock); | 1639 ASSERT_TRUE(adblock); |
1711 EXPECT_EQ(kAdBlockCrxId, adblock->id()); | 1640 EXPECT_EQ(kAdBlockCrxId, adblock->id()); |
(...skipping 10 matching lines...) Expand all Loading... |
1722 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { | 1651 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { |
1723 // Verify that a wildcard blacklist takes effect. | 1652 // Verify that a wildcard blacklist takes effect. |
1724 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); | 1653 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); |
1725 ExtensionService* service = extension_service(); | 1654 ExtensionService* service = extension_service(); |
1726 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1655 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1727 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); | 1656 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); |
1728 base::ListValue blacklist; | 1657 base::ListValue blacklist; |
1729 blacklist.Append(new base::StringValue("*")); | 1658 blacklist.Append(new base::StringValue("*")); |
1730 PolicyMap policies; | 1659 PolicyMap policies; |
1731 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1660 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1732 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 1661 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1733 nullptr); | 1662 blacklist.CreateDeepCopy(), nullptr); |
1734 UpdateProviderPolicy(policies); | 1663 UpdateProviderPolicy(policies); |
1735 | 1664 |
1736 // AdBlock was automatically removed. | 1665 // AdBlock was automatically removed. |
1737 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1666 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1738 | 1667 |
1739 // And can't be installed again, nor can good.crx. | 1668 // And can't be installed again, nor can good.crx. |
1740 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1669 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
1741 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1670 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1742 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1671 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1743 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1672 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
(...skipping 27 matching lines...) Expand all Loading... |
1771 | 1700 |
1772 // Blacklist "*" but force-install the importer extension. The shared module | 1701 // Blacklist "*" but force-install the importer extension. The shared module |
1773 // should be automatically installed too. | 1702 // should be automatically installed too. |
1774 base::ListValue blacklist; | 1703 base::ListValue blacklist; |
1775 blacklist.AppendString("*"); | 1704 blacklist.AppendString("*"); |
1776 base::ListValue forcelist; | 1705 base::ListValue forcelist; |
1777 forcelist.AppendString( | 1706 forcelist.AppendString( |
1778 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str())); | 1707 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str())); |
1779 PolicyMap policies; | 1708 PolicyMap policies; |
1780 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1709 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1781 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 1710 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1782 nullptr); | 1711 blacklist.CreateDeepCopy(), nullptr); |
1783 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | 1712 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
1784 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, forcelist.DeepCopy(), | 1713 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1785 nullptr); | 1714 forcelist.CreateDeepCopy(), nullptr); |
1786 | 1715 |
1787 extensions::ExtensionRegistry* registry = | 1716 extensions::ExtensionRegistry* registry = |
1788 extensions::ExtensionRegistry::Get(browser()->profile()); | 1717 extensions::ExtensionRegistry::Get(browser()->profile()); |
1789 extensions::TestExtensionRegistryObserver observe_importer( | 1718 extensions::TestExtensionRegistryObserver observe_importer( |
1790 registry, kImporterId); | 1719 registry, kImporterId); |
1791 extensions::TestExtensionRegistryObserver observe_shared_module( | 1720 extensions::TestExtensionRegistryObserver observe_shared_module( |
1792 registry, kSharedModuleId); | 1721 registry, kSharedModuleId); |
1793 UpdateProviderPolicy(policies); | 1722 UpdateProviderPolicy(policies); |
1794 observe_importer.WaitForExtensionLoaded(); | 1723 observe_importer.WaitForExtensionLoaded(); |
1795 observe_shared_module.WaitForExtensionLoaded(); | 1724 observe_shared_module.WaitForExtensionLoaded(); |
(...skipping 26 matching lines...) Expand all Loading... |
1822 // Verifies that the whitelist can open exceptions to the blacklist. | 1751 // Verifies that the whitelist can open exceptions to the blacklist. |
1823 ExtensionService* service = extension_service(); | 1752 ExtensionService* service = extension_service(); |
1824 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1753 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1825 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1754 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1826 base::ListValue blacklist; | 1755 base::ListValue blacklist; |
1827 blacklist.Append(new base::StringValue("*")); | 1756 blacklist.Append(new base::StringValue("*")); |
1828 base::ListValue whitelist; | 1757 base::ListValue whitelist; |
1829 whitelist.Append(new base::StringValue(kGoodCrxId)); | 1758 whitelist.Append(new base::StringValue(kGoodCrxId)); |
1830 PolicyMap policies; | 1759 PolicyMap policies; |
1831 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1760 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1832 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 1761 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1833 nullptr); | 1762 blacklist.CreateDeepCopy(), nullptr); |
1834 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, | 1763 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, |
1835 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), | 1764 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1836 nullptr); | 1765 whitelist.CreateDeepCopy(), nullptr); |
1837 UpdateProviderPolicy(policies); | 1766 UpdateProviderPolicy(policies); |
1838 // "adblock.crx" is blacklisted. | 1767 // "adblock.crx" is blacklisted. |
1839 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1768 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
1840 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1769 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1841 // "good.crx" has a whitelist exception. | 1770 // "good.crx" has a whitelist exception. |
1842 const extensions::Extension* good = InstallExtension(kGoodCrxName); | 1771 const extensions::Extension* good = InstallExtension(kGoodCrxName); |
1843 ASSERT_TRUE(good); | 1772 ASSERT_TRUE(good); |
1844 EXPECT_EQ(kGoodCrxId, good->id()); | 1773 EXPECT_EQ(kGoodCrxId, good->id()); |
1845 EXPECT_EQ(good, service->GetExtensionById(kGoodCrxId, true)); | 1774 EXPECT_EQ(good, service->GetExtensionById(kGoodCrxId, true)); |
1846 // The user can also remove this extension. | 1775 // The user can also remove this extension. |
(...skipping 12 matching lines...) Expand all Loading... |
1859 base::FilePath path = | 1788 base::FilePath path = |
1860 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); | 1789 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); |
1861 GURL url(URLRequestMockHTTPJob::GetMockUrl(path.MaybeAsASCII())); | 1790 GURL url(URLRequestMockHTTPJob::GetMockUrl(path.MaybeAsASCII())); |
1862 | 1791 |
1863 // Setting the forcelist extension should install "good_v1.crx". | 1792 // Setting the forcelist extension should install "good_v1.crx". |
1864 base::ListValue forcelist; | 1793 base::ListValue forcelist; |
1865 forcelist.Append(new base::StringValue( | 1794 forcelist.Append(new base::StringValue( |
1866 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str()))); | 1795 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str()))); |
1867 PolicyMap policies; | 1796 PolicyMap policies; |
1868 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | 1797 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
1869 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, forcelist.DeepCopy(), | 1798 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1870 nullptr); | 1799 forcelist.CreateDeepCopy(), nullptr); |
1871 extensions::TestExtensionRegistryObserver observer( | 1800 extensions::TestExtensionRegistryObserver observer( |
1872 extensions::ExtensionRegistry::Get(browser()->profile())); | 1801 extensions::ExtensionRegistry::Get(browser()->profile())); |
1873 UpdateProviderPolicy(policies); | 1802 UpdateProviderPolicy(policies); |
1874 observer.WaitForExtensionWillBeInstalled(); | 1803 observer.WaitForExtensionWillBeInstalled(); |
1875 // Note: Cannot check that the notification details match the expected | 1804 // Note: Cannot check that the notification details match the expected |
1876 // exception, since the details object has already been freed prior to | 1805 // exception, since the details object has already been freed prior to |
1877 // the completion of observer.WaitForExtensionWillBeInstalled(). | 1806 // the completion of observer.WaitForExtensionWillBeInstalled(). |
1878 | 1807 |
1879 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); | 1808 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); |
1880 | 1809 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 | 1903 |
1975 // Setting the forcelist extension should install "good_v1.crx". | 1904 // Setting the forcelist extension should install "good_v1.crx". |
1976 base::DictionaryValue dict_value; | 1905 base::DictionaryValue dict_value; |
1977 dict_value.SetString(std::string(kGoodCrxId) + "." + | 1906 dict_value.SetString(std::string(kGoodCrxId) + "." + |
1978 extensions::schema_constants::kInstallationMode, | 1907 extensions::schema_constants::kInstallationMode, |
1979 extensions::schema_constants::kNormalInstalled); | 1908 extensions::schema_constants::kNormalInstalled); |
1980 dict_value.SetString( | 1909 dict_value.SetString( |
1981 std::string(kGoodCrxId) + "." + extensions::schema_constants::kUpdateUrl, | 1910 std::string(kGoodCrxId) + "." + extensions::schema_constants::kUpdateUrl, |
1982 url.spec()); | 1911 url.spec()); |
1983 PolicyMap policies; | 1912 PolicyMap policies; |
1984 policies.Set(key::kExtensionSettings, | 1913 policies.Set(key::kExtensionSettings, POLICY_LEVEL_MANDATORY, |
1985 POLICY_LEVEL_MANDATORY, | 1914 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
1986 POLICY_SCOPE_USER, | 1915 dict_value.CreateDeepCopy(), nullptr); |
1987 POLICY_SOURCE_CLOUD, | |
1988 dict_value.DeepCopy(), | |
1989 NULL); | |
1990 extensions::TestExtensionRegistryObserver observer( | 1916 extensions::TestExtensionRegistryObserver observer( |
1991 extensions::ExtensionRegistry::Get(browser()->profile())); | 1917 extensions::ExtensionRegistry::Get(browser()->profile())); |
1992 UpdateProviderPolicy(policies); | 1918 UpdateProviderPolicy(policies); |
1993 observer.WaitForExtensionWillBeInstalled(); | 1919 observer.WaitForExtensionWillBeInstalled(); |
1994 | 1920 |
1995 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); | 1921 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); |
1996 | 1922 |
1997 // The user is not allowed to uninstall recommended-installed extensions. | 1923 // The user is not allowed to uninstall recommended-installed extensions. |
1998 UninstallExtension(kGoodCrxId, false); | 1924 UninstallExtension(kGoodCrxId, false); |
1999 | 1925 |
(...skipping 10 matching lines...) Expand all Loading... |
2010 // Verifies that extensions are blocked if policy specifies an allowed types | 1936 // Verifies that extensions are blocked if policy specifies an allowed types |
2011 // list and the extension's type is not on that list. | 1937 // list and the extension's type is not on that list. |
2012 ExtensionService* service = extension_service(); | 1938 ExtensionService* service = extension_service(); |
2013 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1939 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
2014 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); | 1940 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); |
2015 | 1941 |
2016 base::ListValue allowed_types; | 1942 base::ListValue allowed_types; |
2017 allowed_types.AppendString("hosted_app"); | 1943 allowed_types.AppendString("hosted_app"); |
2018 PolicyMap policies; | 1944 PolicyMap policies; |
2019 policies.Set(key::kExtensionAllowedTypes, POLICY_LEVEL_MANDATORY, | 1945 policies.Set(key::kExtensionAllowedTypes, POLICY_LEVEL_MANDATORY, |
2020 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, allowed_types.DeepCopy(), | 1946 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2021 nullptr); | 1947 allowed_types.CreateDeepCopy(), nullptr); |
2022 UpdateProviderPolicy(policies); | 1948 UpdateProviderPolicy(policies); |
2023 | 1949 |
2024 // "good.crx" is blocked. | 1950 // "good.crx" is blocked. |
2025 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1951 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
2026 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1952 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
2027 | 1953 |
2028 // "hosted_app.crx" is of a whitelisted type. | 1954 // "hosted_app.crx" is of a whitelisted type. |
2029 const extensions::Extension* hosted_app = InstallExtension(kHostedAppCrxName); | 1955 const extensions::Extension* hosted_app = InstallExtension(kHostedAppCrxName); |
2030 ASSERT_TRUE(hosted_app); | 1956 ASSERT_TRUE(hosted_app); |
2031 EXPECT_EQ(kHostedAppCrxId, hosted_app->id()); | 1957 EXPECT_EQ(kHostedAppCrxId, hosted_app->id()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 PerformClick(0, 0); | 1995 PerformClick(0, 0); |
2070 download_observer.WaitForFinished(); | 1996 download_observer.WaitForFinished(); |
2071 | 1997 |
2072 // Install the policy and trigger another download. | 1998 // Install the policy and trigger another download. |
2073 base::ListValue install_sources; | 1999 base::ListValue install_sources; |
2074 install_sources.AppendString(install_source_url.spec()); | 2000 install_sources.AppendString(install_source_url.spec()); |
2075 install_sources.AppendString(referrer_url.spec()); | 2001 install_sources.AppendString(referrer_url.spec()); |
2076 PolicyMap policies; | 2002 PolicyMap policies; |
2077 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, | 2003 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, |
2078 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2004 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2079 install_sources.DeepCopy(), nullptr); | 2005 install_sources.CreateDeepCopy(), nullptr); |
2080 UpdateProviderPolicy(policies); | 2006 UpdateProviderPolicy(policies); |
2081 | 2007 |
2082 extensions::TestExtensionRegistryObserver observer( | 2008 extensions::TestExtensionRegistryObserver observer( |
2083 extensions::ExtensionRegistry::Get(browser()->profile())); | 2009 extensions::ExtensionRegistry::Get(browser()->profile())); |
2084 PerformClick(1, 0); | 2010 PerformClick(1, 0); |
2085 observer.WaitForExtensionWillBeInstalled(); | 2011 observer.WaitForExtensionWillBeInstalled(); |
2086 // Note: Cannot check that the notification details match the expected | 2012 // Note: Cannot check that the notification details match the expected |
2087 // exception, since the details object has already been freed prior to | 2013 // exception, since the details object has already been freed prior to |
2088 // the completion of observer.WaitForExtensionWillBeInstalled(). | 2014 // the completion of observer.WaitForExtensionWillBeInstalled(). |
2089 | 2015 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), | 2218 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), |
2293 browser()->profile()->GetHomePage()); | 2219 browser()->profile()->GetHomePage()); |
2294 content::WebContents* contents = | 2220 content::WebContents* contents = |
2295 browser()->tab_strip_model()->GetActiveWebContents(); | 2221 browser()->tab_strip_model()->GetActiveWebContents(); |
2296 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); | 2222 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); |
2297 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2223 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
2298 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); | 2224 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); |
2299 | 2225 |
2300 // Now override with policy. | 2226 // Now override with policy. |
2301 PolicyMap policies; | 2227 PolicyMap policies; |
2302 policies.Set(key::kHomepageLocation, | 2228 policies.Set( |
2303 POLICY_LEVEL_MANDATORY, | 2229 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2304 POLICY_SCOPE_USER, | 2230 POLICY_SOURCE_CLOUD, |
2305 POLICY_SOURCE_CLOUD, | 2231 base::WrapUnique(new base::StringValue(chrome::kChromeUICreditsURL)), |
2306 new base::StringValue(chrome::kChromeUICreditsURL), | 2232 nullptr); |
2307 NULL); | |
2308 UpdateProviderPolicy(policies); | 2233 UpdateProviderPolicy(policies); |
2309 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2234 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
2310 content::WaitForLoadStop(contents); | 2235 content::WaitForLoadStop(contents); |
2311 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); | 2236 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); |
2312 | 2237 |
2313 policies.Set(key::kHomepageIsNewTabPage, | 2238 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, |
2314 POLICY_LEVEL_MANDATORY, | 2239 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2315 POLICY_SCOPE_USER, | 2240 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
2316 POLICY_SOURCE_CLOUD, | |
2317 new base::FundamentalValue(true), | |
2318 NULL); | |
2319 UpdateProviderPolicy(policies); | 2241 UpdateProviderPolicy(policies); |
2320 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2242 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
2321 content::WaitForLoadStop(contents); | 2243 content::WaitForLoadStop(contents); |
2322 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); | 2244 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); |
2323 } | 2245 } |
2324 | 2246 |
2325 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { | 2247 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
2326 // Verifies that incognito windows can't be opened when disabled by policy. | 2248 // Verifies that incognito windows can't be opened when disabled by policy. |
2327 | 2249 |
2328 const BrowserList* active_browser_list = BrowserList::GetInstance(); | 2250 const BrowserList* active_browser_list = BrowserList::GetInstance(); |
2329 | 2251 |
2330 // Disable incognito via policy and verify that incognito windows can't be | 2252 // Disable incognito via policy and verify that incognito windows can't be |
2331 // opened. | 2253 // opened. |
2332 EXPECT_EQ(1u, active_browser_list->size()); | 2254 EXPECT_EQ(1u, active_browser_list->size()); |
2333 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 2255 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); |
2334 PolicyMap policies; | 2256 PolicyMap policies; |
2335 policies.Set(key::kIncognitoEnabled, | 2257 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
2336 POLICY_LEVEL_MANDATORY, | 2258 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2337 POLICY_SCOPE_USER, | 2259 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2338 POLICY_SOURCE_CLOUD, | |
2339 new base::FundamentalValue(false), | |
2340 NULL); | |
2341 UpdateProviderPolicy(policies); | 2260 UpdateProviderPolicy(policies); |
2342 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2261 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
2343 EXPECT_EQ(1u, active_browser_list->size()); | 2262 EXPECT_EQ(1u, active_browser_list->size()); |
2344 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 2263 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); |
2345 | 2264 |
2346 // Enable via policy and verify that incognito windows can be opened. | 2265 // Enable via policy and verify that incognito windows can be opened. |
2347 policies.Set(key::kIncognitoEnabled, | 2266 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
2348 POLICY_LEVEL_MANDATORY, | 2267 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2349 POLICY_SCOPE_USER, | 2268 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
2350 POLICY_SOURCE_CLOUD, | |
2351 new base::FundamentalValue(true), | |
2352 NULL); | |
2353 UpdateProviderPolicy(policies); | 2269 UpdateProviderPolicy(policies); |
2354 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2270 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
2355 EXPECT_EQ(2u, active_browser_list->size()); | 2271 EXPECT_EQ(2u, active_browser_list->size()); |
2356 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); | 2272 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); |
2357 } | 2273 } |
2358 | 2274 |
2359 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 2275 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
2360 // Verifies that Javascript can be disabled. | 2276 // Verifies that Javascript can be disabled. |
2361 content::WebContents* contents = | 2277 content::WebContents* contents = |
2362 browser()->tab_strip_model()->GetActiveWebContents(); | 2278 browser()->tab_strip_model()->GetActiveWebContents(); |
2363 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2279 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
2364 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2280 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
2365 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2281 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
2366 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2282 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
2367 | 2283 |
2368 // Disable Javascript via policy. | 2284 // Disable Javascript via policy. |
2369 PolicyMap policies; | 2285 PolicyMap policies; |
2370 policies.Set(key::kJavascriptEnabled, | 2286 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, |
2371 POLICY_LEVEL_MANDATORY, | 2287 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2372 POLICY_SCOPE_USER, | 2288 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2373 POLICY_SOURCE_CLOUD, | |
2374 new base::FundamentalValue(false), | |
2375 NULL); | |
2376 UpdateProviderPolicy(policies); | 2289 UpdateProviderPolicy(policies); |
2377 // Reload the page. | 2290 // Reload the page. |
2378 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2291 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
2379 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2292 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
2380 // Developer tools still work when javascript is disabled. | 2293 // Developer tools still work when javascript is disabled. |
2381 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2294 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
2382 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2295 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
2383 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2296 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
2384 // Javascript is always enabled for the internal pages. | 2297 // Javascript is always enabled for the internal pages. |
2385 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 2298 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
2386 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2299 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
2387 | 2300 |
2388 // The javascript content setting policy overrides the javascript policy. | 2301 // The javascript content setting policy overrides the javascript policy. |
2389 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2302 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
2390 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2303 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
2391 policies.Set(key::kDefaultJavaScriptSetting, | 2304 policies.Set( |
2392 POLICY_LEVEL_MANDATORY, | 2305 key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2393 POLICY_SCOPE_USER, | 2306 POLICY_SOURCE_CLOUD, |
2394 POLICY_SOURCE_CLOUD, | 2307 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ALLOW)), |
2395 new base::FundamentalValue(CONTENT_SETTING_ALLOW), | 2308 nullptr); |
2396 NULL); | |
2397 UpdateProviderPolicy(policies); | 2309 UpdateProviderPolicy(policies); |
2398 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2310 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
2399 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2311 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
2400 } | 2312 } |
2401 | 2313 |
2402 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { | 2314 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { |
2403 PrefService* prefs = browser()->profile()->GetPrefs(); | 2315 PrefService* prefs = browser()->profile()->GetPrefs(); |
2404 | 2316 |
2405 // Enabled by default. | 2317 // Enabled by default. |
2406 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2318 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
2407 | 2319 |
2408 // Disable by old, deprecated policy. | 2320 // Disable by old, deprecated policy. |
2409 PolicyMap policies; | 2321 PolicyMap policies; |
2410 policies.Set(key::kDnsPrefetchingEnabled, | 2322 policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY, |
2411 POLICY_LEVEL_MANDATORY, | 2323 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2412 POLICY_SCOPE_USER, | 2324 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2413 POLICY_SOURCE_CLOUD, | |
2414 new base::FundamentalValue(false), | |
2415 NULL); | |
2416 UpdateProviderPolicy(policies); | 2325 UpdateProviderPolicy(policies); |
2417 | 2326 |
2418 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); | 2327 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); |
2419 | 2328 |
2420 // Enabled by new policy, this should override old one. | 2329 // Enabled by new policy, this should override old one. |
2421 policies.Set( | 2330 policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY, |
2422 key::kNetworkPredictionOptions, | 2331 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2423 POLICY_LEVEL_MANDATORY, | 2332 base::WrapUnique(new base::FundamentalValue( |
2424 POLICY_SCOPE_USER, | 2333 chrome_browser_net::NETWORK_PREDICTION_ALWAYS)), |
2425 POLICY_SOURCE_CLOUD, | 2334 nullptr); |
2426 new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS), | |
2427 NULL); | |
2428 UpdateProviderPolicy(policies); | 2335 UpdateProviderPolicy(policies); |
2429 | 2336 |
2430 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2337 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
2431 } | 2338 } |
2432 | 2339 |
2433 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { | 2340 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { |
2434 // Verifies that browsing history is not saved. | 2341 // Verifies that browsing history is not saved. |
2435 PolicyMap policies; | 2342 PolicyMap policies; |
2436 policies.Set(key::kSavingBrowserHistoryDisabled, | 2343 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
2437 POLICY_LEVEL_MANDATORY, | 2344 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2438 POLICY_SCOPE_USER, | 2345 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
2439 POLICY_SOURCE_CLOUD, | |
2440 new base::FundamentalValue(true), | |
2441 NULL); | |
2442 UpdateProviderPolicy(policies); | 2346 UpdateProviderPolicy(policies); |
2443 GURL url = ui_test_utils::GetTestUrl( | 2347 GURL url = ui_test_utils::GetTestUrl( |
2444 base::FilePath(base::FilePath::kCurrentDirectory), | 2348 base::FilePath(base::FilePath::kCurrentDirectory), |
2445 base::FilePath(FILE_PATH_LITERAL("empty.html"))); | 2349 base::FilePath(FILE_PATH_LITERAL("empty.html"))); |
2446 ui_test_utils::NavigateToURL(browser(), url); | 2350 ui_test_utils::NavigateToURL(browser(), url); |
2447 // Verify that the navigation wasn't saved in the history. | 2351 // Verify that the navigation wasn't saved in the history. |
2448 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); | 2352 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); |
2449 EXPECT_EQ(0u, enumerator1.urls().size()); | 2353 EXPECT_EQ(0u, enumerator1.urls().size()); |
2450 | 2354 |
2451 // Now flip the policy and try again. | 2355 // Now flip the policy and try again. |
2452 policies.Set(key::kSavingBrowserHistoryDisabled, | 2356 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
2453 POLICY_LEVEL_MANDATORY, | 2357 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2454 POLICY_SCOPE_USER, | 2358 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2455 POLICY_SOURCE_CLOUD, | |
2456 new base::FundamentalValue(false), | |
2457 NULL); | |
2458 UpdateProviderPolicy(policies); | 2359 UpdateProviderPolicy(policies); |
2459 ui_test_utils::NavigateToURL(browser(), url); | 2360 ui_test_utils::NavigateToURL(browser(), url); |
2460 // Verify that the navigation was saved in the history. | 2361 // Verify that the navigation was saved in the history. |
2461 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); | 2362 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); |
2462 ASSERT_EQ(1u, enumerator2.urls().size()); | 2363 ASSERT_EQ(1u, enumerator2.urls().size()); |
2463 EXPECT_EQ(url, enumerator2.urls()[0]); | 2364 EXPECT_EQ(url, enumerator2.urls()[0]); |
2464 } | 2365 } |
2465 | 2366 |
2466 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 | 2367 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 |
2467 #if !defined(USE_AURA) | 2368 #if !defined(USE_AURA) |
2468 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. | 2369 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. |
2469 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { | 2370 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { |
2470 std::unique_ptr<test::CldDataHarness> cld_data_scope = | 2371 std::unique_ptr<test::CldDataHarness> cld_data_scope = |
2471 test::CldDataHarnessFactory::Get()->CreateCldDataHarness(); | 2372 test::CldDataHarnessFactory::Get()->CreateCldDataHarness(); |
2472 ASSERT_NO_FATAL_FAILURE(cld_data_scope->Init()); | 2373 ASSERT_NO_FATAL_FAILURE(cld_data_scope->Init()); |
2473 | 2374 |
2474 // Verifies that translate can be forced enabled or disabled by policy. | 2375 // Verifies that translate can be forced enabled or disabled by policy. |
2475 | 2376 |
2476 // Get the InfoBarService, and verify that there are no infobars on startup. | 2377 // Get the InfoBarService, and verify that there are no infobars on startup. |
2477 content::WebContents* contents = | 2378 content::WebContents* contents = |
2478 browser()->tab_strip_model()->GetActiveWebContents(); | 2379 browser()->tab_strip_model()->GetActiveWebContents(); |
2479 ASSERT_TRUE(contents); | 2380 ASSERT_TRUE(contents); |
2480 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); | 2381 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); |
2481 ASSERT_TRUE(infobar_service); | 2382 ASSERT_TRUE(infobar_service); |
2482 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2383 EXPECT_EQ(0u, infobar_service->infobar_count()); |
2483 | 2384 |
2484 // Force enable the translate feature. | 2385 // Force enable the translate feature. |
2485 PolicyMap policies; | 2386 PolicyMap policies; |
2486 policies.Set(key::kTranslateEnabled, | 2387 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, |
2487 POLICY_LEVEL_MANDATORY, | 2388 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2488 POLICY_SCOPE_USER, | 2389 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
2489 POLICY_SOURCE_CLOUD, | |
2490 new base::FundamentalValue(true), | |
2491 NULL); | |
2492 UpdateProviderPolicy(policies); | 2390 UpdateProviderPolicy(policies); |
2493 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test | 2391 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test |
2494 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the | 2392 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the |
2495 // TranslateManager observes. This allows checking that an infobar is NOT | 2393 // TranslateManager observes. This allows checking that an infobar is NOT |
2496 // shown below, without polling for infobars for some indeterminate amount | 2394 // shown below, without polling for infobars for some indeterminate amount |
2497 // of time. | 2395 // of time. |
2498 GURL url = ui_test_utils::GetTestUrl( | 2396 GURL url = ui_test_utils::GetTestUrl( |
2499 base::FilePath(), | 2397 base::FilePath(), |
2500 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html"))); | 2398 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html"))); |
2501 content::WindowedNotificationObserver language_observer1( | 2399 content::WindowedNotificationObserver language_observer1( |
(...skipping 20 matching lines...) Expand all Loading... |
2522 translate::TranslateInfoBarDelegate* translate_infobar_delegate = | 2420 translate::TranslateInfoBarDelegate* translate_infobar_delegate = |
2523 infobar->delegate()->AsTranslateInfoBarDelegate(); | 2421 infobar->delegate()->AsTranslateInfoBarDelegate(); |
2524 ASSERT_TRUE(translate_infobar_delegate); | 2422 ASSERT_TRUE(translate_infobar_delegate); |
2525 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 2423 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
2526 translate_infobar_delegate->translate_step()); | 2424 translate_infobar_delegate->translate_step()); |
2527 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); | 2425 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); |
2528 | 2426 |
2529 // Now force disable translate. | 2427 // Now force disable translate. |
2530 infobar_service->RemoveInfoBar(infobar); | 2428 infobar_service->RemoveInfoBar(infobar); |
2531 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2429 EXPECT_EQ(0u, infobar_service->infobar_count()); |
2532 policies.Set(key::kTranslateEnabled, | 2430 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, |
2533 POLICY_LEVEL_MANDATORY, | 2431 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2534 POLICY_SCOPE_USER, | 2432 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2535 POLICY_SOURCE_CLOUD, | |
2536 new base::FundamentalValue(false), | |
2537 NULL); | |
2538 UpdateProviderPolicy(policies); | 2433 UpdateProviderPolicy(policies); |
2539 // Navigating to the same URL now doesn't trigger an infobar. | 2434 // Navigating to the same URL now doesn't trigger an infobar. |
2540 content::WindowedNotificationObserver language_observer2( | 2435 content::WindowedNotificationObserver language_observer2( |
2541 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 2436 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
2542 content::NotificationService::AllSources()); | 2437 content::NotificationService::AllSources()); |
2543 ui_test_utils::NavigateToURL(browser(), url); | 2438 ui_test_utils::NavigateToURL(browser(), url); |
2544 language_observer2.Wait(); | 2439 language_observer2.Wait(); |
2545 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2440 EXPECT_EQ(0u, infobar_service->infobar_count()); |
2546 } | 2441 } |
2547 #endif // !defined(USE_AURA) | 2442 #endif // !defined(USE_AURA) |
(...skipping 20 matching lines...) Expand all Loading... |
2568 loop.Run(); | 2463 loop.Run(); |
2569 } | 2464 } |
2570 | 2465 |
2571 // Verify that "bbb.com" opens before applying the blacklist. | 2466 // Verify that "bbb.com" opens before applying the blacklist. |
2572 CheckCanOpenURL(browser(), kURLS[1]); | 2467 CheckCanOpenURL(browser(), kURLS[1]); |
2573 | 2468 |
2574 // Set a blacklist. | 2469 // Set a blacklist. |
2575 base::ListValue blacklist; | 2470 base::ListValue blacklist; |
2576 blacklist.Append(new base::StringValue("bbb.com")); | 2471 blacklist.Append(new base::StringValue("bbb.com")); |
2577 PolicyMap policies; | 2472 PolicyMap policies; |
2578 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2473 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2579 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 2474 POLICY_SOURCE_CLOUD, blacklist.CreateDeepCopy(), nullptr); |
2580 nullptr); | |
2581 UpdateProviderPolicy(policies); | 2475 UpdateProviderPolicy(policies); |
2582 FlushBlacklistPolicy(); | 2476 FlushBlacklistPolicy(); |
2583 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. | 2477 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. |
2584 CheckCanOpenURL(browser(), kURLS[0]); | 2478 CheckCanOpenURL(browser(), kURLS[0]); |
2585 for (size_t i = 1; i < arraysize(kURLS); ++i) | 2479 for (size_t i = 1; i < arraysize(kURLS); ++i) |
2586 CheckURLIsBlocked(browser(), kURLS[i]); | 2480 CheckURLIsBlocked(browser(), kURLS[i]); |
2587 | 2481 |
2588 // Whitelist some sites of bbb.com. | 2482 // Whitelist some sites of bbb.com. |
2589 base::ListValue whitelist; | 2483 base::ListValue whitelist; |
2590 whitelist.Append(new base::StringValue("sub.bbb.com")); | 2484 whitelist.Append(new base::StringValue("sub.bbb.com")); |
2591 whitelist.Append(new base::StringValue("bbb.com/policy")); | 2485 whitelist.Append(new base::StringValue("bbb.com/policy")); |
2592 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, | 2486 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2593 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), | 2487 POLICY_SOURCE_CLOUD, whitelist.CreateDeepCopy(), nullptr); |
2594 nullptr); | |
2595 UpdateProviderPolicy(policies); | 2488 UpdateProviderPolicy(policies); |
2596 FlushBlacklistPolicy(); | 2489 FlushBlacklistPolicy(); |
2597 CheckURLIsBlocked(browser(), kURLS[1]); | 2490 CheckURLIsBlocked(browser(), kURLS[1]); |
2598 CheckCanOpenURL(browser(), kURLS[2]); | 2491 CheckCanOpenURL(browser(), kURLS[2]); |
2599 CheckCanOpenURL(browser(), kURLS[3]); | 2492 CheckCanOpenURL(browser(), kURLS[3]); |
2600 CheckCanOpenURL(browser(), kURLS[4]); | 2493 CheckCanOpenURL(browser(), kURLS[4]); |
2601 | 2494 |
2602 { | 2495 { |
2603 base::RunLoop loop; | 2496 base::RunLoop loop; |
2604 BrowserThread::PostTaskAndReply( | 2497 BrowserThread::PostTaskAndReply( |
(...skipping 12 matching lines...) Expand all Loading... |
2617 URLRequestMockHTTPJob::GetMockUrl("policy/blacklist-subresources.html"); | 2510 URLRequestMockHTTPJob::GetMockUrl("policy/blacklist-subresources.html"); |
2618 GURL image_url = URLRequestMockHTTPJob::GetMockUrl("policy/pixel.png"); | 2511 GURL image_url = URLRequestMockHTTPJob::GetMockUrl("policy/pixel.png"); |
2619 GURL subframe_url = URLRequestMockHTTPJob::GetMockUrl("policy/blank.html"); | 2512 GURL subframe_url = URLRequestMockHTTPJob::GetMockUrl("policy/blank.html"); |
2620 | 2513 |
2621 // Set a blacklist containing the image and the iframe which are used by the | 2514 // Set a blacklist containing the image and the iframe which are used by the |
2622 // main document. | 2515 // main document. |
2623 base::ListValue blacklist; | 2516 base::ListValue blacklist; |
2624 blacklist.Append(new base::StringValue(image_url.spec().c_str())); | 2517 blacklist.Append(new base::StringValue(image_url.spec().c_str())); |
2625 blacklist.Append(new base::StringValue(subframe_url.spec().c_str())); | 2518 blacklist.Append(new base::StringValue(subframe_url.spec().c_str())); |
2626 PolicyMap policies; | 2519 PolicyMap policies; |
2627 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2520 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2628 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 2521 POLICY_SOURCE_CLOUD, blacklist.CreateDeepCopy(), nullptr); |
2629 nullptr); | |
2630 UpdateProviderPolicy(policies); | 2522 UpdateProviderPolicy(policies); |
2631 FlushBlacklistPolicy(); | 2523 FlushBlacklistPolicy(); |
2632 | 2524 |
2633 std::string blacklisted_image_load_result; | 2525 std::string blacklisted_image_load_result; |
2634 ui_test_utils::NavigateToURL(browser(), main_url); | 2526 ui_test_utils::NavigateToURL(browser(), main_url); |
2635 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 2527 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
2636 browser()->tab_strip_model()->GetActiveWebContents(), | 2528 browser()->tab_strip_model()->GetActiveWebContents(), |
2637 "window.domAutomationController.send(imageLoadResult)", | 2529 "window.domAutomationController.send(imageLoadResult)", |
2638 &blacklisted_image_load_result)); | 2530 &blacklisted_image_load_result)); |
2639 EXPECT_EQ("success", blacklisted_image_load_result); | 2531 EXPECT_EQ("success", blacklisted_image_load_result); |
(...skipping 24 matching lines...) Expand all Loading... |
2664 const std::string file_path1 = base_path + "title1.html"; | 2556 const std::string file_path1 = base_path + "title1.html"; |
2665 const std::string file_path2 = folder_path + "basic.html"; | 2557 const std::string file_path2 = folder_path + "basic.html"; |
2666 | 2558 |
2667 CheckCanOpenURL(browser(), file_path1.c_str()); | 2559 CheckCanOpenURL(browser(), file_path1.c_str()); |
2668 CheckCanOpenURL(browser(), file_path2.c_str()); | 2560 CheckCanOpenURL(browser(), file_path2.c_str()); |
2669 | 2561 |
2670 // Set a blacklist for all the files. | 2562 // Set a blacklist for all the files. |
2671 base::ListValue blacklist; | 2563 base::ListValue blacklist; |
2672 blacklist.Append(new base::StringValue("file://*")); | 2564 blacklist.Append(new base::StringValue("file://*")); |
2673 PolicyMap policies; | 2565 PolicyMap policies; |
2674 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2566 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2675 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 2567 POLICY_SOURCE_CLOUD, blacklist.CreateDeepCopy(), nullptr); |
2676 nullptr); | |
2677 UpdateProviderPolicy(policies); | 2568 UpdateProviderPolicy(policies); |
2678 FlushBlacklistPolicy(); | 2569 FlushBlacklistPolicy(); |
2679 | 2570 |
2680 CheckURLIsBlocked(browser(), file_path1.c_str()); | 2571 CheckURLIsBlocked(browser(), file_path1.c_str()); |
2681 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2572 CheckURLIsBlocked(browser(), file_path2.c_str()); |
2682 | 2573 |
2683 // Replace the URLblacklist with disabling the file scheme. | 2574 // Replace the URLblacklist with disabling the file scheme. |
2684 blacklist.Remove(base::StringValue("file://*"), NULL); | 2575 blacklist.Remove(base::StringValue("file://*"), NULL); |
2685 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2576 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2686 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 2577 POLICY_SOURCE_CLOUD, blacklist.CreateDeepCopy(), nullptr); |
2687 nullptr); | |
2688 UpdateProviderPolicy(policies); | 2578 UpdateProviderPolicy(policies); |
2689 FlushBlacklistPolicy(); | 2579 FlushBlacklistPolicy(); |
2690 | 2580 |
2691 PrefService* prefs = browser()->profile()->GetPrefs(); | 2581 PrefService* prefs = browser()->profile()->GetPrefs(); |
2692 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); | 2582 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); |
2693 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), | 2583 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), |
2694 list_url->end()); | 2584 list_url->end()); |
2695 | 2585 |
2696 base::ListValue disabledscheme; | 2586 base::ListValue disabledscheme; |
2697 disabledscheme.Append(new base::StringValue("file")); | 2587 disabledscheme.Append(new base::StringValue("file")); |
2698 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, | 2588 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2699 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2589 POLICY_SOURCE_CLOUD, disabledscheme.CreateDeepCopy(), nullptr); |
2700 disabledscheme.DeepCopy(), nullptr); | |
2701 UpdateProviderPolicy(policies); | 2590 UpdateProviderPolicy(policies); |
2702 FlushBlacklistPolicy(); | 2591 FlushBlacklistPolicy(); |
2703 | 2592 |
2704 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); | 2593 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); |
2705 EXPECT_NE(list_url->Find(base::StringValue("file://*")), | 2594 EXPECT_NE(list_url->Find(base::StringValue("file://*")), |
2706 list_url->end()); | 2595 list_url->end()); |
2707 | 2596 |
2708 // Whitelist one folder and blacklist an another just inside. | 2597 // Whitelist one folder and blacklist an another just inside. |
2709 base::ListValue whitelist; | 2598 base::ListValue whitelist; |
2710 whitelist.Append(new base::StringValue(base_path)); | 2599 whitelist.Append(new base::StringValue(base_path)); |
2711 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, | 2600 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2712 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), | 2601 POLICY_SOURCE_CLOUD, whitelist.CreateDeepCopy(), nullptr); |
2713 nullptr); | |
2714 blacklist.Append(new base::StringValue(folder_path)); | 2602 blacklist.Append(new base::StringValue(folder_path)); |
2715 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2603 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2716 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 2604 POLICY_SOURCE_CLOUD, blacklist.CreateDeepCopy(), nullptr); |
2717 nullptr); | |
2718 UpdateProviderPolicy(policies); | 2605 UpdateProviderPolicy(policies); |
2719 FlushBlacklistPolicy(); | 2606 FlushBlacklistPolicy(); |
2720 | 2607 |
2721 CheckCanOpenURL(browser(), file_path1.c_str()); | 2608 CheckCanOpenURL(browser(), file_path1.c_str()); |
2722 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2609 CheckURLIsBlocked(browser(), file_path2.c_str()); |
2723 } | 2610 } |
2724 | 2611 |
2725 namespace { | 2612 namespace { |
2726 | 2613 |
2727 void GetSSLVersionFallbackMinOnIOThread( | 2614 void GetSSLVersionFallbackMinOnIOThread( |
(...skipping 25 matching lines...) Expand all Loading... |
2753 | 2640 |
2754 const std::string new_value("tls1.1"); | 2641 const std::string new_value("tls1.1"); |
2755 const std::string default_value( | 2642 const std::string default_value( |
2756 prefs->GetString(ssl_config::prefs::kSSLVersionFallbackMin)); | 2643 prefs->GetString(ssl_config::prefs::kSSLVersionFallbackMin)); |
2757 | 2644 |
2758 EXPECT_NE(default_value, new_value); | 2645 EXPECT_NE(default_value, new_value); |
2759 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_2, | 2646 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_2, |
2760 GetSSLVersionFallbackMin(browser()->profile())); | 2647 GetSSLVersionFallbackMin(browser()->profile())); |
2761 | 2648 |
2762 PolicyMap policies; | 2649 PolicyMap policies; |
2763 policies.Set(key::kSSLVersionFallbackMin, | 2650 policies.Set(key::kSSLVersionFallbackMin, POLICY_LEVEL_MANDATORY, |
2764 POLICY_LEVEL_MANDATORY, | 2651 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2765 POLICY_SCOPE_USER, | 2652 base::WrapUnique(new base::StringValue(new_value)), nullptr); |
2766 POLICY_SOURCE_CLOUD, | |
2767 new base::StringValue(new_value), | |
2768 NULL); | |
2769 UpdateProviderPolicy(policies); | 2653 UpdateProviderPolicy(policies); |
2770 | 2654 |
2771 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_1, | 2655 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_1, |
2772 GetSSLVersionFallbackMin(browser()->profile())); | 2656 GetSSLVersionFallbackMin(browser()->profile())); |
2773 } | 2657 } |
2774 | 2658 |
2775 #if !defined(OS_MACOSX) | 2659 #if !defined(OS_MACOSX) |
2776 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { | 2660 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { |
2777 PolicyMap policies; | 2661 PolicyMap policies; |
2778 policies.Set(key::kFullscreenAllowed, | 2662 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
2779 POLICY_LEVEL_MANDATORY, | 2663 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2780 POLICY_SCOPE_USER, | 2664 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2781 POLICY_SOURCE_CLOUD, | |
2782 new base::FundamentalValue(false), | |
2783 NULL); | |
2784 UpdateProviderPolicy(policies); | 2665 UpdateProviderPolicy(policies); |
2785 | 2666 |
2786 BrowserWindow* browser_window = browser()->window(); | 2667 BrowserWindow* browser_window = browser()->window(); |
2787 ASSERT_TRUE(browser_window); | 2668 ASSERT_TRUE(browser_window); |
2788 | 2669 |
2789 EXPECT_FALSE(browser_window->IsFullscreen()); | 2670 EXPECT_FALSE(browser_window->IsFullscreen()); |
2790 chrome::ToggleFullscreenMode(browser()); | 2671 chrome::ToggleFullscreenMode(browser()); |
2791 EXPECT_FALSE(browser_window->IsFullscreen()); | 2672 EXPECT_FALSE(browser_window->IsFullscreen()); |
2792 } | 2673 } |
2793 | 2674 |
2794 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { | 2675 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { |
2795 PolicyMap policies; | 2676 PolicyMap policies; |
2796 policies.Set(key::kFullscreenAllowed, | 2677 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
2797 POLICY_LEVEL_MANDATORY, | 2678 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2798 POLICY_SCOPE_USER, | 2679 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2799 POLICY_SOURCE_CLOUD, | |
2800 new base::FundamentalValue(false), | |
2801 NULL); | |
2802 UpdateProviderPolicy(policies); | 2680 UpdateProviderPolicy(policies); |
2803 | 2681 |
2804 const extensions::Extension* extension = | 2682 const extensions::Extension* extension = |
2805 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); | 2683 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); |
2806 ASSERT_TRUE(extension); | 2684 ASSERT_TRUE(extension); |
2807 | 2685 |
2808 // Launch an app that tries to open a fullscreen window. | 2686 // Launch an app that tries to open a fullscreen window. |
2809 TestAddAppWindowObserver add_window_observer( | 2687 TestAddAppWindowObserver add_window_observer( |
2810 extensions::AppWindowRegistry::Get(browser()->profile())); | 2688 extensions::AppWindowRegistry::Get(browser()->profile())); |
2811 OpenApplication(AppLaunchParams(browser()->profile(), extension, | 2689 OpenApplication(AppLaunchParams(browser()->profile(), extension, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 std::unique_ptr<TestAudioObserver> test_observer(new TestAudioObserver); | 2736 std::unique_ptr<TestAudioObserver> test_observer(new TestAudioObserver); |
2859 audio_handler->AddAudioObserver(test_observer.get()); | 2737 audio_handler->AddAudioObserver(test_observer.get()); |
2860 | 2738 |
2861 bool prior_state = audio_handler->IsOutputMuted(); | 2739 bool prior_state = audio_handler->IsOutputMuted(); |
2862 // Make sure the audio is not muted and then toggle the policy and observe | 2740 // Make sure the audio is not muted and then toggle the policy and observe |
2863 // if the output mute changed event is fired. | 2741 // if the output mute changed event is fired. |
2864 audio_handler->SetOutputMute(false); | 2742 audio_handler->SetOutputMute(false); |
2865 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2743 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
2866 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2744 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
2867 PolicyMap policies; | 2745 PolicyMap policies; |
2868 policies.Set(key::kAudioOutputAllowed, | 2746 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
2869 POLICY_LEVEL_MANDATORY, | 2747 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2870 POLICY_SCOPE_USER, | 2748 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
2871 POLICY_SOURCE_CLOUD, | |
2872 new base::FundamentalValue(false), | |
2873 NULL); | |
2874 UpdateProviderPolicy(policies); | 2749 UpdateProviderPolicy(policies); |
2875 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2750 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
2876 // This should not change the state now and should not trigger output mute | 2751 // This should not change the state now and should not trigger output mute |
2877 // changed event. | 2752 // changed event. |
2878 audio_handler->SetOutputMute(false); | 2753 audio_handler->SetOutputMute(false); |
2879 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2754 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
2880 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2755 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
2881 | 2756 |
2882 // Toggle back and observe if the output mute changed event is fired. | 2757 // Toggle back and observe if the output mute changed event is fired. |
2883 policies.Set(key::kAudioOutputAllowed, | 2758 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
2884 POLICY_LEVEL_MANDATORY, | 2759 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2885 POLICY_SCOPE_USER, | 2760 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
2886 POLICY_SOURCE_CLOUD, | |
2887 new base::FundamentalValue(true), | |
2888 NULL); | |
2889 UpdateProviderPolicy(policies); | 2761 UpdateProviderPolicy(policies); |
2890 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2762 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
2891 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2763 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
2892 audio_handler->SetOutputMute(true); | 2764 audio_handler->SetOutputMute(true); |
2893 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2765 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
2894 EXPECT_EQ(2, test_observer->output_mute_changed_count()); | 2766 EXPECT_EQ(2, test_observer->output_mute_changed_count()); |
2895 // Revert the prior state. | 2767 // Revert the prior state. |
2896 audio_handler->SetOutputMute(prior_state); | 2768 audio_handler->SetOutputMute(prior_state); |
2897 audio_handler->RemoveAudioObserver(test_observer.get()); | 2769 audio_handler->RemoveAudioObserver(test_observer.get()); |
2898 } | 2770 } |
(...skipping 12 matching lines...) Expand all Loading... |
2911 content::NotificationRegistrar registrar; | 2783 content::NotificationRegistrar registrar; |
2912 registrar.Add(&observer, | 2784 registrar.Add(&observer, |
2913 chrome::NOTIFICATION_APP_TERMINATING, | 2785 chrome::NOTIFICATION_APP_TERMINATING, |
2914 content::NotificationService::AllSources()); | 2786 content::NotificationService::AllSources()); |
2915 | 2787 |
2916 // Set the session length limit to 3 hours. Verify that the session is not | 2788 // Set the session length limit to 3 hours. Verify that the session is not |
2917 // terminated. | 2789 // terminated. |
2918 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2790 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
2919 .Times(0); | 2791 .Times(0); |
2920 PolicyMap policies; | 2792 PolicyMap policies; |
2921 policies.Set(key::kSessionLengthLimit, | 2793 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
2922 POLICY_LEVEL_MANDATORY, | 2794 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2923 POLICY_SCOPE_USER, | 2795 base::WrapUnique(new base::FundamentalValue(kThreeHoursInMs)), |
2924 POLICY_SOURCE_CLOUD, | 2796 nullptr); |
2925 new base::FundamentalValue(kThreeHoursInMs), | |
2926 NULL); | |
2927 UpdateProviderPolicy(policies); | 2797 UpdateProviderPolicy(policies); |
2928 base::RunLoop().RunUntilIdle(); | 2798 base::RunLoop().RunUntilIdle(); |
2929 Mock::VerifyAndClearExpectations(&observer); | 2799 Mock::VerifyAndClearExpectations(&observer); |
2930 | 2800 |
2931 // Decrease the session length limit to 1 hour. Verify that the session is | 2801 // Decrease the session length limit to 1 hour. Verify that the session is |
2932 // terminated immediately. | 2802 // terminated immediately. |
2933 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2803 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
2934 policies.Set(key::kSessionLengthLimit, | 2804 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
2935 POLICY_LEVEL_MANDATORY, | 2805 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2936 POLICY_SCOPE_USER, | 2806 base::WrapUnique(new base::FundamentalValue(kOneHourInMs)), |
2937 POLICY_SOURCE_CLOUD, | 2807 nullptr); |
2938 new base::FundamentalValue(kOneHourInMs), | |
2939 NULL); | |
2940 UpdateProviderPolicy(policies); | 2808 UpdateProviderPolicy(policies); |
2941 base::RunLoop().RunUntilIdle(); | 2809 base::RunLoop().RunUntilIdle(); |
2942 Mock::VerifyAndClearExpectations(&observer); | 2810 Mock::VerifyAndClearExpectations(&observer); |
2943 } | 2811 } |
2944 | 2812 |
2945 // Disabled, see http://crbug.com/554728. | 2813 // Disabled, see http://crbug.com/554728. |
2946 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2814 IN_PROC_BROWSER_TEST_F(PolicyTest, |
2947 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { | 2815 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { |
2948 // Indicate that the session started 2 hours ago and no user activity has | 2816 // Indicate that the session started 2 hours ago and no user activity has |
2949 // occurred yet. | 2817 // occurred yet. |
2950 g_browser_process->local_state()->SetInt64( | 2818 g_browser_process->local_state()->SetInt64( |
2951 prefs::kSessionStartTime, | 2819 prefs::kSessionStartTime, |
2952 (base::TimeTicks::Now() - base::TimeDelta::FromHours(2)) | 2820 (base::TimeTicks::Now() - base::TimeDelta::FromHours(2)) |
2953 .ToInternalValue()); | 2821 .ToInternalValue()); |
2954 } | 2822 } |
2955 | 2823 |
2956 // Disabled, see http://crbug.com/554728. | 2824 // Disabled, see http://crbug.com/554728. |
2957 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2825 IN_PROC_BROWSER_TEST_F(PolicyTest, |
2958 DISABLED_WaitForInitialUserActivityUnsatisfied) { | 2826 DISABLED_WaitForInitialUserActivityUnsatisfied) { |
2959 content::MockNotificationObserver observer; | 2827 content::MockNotificationObserver observer; |
2960 content::NotificationRegistrar registrar; | 2828 content::NotificationRegistrar registrar; |
2961 registrar.Add(&observer, | 2829 registrar.Add(&observer, |
2962 chrome::NOTIFICATION_APP_TERMINATING, | 2830 chrome::NOTIFICATION_APP_TERMINATING, |
2963 content::NotificationService::AllSources()); | 2831 content::NotificationService::AllSources()); |
2964 | 2832 |
2965 // Require initial user activity. | 2833 // Require initial user activity. |
2966 PolicyMap policies; | 2834 PolicyMap policies; |
2967 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2835 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
2968 POLICY_SCOPE_USER, | 2836 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2969 POLICY_SOURCE_CLOUD, | 2837 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
2970 new base::FundamentalValue(true), | |
2971 NULL); | |
2972 UpdateProviderPolicy(policies); | 2838 UpdateProviderPolicy(policies); |
2973 base::RunLoop().RunUntilIdle(); | 2839 base::RunLoop().RunUntilIdle(); |
2974 | 2840 |
2975 // Set the session length limit to 1 hour. Verify that the session is not | 2841 // Set the session length limit to 1 hour. Verify that the session is not |
2976 // terminated. | 2842 // terminated. |
2977 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2843 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
2978 .Times(0); | 2844 .Times(0); |
2979 policies.Set(key::kSessionLengthLimit, | 2845 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
2980 POLICY_LEVEL_MANDATORY, | 2846 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
2981 POLICY_SCOPE_USER, | 2847 base::WrapUnique(new base::FundamentalValue(kOneHourInMs)), |
2982 POLICY_SOURCE_CLOUD, | 2848 nullptr); |
2983 new base::FundamentalValue(kOneHourInMs), | |
2984 NULL); | |
2985 UpdateProviderPolicy(policies); | 2849 UpdateProviderPolicy(policies); |
2986 base::RunLoop().RunUntilIdle(); | 2850 base::RunLoop().RunUntilIdle(); |
2987 Mock::VerifyAndClearExpectations(&observer); | 2851 Mock::VerifyAndClearExpectations(&observer); |
2988 } | 2852 } |
2989 | 2853 |
2990 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2854 IN_PROC_BROWSER_TEST_F(PolicyTest, |
2991 PRE_WaitForInitialUserActivitySatisfied) { | 2855 PRE_WaitForInitialUserActivitySatisfied) { |
2992 // Indicate that initial user activity in this session occurred 2 hours ago. | 2856 // Indicate that initial user activity in this session occurred 2 hours ago. |
2993 g_browser_process->local_state()->SetInt64( | 2857 g_browser_process->local_state()->SetInt64( |
2994 prefs::kSessionStartTime, | 2858 prefs::kSessionStartTime, |
(...skipping 11 matching lines...) Expand all Loading... |
3006 registrar.Add(&observer, | 2870 registrar.Add(&observer, |
3007 chrome::NOTIFICATION_APP_TERMINATING, | 2871 chrome::NOTIFICATION_APP_TERMINATING, |
3008 content::NotificationService::AllSources()); | 2872 content::NotificationService::AllSources()); |
3009 | 2873 |
3010 // Require initial user activity and set the session length limit to 3 hours. | 2874 // Require initial user activity and set the session length limit to 3 hours. |
3011 // Verify that the session is not terminated. | 2875 // Verify that the session is not terminated. |
3012 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2876 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
3013 .Times(0); | 2877 .Times(0); |
3014 PolicyMap policies; | 2878 PolicyMap policies; |
3015 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2879 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
3016 POLICY_SCOPE_USER, | 2880 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3017 POLICY_SOURCE_CLOUD, | 2881 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
3018 new base::FundamentalValue(true), | 2882 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
3019 NULL); | 2883 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3020 policies.Set(key::kSessionLengthLimit, | 2884 base::WrapUnique(new base::FundamentalValue(kThreeHoursInMs)), |
3021 POLICY_LEVEL_MANDATORY, | 2885 nullptr); |
3022 POLICY_SCOPE_USER, | |
3023 POLICY_SOURCE_CLOUD, | |
3024 new base::FundamentalValue(kThreeHoursInMs), | |
3025 NULL); | |
3026 UpdateProviderPolicy(policies); | 2886 UpdateProviderPolicy(policies); |
3027 base::RunLoop().RunUntilIdle(); | 2887 base::RunLoop().RunUntilIdle(); |
3028 Mock::VerifyAndClearExpectations(&observer); | 2888 Mock::VerifyAndClearExpectations(&observer); |
3029 | 2889 |
3030 // Decrease the session length limit to 1 hour. Verify that the session is | 2890 // Decrease the session length limit to 1 hour. Verify that the session is |
3031 // terminated immediately. | 2891 // terminated immediately. |
3032 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2892 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
3033 policies.Set(key::kSessionLengthLimit, | 2893 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
3034 POLICY_LEVEL_MANDATORY, | 2894 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3035 POLICY_SCOPE_USER, | 2895 base::WrapUnique(new base::FundamentalValue(kOneHourInMs)), |
3036 POLICY_SOURCE_CLOUD, | 2896 nullptr); |
3037 new base::FundamentalValue(kOneHourInMs), | |
3038 NULL); | |
3039 UpdateProviderPolicy(policies); | 2897 UpdateProviderPolicy(policies); |
3040 base::RunLoop().RunUntilIdle(); | 2898 base::RunLoop().RunUntilIdle(); |
3041 Mock::VerifyAndClearExpectations(&observer); | 2899 Mock::VerifyAndClearExpectations(&observer); |
3042 } | 2900 } |
3043 | 2901 |
3044 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { | 2902 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { |
3045 // Verifies that the large cursor accessibility feature can be controlled | 2903 // Verifies that the large cursor accessibility feature can be controlled |
3046 // through policy. | 2904 // through policy. |
3047 chromeos::AccessibilityManager* accessibility_manager = | 2905 chromeos::AccessibilityManager* accessibility_manager = |
3048 chromeos::AccessibilityManager::Get(); | 2906 chromeos::AccessibilityManager::Get(); |
3049 | 2907 |
3050 // Manually enable the large cursor. | 2908 // Manually enable the large cursor. |
3051 accessibility_manager->EnableLargeCursor(true); | 2909 accessibility_manager->EnableLargeCursor(true); |
3052 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); | 2910 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); |
3053 | 2911 |
3054 // Verify that policy overrides the manual setting. | 2912 // Verify that policy overrides the manual setting. |
3055 PolicyMap policies; | 2913 PolicyMap policies; |
3056 policies.Set(key::kLargeCursorEnabled, | 2914 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, |
3057 POLICY_LEVEL_MANDATORY, | 2915 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3058 POLICY_SCOPE_USER, | 2916 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3059 POLICY_SOURCE_CLOUD, | |
3060 new base::FundamentalValue(false), | |
3061 NULL); | |
3062 UpdateProviderPolicy(policies); | 2917 UpdateProviderPolicy(policies); |
3063 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2918 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
3064 | 2919 |
3065 // Verify that the large cursor cannot be enabled manually anymore. | 2920 // Verify that the large cursor cannot be enabled manually anymore. |
3066 accessibility_manager->EnableLargeCursor(true); | 2921 accessibility_manager->EnableLargeCursor(true); |
3067 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2922 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
3068 } | 2923 } |
3069 | 2924 |
3070 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { | 2925 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { |
3071 // Verifies that the spoken feedback accessibility feature can be controlled | 2926 // Verifies that the spoken feedback accessibility feature can be controlled |
3072 // through policy. | 2927 // through policy. |
3073 chromeos::AccessibilityManager* accessibility_manager = | 2928 chromeos::AccessibilityManager* accessibility_manager = |
3074 chromeos::AccessibilityManager::Get(); | 2929 chromeos::AccessibilityManager::Get(); |
3075 | 2930 |
3076 // Manually enable spoken feedback. | 2931 // Manually enable spoken feedback. |
3077 accessibility_manager->EnableSpokenFeedback( | 2932 accessibility_manager->EnableSpokenFeedback( |
3078 true, ui::A11Y_NOTIFICATION_NONE); | 2933 true, ui::A11Y_NOTIFICATION_NONE); |
3079 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2934 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); |
3080 | 2935 |
3081 // Verify that policy overrides the manual setting. | 2936 // Verify that policy overrides the manual setting. |
3082 PolicyMap policies; | 2937 PolicyMap policies; |
3083 policies.Set(key::kSpokenFeedbackEnabled, | 2938 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, |
3084 POLICY_LEVEL_MANDATORY, | 2939 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3085 POLICY_SCOPE_USER, | 2940 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3086 POLICY_SOURCE_CLOUD, | |
3087 new base::FundamentalValue(false), | |
3088 NULL); | |
3089 UpdateProviderPolicy(policies); | 2941 UpdateProviderPolicy(policies); |
3090 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2942 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
3091 | 2943 |
3092 // Verify that spoken feedback cannot be enabled manually anymore. | 2944 // Verify that spoken feedback cannot be enabled manually anymore. |
3093 accessibility_manager->EnableSpokenFeedback( | 2945 accessibility_manager->EnableSpokenFeedback( |
3094 true, ui::A11Y_NOTIFICATION_NONE); | 2946 true, ui::A11Y_NOTIFICATION_NONE); |
3095 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2947 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
3096 } | 2948 } |
3097 | 2949 |
3098 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { | 2950 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { |
3099 // Verifies that the high contrast mode accessibility feature can be | 2951 // Verifies that the high contrast mode accessibility feature can be |
3100 // controlled through policy. | 2952 // controlled through policy. |
3101 chromeos::AccessibilityManager* accessibility_manager = | 2953 chromeos::AccessibilityManager* accessibility_manager = |
3102 chromeos::AccessibilityManager::Get(); | 2954 chromeos::AccessibilityManager::Get(); |
3103 | 2955 |
3104 // Manually enable high contrast mode. | 2956 // Manually enable high contrast mode. |
3105 accessibility_manager->EnableHighContrast(true); | 2957 accessibility_manager->EnableHighContrast(true); |
3106 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); | 2958 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); |
3107 | 2959 |
3108 // Verify that policy overrides the manual setting. | 2960 // Verify that policy overrides the manual setting. |
3109 PolicyMap policies; | 2961 PolicyMap policies; |
3110 policies.Set(key::kHighContrastEnabled, | 2962 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, |
3111 POLICY_LEVEL_MANDATORY, | 2963 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3112 POLICY_SCOPE_USER, | 2964 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3113 POLICY_SOURCE_CLOUD, | |
3114 new base::FundamentalValue(false), | |
3115 NULL); | |
3116 UpdateProviderPolicy(policies); | 2965 UpdateProviderPolicy(policies); |
3117 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2966 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
3118 | 2967 |
3119 // Verify that high contrast mode cannot be enabled manually anymore. | 2968 // Verify that high contrast mode cannot be enabled manually anymore. |
3120 accessibility_manager->EnableHighContrast(true); | 2969 accessibility_manager->EnableHighContrast(true); |
3121 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2970 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
3122 } | 2971 } |
3123 | 2972 |
3124 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { | 2973 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { |
3125 // Verifies that the screen magnifier can be disabled through policy. | 2974 // Verifies that the screen magnifier can be disabled through policy. |
3126 chromeos::MagnificationManager* magnification_manager = | 2975 chromeos::MagnificationManager* magnification_manager = |
3127 chromeos::MagnificationManager::Get(); | 2976 chromeos::MagnificationManager::Get(); |
3128 | 2977 |
3129 // Manually enable the full-screen magnifier. | 2978 // Manually enable the full-screen magnifier. |
3130 magnification_manager->SetMagnifierType(ui::MAGNIFIER_FULL); | 2979 magnification_manager->SetMagnifierType(ui::MAGNIFIER_FULL); |
3131 magnification_manager->SetMagnifierEnabled(true); | 2980 magnification_manager->SetMagnifierEnabled(true); |
3132 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 2981 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
3133 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2982 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
3134 | 2983 |
3135 // Verify that policy overrides the manual setting. | 2984 // Verify that policy overrides the manual setting. |
3136 PolicyMap policies; | 2985 PolicyMap policies; |
3137 policies.Set(key::kScreenMagnifierType, | 2986 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
3138 POLICY_LEVEL_MANDATORY, | 2987 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3139 POLICY_SCOPE_USER, | 2988 base::WrapUnique(new base::FundamentalValue(0)), nullptr); |
3140 POLICY_SOURCE_CLOUD, | |
3141 new base::FundamentalValue(0), | |
3142 NULL); | |
3143 UpdateProviderPolicy(policies); | 2989 UpdateProviderPolicy(policies); |
3144 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2990 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
3145 | 2991 |
3146 // Verify that the screen magnifier cannot be enabled manually anymore. | 2992 // Verify that the screen magnifier cannot be enabled manually anymore. |
3147 magnification_manager->SetMagnifierEnabled(true); | 2993 magnification_manager->SetMagnifierEnabled(true); |
3148 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2994 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
3149 } | 2995 } |
3150 | 2996 |
3151 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { | 2997 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { |
3152 // Verifies that the full-screen magnifier can be enabled through policy. | 2998 // Verifies that the full-screen magnifier can be enabled through policy. |
3153 chromeos::MagnificationManager* magnification_manager = | 2999 chromeos::MagnificationManager* magnification_manager = |
3154 chromeos::MagnificationManager::Get(); | 3000 chromeos::MagnificationManager::Get(); |
3155 | 3001 |
3156 // Verify that the screen magnifier is initially disabled. | 3002 // Verify that the screen magnifier is initially disabled. |
3157 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 3003 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
3158 | 3004 |
3159 // Verify that policy can enable the full-screen magnifier. | 3005 // Verify that policy can enable the full-screen magnifier. |
3160 PolicyMap policies; | 3006 PolicyMap policies; |
3161 policies.Set(key::kScreenMagnifierType, | 3007 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
3162 POLICY_LEVEL_MANDATORY, | 3008 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3163 POLICY_SCOPE_USER, | 3009 base::WrapUnique(new base::FundamentalValue(ui::MAGNIFIER_FULL)), |
3164 POLICY_SOURCE_CLOUD, | 3010 nullptr); |
3165 new base::FundamentalValue(ui::MAGNIFIER_FULL), | |
3166 NULL); | |
3167 UpdateProviderPolicy(policies); | 3011 UpdateProviderPolicy(policies); |
3168 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 3012 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
3169 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 3013 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
3170 | 3014 |
3171 // Verify that the screen magnifier cannot be disabled manually anymore. | 3015 // Verify that the screen magnifier cannot be disabled manually anymore. |
3172 magnification_manager->SetMagnifierEnabled(false); | 3016 magnification_manager->SetMagnifierEnabled(false); |
3173 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 3017 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
3174 } | 3018 } |
3175 | 3019 |
3176 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { | 3020 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { |
3177 // Verifies that the on-screen keyboard accessibility feature can be | 3021 // Verifies that the on-screen keyboard accessibility feature can be |
3178 // controlled through policy. | 3022 // controlled through policy. |
3179 chromeos::AccessibilityManager* accessibility_manager = | 3023 chromeos::AccessibilityManager* accessibility_manager = |
3180 chromeos::AccessibilityManager::Get(); | 3024 chromeos::AccessibilityManager::Get(); |
3181 | 3025 |
3182 // Manually enable the on-screen keyboard. | 3026 // Manually enable the on-screen keyboard. |
3183 accessibility_manager->EnableVirtualKeyboard(true); | 3027 accessibility_manager->EnableVirtualKeyboard(true); |
3184 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); | 3028 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); |
3185 | 3029 |
3186 // Verify that policy overrides the manual setting. | 3030 // Verify that policy overrides the manual setting. |
3187 PolicyMap policies; | 3031 PolicyMap policies; |
3188 policies.Set(key::kVirtualKeyboardEnabled, | 3032 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
3189 POLICY_LEVEL_MANDATORY, | 3033 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3190 POLICY_SCOPE_USER, | 3034 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3191 POLICY_SOURCE_CLOUD, | |
3192 new base::FundamentalValue(false), | |
3193 NULL); | |
3194 UpdateProviderPolicy(policies); | 3035 UpdateProviderPolicy(policies); |
3195 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 3036 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
3196 | 3037 |
3197 // Verify that the on-screen keyboard cannot be enabled manually anymore. | 3038 // Verify that the on-screen keyboard cannot be enabled manually anymore. |
3198 accessibility_manager->EnableVirtualKeyboard(true); | 3039 accessibility_manager->EnableVirtualKeyboard(true); |
3199 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 3040 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
3200 } | 3041 } |
3201 | 3042 |
3202 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { | 3043 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { |
3203 // Verify keyboard disabled by default. | 3044 // Verify keyboard disabled by default. |
3204 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3045 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3205 // Verify keyboard can be toggled by default. | 3046 // Verify keyboard can be toggled by default. |
3206 keyboard::SetTouchKeyboardEnabled(true); | 3047 keyboard::SetTouchKeyboardEnabled(true); |
3207 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 3048 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
3208 keyboard::SetTouchKeyboardEnabled(false); | 3049 keyboard::SetTouchKeyboardEnabled(false); |
3209 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3050 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3210 | 3051 |
3211 // Verify enabling the policy takes effect immediately and that that user | 3052 // Verify enabling the policy takes effect immediately and that that user |
3212 // cannot disable the keyboard.. | 3053 // cannot disable the keyboard.. |
3213 PolicyMap policies; | 3054 PolicyMap policies; |
3214 policies.Set(key::kTouchVirtualKeyboardEnabled, | 3055 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
3215 POLICY_LEVEL_MANDATORY, | 3056 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3216 POLICY_SCOPE_USER, | 3057 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
3217 POLICY_SOURCE_CLOUD, | |
3218 new base::FundamentalValue(true), | |
3219 NULL); | |
3220 UpdateProviderPolicy(policies); | 3058 UpdateProviderPolicy(policies); |
3221 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 3059 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
3222 keyboard::SetTouchKeyboardEnabled(false); | 3060 keyboard::SetTouchKeyboardEnabled(false); |
3223 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 3061 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
3224 | 3062 |
3225 // Verify that disabling the policy takes effect immediately and that the user | 3063 // Verify that disabling the policy takes effect immediately and that the user |
3226 // cannot enable the keyboard. | 3064 // cannot enable the keyboard. |
3227 policies.Set(key::kTouchVirtualKeyboardEnabled, | 3065 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
3228 POLICY_LEVEL_MANDATORY, | 3066 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3229 POLICY_SCOPE_USER, | 3067 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3230 POLICY_SOURCE_CLOUD, | |
3231 new base::FundamentalValue(false), | |
3232 NULL); | |
3233 UpdateProviderPolicy(policies); | 3068 UpdateProviderPolicy(policies); |
3234 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3069 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3235 keyboard::SetTouchKeyboardEnabled(true); | 3070 keyboard::SetTouchKeyboardEnabled(true); |
3236 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 3071 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
3237 } | 3072 } |
3238 | 3073 |
3239 #endif | 3074 #endif |
3240 | 3075 |
3241 namespace { | 3076 namespace { |
3242 | 3077 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3295 } | 3130 } |
3296 | 3131 |
3297 void ListOfURLs() { | 3132 void ListOfURLs() { |
3298 // Verifies that policy can set the startup pages to a list of URLs. | 3133 // Verifies that policy can set the startup pages to a list of URLs. |
3299 base::ListValue urls; | 3134 base::ListValue urls; |
3300 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { | 3135 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { |
3301 urls.Append(new base::StringValue(kRestoredURLs[i])); | 3136 urls.Append(new base::StringValue(kRestoredURLs[i])); |
3302 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 3137 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
3303 } | 3138 } |
3304 PolicyMap policies; | 3139 PolicyMap policies; |
3305 policies.Set(key::kRestoreOnStartup, | 3140 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
3306 POLICY_LEVEL_MANDATORY, | 3141 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3307 POLICY_SCOPE_USER, | 3142 base::WrapUnique(new base::FundamentalValue( |
3308 POLICY_SOURCE_CLOUD, | 3143 SessionStartupPref::kPrefValueURLs)), |
3309 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), | 3144 nullptr); |
3310 NULL); | 3145 policies.Set(key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, |
3311 policies.Set( | 3146 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, urls.CreateDeepCopy(), |
3312 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3147 nullptr); |
3313 POLICY_SOURCE_CLOUD, urls.DeepCopy(), nullptr); | |
3314 provider_.UpdateChromePolicy(policies); | 3148 provider_.UpdateChromePolicy(policies); |
3315 } | 3149 } |
3316 | 3150 |
3317 void NTP() { | 3151 void NTP() { |
3318 // Verifies that policy can set the startup page to the NTP. | 3152 // Verifies that policy can set the startup page to the NTP. |
3319 PolicyMap policies; | 3153 PolicyMap policies; |
3320 policies.Set( | 3154 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
3321 key::kRestoreOnStartup, | 3155 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3322 POLICY_LEVEL_MANDATORY, | 3156 base::WrapUnique(new base::FundamentalValue( |
3323 POLICY_SCOPE_USER, | 3157 SessionStartupPref::kPrefValueNewTab)), |
3324 POLICY_SOURCE_CLOUD, | 3158 nullptr); |
3325 new base::FundamentalValue(SessionStartupPref::kPrefValueNewTab), | |
3326 NULL); | |
3327 provider_.UpdateChromePolicy(policies); | 3159 provider_.UpdateChromePolicy(policies); |
3328 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); | 3160 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); |
3329 } | 3161 } |
3330 | 3162 |
3331 void Last() { | 3163 void Last() { |
3332 // Verifies that policy can set the startup pages to the last session. | 3164 // Verifies that policy can set the startup pages to the last session. |
3333 PolicyMap policies; | 3165 PolicyMap policies; |
3334 policies.Set(key::kRestoreOnStartup, | 3166 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
3335 POLICY_LEVEL_MANDATORY, | 3167 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3336 POLICY_SCOPE_USER, | 3168 base::WrapUnique(new base::FundamentalValue( |
3337 POLICY_SOURCE_CLOUD, | 3169 SessionStartupPref::kPrefValueLast)), |
3338 new base::FundamentalValue(SessionStartupPref::kPrefValueLast), | 3170 nullptr); |
3339 NULL); | |
3340 provider_.UpdateChromePolicy(policies); | 3171 provider_.UpdateChromePolicy(policies); |
3341 // This should restore the tabs opened at PRE_RunTest below. | 3172 // This should restore the tabs opened at PRE_RunTest below. |
3342 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) | 3173 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) |
3343 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 3174 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
3344 } | 3175 } |
3345 | 3176 |
3346 std::vector<GURL> expected_urls_; | 3177 std::vector<GURL> expected_urls_; |
3347 }; | 3178 }; |
3348 | 3179 |
3349 IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, PRE_RunTest) { | 3180 IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, PRE_RunTest) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3387 // Similar to PolicyTest but sets a couple of policies before the browser is | 3218 // Similar to PolicyTest but sets a couple of policies before the browser is |
3388 // started. | 3219 // started. |
3389 class PolicyStatisticsCollectorTest : public PolicyTest { | 3220 class PolicyStatisticsCollectorTest : public PolicyTest { |
3390 public: | 3221 public: |
3391 PolicyStatisticsCollectorTest() {} | 3222 PolicyStatisticsCollectorTest() {} |
3392 ~PolicyStatisticsCollectorTest() override {} | 3223 ~PolicyStatisticsCollectorTest() override {} |
3393 | 3224 |
3394 void SetUpInProcessBrowserTestFixture() override { | 3225 void SetUpInProcessBrowserTestFixture() override { |
3395 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3226 PolicyTest::SetUpInProcessBrowserTestFixture(); |
3396 PolicyMap policies; | 3227 PolicyMap policies; |
3397 policies.Set(key::kShowHomeButton, | 3228 policies.Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, |
3398 POLICY_LEVEL_MANDATORY, | 3229 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3399 POLICY_SCOPE_USER, | 3230 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
3400 POLICY_SOURCE_CLOUD, | 3231 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
3401 new base::FundamentalValue(true), | 3232 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3402 NULL); | 3233 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3403 policies.Set(key::kBookmarkBarEnabled, | 3234 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, |
3404 POLICY_LEVEL_MANDATORY, | 3235 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3405 POLICY_SCOPE_USER, | 3236 base::WrapUnique(new base::StringValue("http://chromium.org")), |
3406 POLICY_SOURCE_CLOUD, | 3237 nullptr); |
3407 new base::FundamentalValue(false), | |
3408 NULL); | |
3409 policies.Set(key::kHomepageLocation, | |
3410 POLICY_LEVEL_MANDATORY, | |
3411 POLICY_SCOPE_USER, | |
3412 POLICY_SOURCE_CLOUD, | |
3413 new base::StringValue("http://chromium.org"), | |
3414 NULL); | |
3415 provider_.UpdateChromePolicy(policies); | 3238 provider_.UpdateChromePolicy(policies); |
3416 } | 3239 } |
3417 }; | 3240 }; |
3418 | 3241 |
3419 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { | 3242 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { |
3420 // Verifies that policy usage histograms are collected at startup. | 3243 // Verifies that policy usage histograms are collected at startup. |
3421 | 3244 |
3422 // BrowserPolicyConnector::Init() has already been called. Make sure the | 3245 // BrowserPolicyConnector::Init() has already been called. Make sure the |
3423 // CompleteInitialization() task has executed as well. | 3246 // CompleteInitialization() task has executed as well. |
3424 content::RunAllPendingInMessageLoop(); | 3247 content::RunAllPendingInMessageLoop(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3467 virtual ~MediaStreamDevicesControllerBrowserTest() {} | 3290 virtual ~MediaStreamDevicesControllerBrowserTest() {} |
3468 | 3291 |
3469 // Configure a given policy map. The |policy_name| is the name of either the | 3292 // Configure a given policy map. The |policy_name| is the name of either the |
3470 // audio or video capture allow policy and must never be NULL. | 3293 // audio or video capture allow policy and must never be NULL. |
3471 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist | 3294 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist |
3472 // policy is set. If non-NULL, the whitelist policy is set to contain either | 3295 // policy is set. If non-NULL, the whitelist policy is set to contain either |
3473 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. | 3296 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. |
3474 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, | 3297 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, |
3475 const char* whitelist_policy, | 3298 const char* whitelist_policy, |
3476 const char* allow_rule) { | 3299 const char* allow_rule) { |
3477 policies->Set(policy_name, | 3300 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
3478 POLICY_LEVEL_MANDATORY, | |
3479 POLICY_SCOPE_USER, | |
3480 POLICY_SOURCE_CLOUD, | 3301 POLICY_SOURCE_CLOUD, |
3481 new base::FundamentalValue(policy_value_), | 3302 base::WrapUnique(new base::FundamentalValue(policy_value_)), |
3482 NULL); | 3303 nullptr); |
3483 | 3304 |
3484 if (whitelist_policy) { | 3305 if (whitelist_policy) { |
3485 // Add an entry to the whitelist that allows the specified URL regardless | 3306 // Add an entry to the whitelist that allows the specified URL regardless |
3486 // of the setting of kAudioCapturedAllowed. | 3307 // of the setting of kAudioCapturedAllowed. |
3487 base::ListValue* list = new base::ListValue(); | 3308 std::unique_ptr<base::ListValue> list(new base::ListValue); |
3488 if (allow_rule) { | 3309 if (allow_rule) { |
3489 list->AppendString(allow_rule); | 3310 list->AppendString(allow_rule); |
3490 request_url_allowed_via_whitelist_ = true; | 3311 request_url_allowed_via_whitelist_ = true; |
3491 } else { | 3312 } else { |
3492 list->AppendString(ContentSettingsPattern::Wildcard().ToString()); | 3313 list->AppendString(ContentSettingsPattern::Wildcard().ToString()); |
3493 // We should ignore all wildcard entries in the whitelist, so even | 3314 // We should ignore all wildcard entries in the whitelist, so even |
3494 // though we've added an entry, it should be ignored and our expectation | 3315 // though we've added an entry, it should be ignored and our expectation |
3495 // is that the request has not been allowed via the whitelist. | 3316 // is that the request has not been allowed via the whitelist. |
3496 request_url_allowed_via_whitelist_ = false; | 3317 request_url_allowed_via_whitelist_ = false; |
3497 } | 3318 } |
3498 policies->Set(whitelist_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3319 policies->Set(whitelist_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
3499 POLICY_SOURCE_CLOUD, list, nullptr); | 3320 POLICY_SOURCE_CLOUD, std::move(list), nullptr); |
3500 } | 3321 } |
3501 } | 3322 } |
3502 | 3323 |
3503 void Accept(const content::MediaStreamDevices& devices, | 3324 void Accept(const content::MediaStreamDevices& devices, |
3504 content::MediaStreamRequestResult result, | 3325 content::MediaStreamRequestResult result, |
3505 std::unique_ptr<content::MediaStreamUI> ui) { | 3326 std::unique_ptr<content::MediaStreamUI> ui) { |
3506 if (policy_value_ || request_url_allowed_via_whitelist_) { | 3327 if (policy_value_ || request_url_allowed_via_whitelist_) { |
3507 ASSERT_EQ(1U, devices.size()); | 3328 ASSERT_EQ(1U, devices.size()); |
3508 ASSERT_EQ("fake_dev", devices[0].id); | 3329 ASSERT_EQ("fake_dev", devices[0].id); |
3509 } else { | 3330 } else { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3700 content::WebContents* const web_contents = | 3521 content::WebContents* const web_contents = |
3701 browser()->tab_strip_model()->GetActiveWebContents(); | 3522 browser()->tab_strip_model()->GetActiveWebContents(); |
3702 EXPECT_THAT( | 3523 EXPECT_THAT( |
3703 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), | 3524 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), |
3704 testing::StartsWith("http://localhost:")); | 3525 testing::StartsWith("http://localhost:")); |
3705 | 3526 |
3706 // Set the policy to block Web Bluetooth. | 3527 // Set the policy to block Web Bluetooth. |
3707 PolicyMap policies; | 3528 PolicyMap policies; |
3708 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, | 3529 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, |
3709 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3530 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3710 new base::FundamentalValue(2), nullptr); | 3531 base::WrapUnique(new base::FundamentalValue(2)), nullptr); |
3711 UpdateProviderPolicy(policies); | 3532 UpdateProviderPolicy(policies); |
3712 | 3533 |
3713 std::string rejection; | 3534 std::string rejection; |
3714 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 3535 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
3715 web_contents, | 3536 web_contents, |
3716 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" | 3537 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" |
3717 " .then(() => { domAutomationController.send('Success'); }," | 3538 " .then(() => { domAutomationController.send('Success'); }," |
3718 " reason => {" | 3539 " reason => {" |
3719 " domAutomationController.send(reason.name + ': ' + reason.message);" | 3540 " domAutomationController.send(reason.name + ': ' + reason.message);" |
3720 " });", | 3541 " });", |
(...skipping 10 matching lines...) Expand all Loading... |
3731 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3552 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
3732 ASSERT_TRUE(https_server_expired.Start()); | 3553 ASSERT_TRUE(https_server_expired.Start()); |
3733 | 3554 |
3734 // Set the enterprise policy to disallow opt-in. | 3555 // Set the enterprise policy to disallow opt-in. |
3735 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3556 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
3736 EXPECT_TRUE( | 3557 EXPECT_TRUE( |
3737 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3558 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
3738 PolicyMap policies; | 3559 PolicyMap policies; |
3739 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, | 3560 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, |
3740 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3561 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3741 new base::FundamentalValue(false), nullptr); | 3562 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3742 UpdateProviderPolicy(policies); | 3563 UpdateProviderPolicy(policies); |
3743 EXPECT_FALSE( | 3564 EXPECT_FALSE( |
3744 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3565 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
3745 | 3566 |
3746 // Navigate to an SSL error page. | 3567 // Navigate to an SSL error page. |
3747 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3568 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
3748 | 3569 |
3749 const content::InterstitialPage* const interstitial = | 3570 const content::InterstitialPage* const interstitial = |
3750 content::InterstitialPage::GetInterstitialPage( | 3571 content::InterstitialPage::GetInterstitialPage( |
3751 browser()->tab_strip_model()->GetActiveWebContents()); | 3572 browser()->tab_strip_model()->GetActiveWebContents()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3813 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3634 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
3814 ASSERT_TRUE(https_server_expired.Start()); | 3635 ASSERT_TRUE(https_server_expired.Start()); |
3815 | 3636 |
3816 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3637 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
3817 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3638 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
3818 | 3639 |
3819 // Disallowing the proceed link by setting the policy to |false|. | 3640 // Disallowing the proceed link by setting the policy to |false|. |
3820 PolicyMap policies; | 3641 PolicyMap policies; |
3821 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, | 3642 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, |
3822 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3643 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3823 new base::FundamentalValue(false), nullptr); | 3644 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3824 UpdateProviderPolicy(policies); | 3645 UpdateProviderPolicy(policies); |
3825 | 3646 |
3826 // Policy should not allow overriding anymore. | 3647 // Policy should not allow overriding anymore. |
3827 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3648 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
3828 | 3649 |
3829 // Policy disallows overriding - navigate to an SSL error page and expect no | 3650 // Policy disallows overriding - navigate to an SSL error page and expect no |
3830 // proceed link. | 3651 // proceed link. |
3831 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3652 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
3832 const content::InterstitialPage* const interstitial = | 3653 const content::InterstitialPage* const interstitial = |
3833 content::InterstitialPage::GetInterstitialPage( | 3654 content::InterstitialPage::GetInterstitialPage( |
(...skipping 26 matching lines...) Expand all Loading... |
3860 | 3681 |
3861 // Test that TaskManager::IsEndProcessEnabled is controlled by | 3682 // Test that TaskManager::IsEndProcessEnabled is controlled by |
3862 // TaskManagerEndProcessEnabled policy | 3683 // TaskManagerEndProcessEnabled policy |
3863 IN_PROC_BROWSER_TEST_F(PolicyTest, TaskManagerEndProcessEnabled) { | 3684 IN_PROC_BROWSER_TEST_F(PolicyTest, TaskManagerEndProcessEnabled) { |
3864 // By default it's allowed to end tasks. | 3685 // By default it's allowed to end tasks. |
3865 EXPECT_TRUE(TaskManager::IsEndProcessEnabled()); | 3686 EXPECT_TRUE(TaskManager::IsEndProcessEnabled()); |
3866 | 3687 |
3867 // Disabling ending tasks in task manager by policy | 3688 // Disabling ending tasks in task manager by policy |
3868 PolicyMap policies1; | 3689 PolicyMap policies1; |
3869 policies1.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, | 3690 policies1.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, |
3870 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 3691 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
3871 new base::FundamentalValue(false), nullptr); | 3692 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3872 UpdateProviderPolicy(policies1); | 3693 UpdateProviderPolicy(policies1); |
3873 | 3694 |
3874 // Policy should not allow ending tasks anymore. | 3695 // Policy should not allow ending tasks anymore. |
3875 EXPECT_FALSE(TaskManager::IsEndProcessEnabled()); | 3696 EXPECT_FALSE(TaskManager::IsEndProcessEnabled()); |
3876 | 3697 |
3877 // Enabling ending tasks in task manager by policy | 3698 // Enabling ending tasks in task manager by policy |
3878 PolicyMap policies2; | 3699 PolicyMap policies2; |
3879 policies2.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, | 3700 policies2.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, |
3880 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 3701 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
3881 new base::FundamentalValue(true), nullptr); | 3702 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
3882 UpdateProviderPolicy(policies2); | 3703 UpdateProviderPolicy(policies2); |
3883 | 3704 |
3884 // Policy should allow ending tasks again. | 3705 // Policy should allow ending tasks again. |
3885 EXPECT_TRUE(TaskManager::IsEndProcessEnabled()); | 3706 EXPECT_TRUE(TaskManager::IsEndProcessEnabled()); |
3886 } | 3707 } |
3887 | 3708 |
3888 #if !defined(OS_CHROMEOS) | 3709 #if !defined(OS_CHROMEOS) |
3889 // Similar to PolicyTest but sets the proper policy before the browser is | 3710 // Similar to PolicyTest but sets the proper policy before the browser is |
3890 // started. | 3711 // started. |
3891 class PolicyVariationsServiceTest : public PolicyTest { | 3712 class PolicyVariationsServiceTest : public PolicyTest { |
3892 public: | 3713 public: |
3893 void SetUpInProcessBrowserTestFixture() override { | 3714 void SetUpInProcessBrowserTestFixture() override { |
3894 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3715 PolicyTest::SetUpInProcessBrowserTestFixture(); |
3895 PolicyMap policies; | 3716 PolicyMap policies; |
3896 policies.Set(key::kVariationsRestrictParameter, | 3717 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY, |
3897 POLICY_LEVEL_MANDATORY, | 3718 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3898 POLICY_SCOPE_USER, | 3719 base::WrapUnique(new base::StringValue("restricted")), |
3899 POLICY_SOURCE_CLOUD, | 3720 nullptr); |
3900 new base::StringValue("restricted"), | |
3901 NULL); | |
3902 provider_.UpdateChromePolicy(policies); | 3721 provider_.UpdateChromePolicy(policies); |
3903 } | 3722 } |
3904 }; | 3723 }; |
3905 | 3724 |
3906 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { | 3725 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { |
3907 const std::string default_variations_url = | 3726 const std::string default_variations_url = |
3908 variations::VariationsService::GetDefaultVariationsServerURLForTesting(); | 3727 variations::VariationsService::GetDefaultVariationsServerURLForTesting(); |
3909 | 3728 |
3910 // g_browser_process->variations_service() is null by default in Chromium | 3729 // g_browser_process->variations_service() is null by default in Chromium |
3911 // builds, so construct a VariationsService locally instead. | 3730 // builds, so construct a VariationsService locally instead. |
3912 std::unique_ptr<variations::VariationsService> service = | 3731 std::unique_ptr<variations::VariationsService> service = |
3913 variations::VariationsService::CreateForTesting( | 3732 variations::VariationsService::CreateForTesting( |
3914 base::WrapUnique(new ChromeVariationsServiceClient()), | 3733 base::WrapUnique(new ChromeVariationsServiceClient()), |
3915 g_browser_process->local_state()); | 3734 g_browser_process->local_state()); |
3916 | 3735 |
3917 const GURL url = service->GetVariationsServerURL( | 3736 const GURL url = service->GetVariationsServerURL( |
3918 g_browser_process->local_state(), std::string()); | 3737 g_browser_process->local_state(), std::string()); |
3919 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, | 3738 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, |
3920 base::CompareCase::SENSITIVE)); | 3739 base::CompareCase::SENSITIVE)); |
3921 std::string value; | 3740 std::string value; |
3922 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 3741 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
3923 EXPECT_EQ("restricted", value); | 3742 EXPECT_EQ("restricted", value); |
3924 } | 3743 } |
3925 | 3744 |
3926 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { | 3745 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { |
3927 base::ListValue blacklist; | 3746 base::ListValue blacklist; |
3928 blacklist.Append(new base::StringValue("host.name")); | 3747 blacklist.Append(new base::StringValue("host.name")); |
3929 PolicyMap policies; | 3748 PolicyMap policies; |
3930 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3749 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
3931 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 3750 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3932 nullptr); | 3751 blacklist.CreateDeepCopy(), nullptr); |
3933 UpdateProviderPolicy(policies); | 3752 UpdateProviderPolicy(policies); |
3934 | 3753 |
3935 PrefService* prefs = browser()->profile()->GetPrefs(); | 3754 PrefService* prefs = browser()->profile()->GetPrefs(); |
3936 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3755 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3937 prefs, "host.name")); | 3756 prefs, "host.name")); |
3938 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3757 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3939 prefs, "other.host.name")); | 3758 prefs, "other.host.name")); |
3940 } | 3759 } |
3941 | 3760 |
3942 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { | 3761 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { |
3943 base::ListValue blacklist; | 3762 base::ListValue blacklist; |
3944 blacklist.Append(new base::StringValue("*")); | 3763 blacklist.Append(new base::StringValue("*")); |
3945 PolicyMap policies; | 3764 PolicyMap policies; |
3946 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3765 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
3947 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 3766 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3948 nullptr); | 3767 blacklist.CreateDeepCopy(), nullptr); |
3949 UpdateProviderPolicy(policies); | 3768 UpdateProviderPolicy(policies); |
3950 | 3769 |
3951 PrefService* prefs = browser()->profile()->GetPrefs(); | 3770 PrefService* prefs = browser()->profile()->GetPrefs(); |
3952 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3771 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3953 prefs, "host.name")); | 3772 prefs, "host.name")); |
3954 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3773 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3955 prefs, "other.host.name")); | 3774 prefs, "other.host.name")); |
3956 } | 3775 } |
3957 | 3776 |
3958 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { | 3777 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { |
3959 base::ListValue blacklist; | 3778 base::ListValue blacklist; |
3960 blacklist.Append(new base::StringValue("*")); | 3779 blacklist.Append(new base::StringValue("*")); |
3961 base::ListValue whitelist; | 3780 base::ListValue whitelist; |
3962 whitelist.Append(new base::StringValue("host.name")); | 3781 whitelist.Append(new base::StringValue("host.name")); |
3963 PolicyMap policies; | 3782 PolicyMap policies; |
3964 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3783 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
3965 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(), | 3784 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3966 nullptr); | 3785 blacklist.CreateDeepCopy(), nullptr); |
3967 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, | 3786 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, |
3968 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(), | 3787 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3969 nullptr); | 3788 whitelist.CreateDeepCopy(), nullptr); |
3970 UpdateProviderPolicy(policies); | 3789 UpdateProviderPolicy(policies); |
3971 | 3790 |
3972 PrefService* prefs = browser()->profile()->GetPrefs(); | 3791 PrefService* prefs = browser()->profile()->GetPrefs(); |
3973 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3792 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3974 prefs, "host.name")); | 3793 prefs, "host.name")); |
3975 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( | 3794 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( |
3976 prefs, "other.host.name")); | 3795 prefs, "other.host.name")); |
3977 } | 3796 } |
3978 | 3797 |
3979 #endif // !defined(CHROME_OS) | 3798 #endif // !defined(CHROME_OS) |
3980 | 3799 |
3981 | 3800 |
3982 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 3801 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
3983 // Sets the hardware acceleration mode policy before the browser is started. | 3802 // Sets the hardware acceleration mode policy before the browser is started. |
3984 class HardwareAccelerationModePolicyTest : public PolicyTest { | 3803 class HardwareAccelerationModePolicyTest : public PolicyTest { |
3985 public: | 3804 public: |
3986 HardwareAccelerationModePolicyTest() {} | 3805 HardwareAccelerationModePolicyTest() {} |
3987 | 3806 |
3988 void SetUpInProcessBrowserTestFixture() override { | 3807 void SetUpInProcessBrowserTestFixture() override { |
3989 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3808 PolicyTest::SetUpInProcessBrowserTestFixture(); |
3990 PolicyMap policies; | 3809 PolicyMap policies; |
3991 policies.Set(key::kHardwareAccelerationModeEnabled, | 3810 policies.Set(key::kHardwareAccelerationModeEnabled, POLICY_LEVEL_MANDATORY, |
3992 POLICY_LEVEL_MANDATORY, | 3811 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
3993 POLICY_SCOPE_USER, | 3812 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
3994 POLICY_SOURCE_CLOUD, | |
3995 new base::FundamentalValue(false), | |
3996 NULL); | |
3997 provider_.UpdateChromePolicy(policies); | 3813 provider_.UpdateChromePolicy(policies); |
3998 } | 3814 } |
3999 }; | 3815 }; |
4000 | 3816 |
4001 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, | 3817 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, |
4002 HardwareAccelerationDisabled) { | 3818 HardwareAccelerationDisabled) { |
4003 // Verifies that hardware acceleration can be disabled with policy. | 3819 // Verifies that hardware acceleration can be disabled with policy. |
4004 EXPECT_FALSE( | 3820 EXPECT_FALSE( |
4005 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); | 3821 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); |
4006 } | 3822 } |
4007 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 3823 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
4008 | 3824 |
4009 #if defined(OS_CHROMEOS) | 3825 #if defined(OS_CHROMEOS) |
4010 // Policy is only available in ChromeOS | 3826 // Policy is only available in ChromeOS |
4011 IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) { | 3827 IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) { |
4012 // Verify that Unified Desktop can be enabled by policy | 3828 // Verify that Unified Desktop can be enabled by policy |
4013 ash::DisplayManager *display_manager = | 3829 ash::DisplayManager *display_manager = |
4014 ash::Shell::GetInstance()->display_manager(); | 3830 ash::Shell::GetInstance()->display_manager(); |
4015 | 3831 |
4016 // The policy description promises that Unified Desktop is not available | 3832 // The policy description promises that Unified Desktop is not available |
4017 // unless the policy is set (or a command line or an extension is used). If | 3833 // unless the policy is set (or a command line or an extension is used). If |
4018 // this default behaviour changes, please change the description at | 3834 // this default behaviour changes, please change the description at |
4019 // components/policy/resources/policy_templates.json. | 3835 // components/policy/resources/policy_templates.json. |
4020 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3836 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
4021 // Now set the policy and check that unified desktop is turned on. | 3837 // Now set the policy and check that unified desktop is turned on. |
4022 PolicyMap policies; | 3838 PolicyMap policies; |
4023 policies.Set(key::kUnifiedDesktopEnabledByDefault, | 3839 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, |
4024 POLICY_LEVEL_MANDATORY, | 3840 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
4025 POLICY_SCOPE_USER, | 3841 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
4026 POLICY_SOURCE_CLOUD, | |
4027 new base::FundamentalValue(true), | |
4028 NULL); | |
4029 UpdateProviderPolicy(policies); | 3842 UpdateProviderPolicy(policies); |
4030 EXPECT_TRUE(display_manager->unified_desktop_enabled()); | 3843 EXPECT_TRUE(display_manager->unified_desktop_enabled()); |
4031 policies.Set(key::kUnifiedDesktopEnabledByDefault, | 3844 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, |
4032 POLICY_LEVEL_MANDATORY, | 3845 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
4033 POLICY_SCOPE_USER, | 3846 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
4034 POLICY_SOURCE_CLOUD, | |
4035 new base::FundamentalValue(false), | |
4036 NULL); | |
4037 UpdateProviderPolicy(policies); | 3847 UpdateProviderPolicy(policies); |
4038 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3848 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
4039 } | 3849 } |
4040 | 3850 |
4041 class ArcPolicyTest : public PolicyTest { | 3851 class ArcPolicyTest : public PolicyTest { |
4042 public: | 3852 public: |
4043 ArcPolicyTest() {} | 3853 ArcPolicyTest() {} |
4044 ~ArcPolicyTest() override {} | 3854 ~ArcPolicyTest() override {} |
4045 | 3855 |
4046 protected: | 3856 protected: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4087 const PrefService* const pref = browser()->profile()->GetPrefs(); | 3897 const PrefService* const pref = browser()->profile()->GetPrefs(); |
4088 const arc::ArcBridgeService* const arc_bridge_service | 3898 const arc::ArcBridgeService* const arc_bridge_service |
4089 = arc::ArcBridgeService::Get(); | 3899 = arc::ArcBridgeService::Get(); |
4090 | 3900 |
4091 // ARC is switched off by default. | 3901 // ARC is switched off by default. |
4092 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); | 3902 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); |
4093 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 3903 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
4094 | 3904 |
4095 // Enable ARC. | 3905 // Enable ARC. |
4096 PolicyMap policies; | 3906 PolicyMap policies; |
4097 policies.Set(key::kArcEnabled, | 3907 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
4098 POLICY_LEVEL_MANDATORY, | |
4099 POLICY_SCOPE_USER, | |
4100 POLICY_SOURCE_CLOUD, | 3908 POLICY_SOURCE_CLOUD, |
4101 new base::FundamentalValue(true), | 3909 base::WrapUnique(new base::FundamentalValue(true)), nullptr); |
4102 nullptr); | |
4103 UpdateProviderPolicy(policies); | 3910 UpdateProviderPolicy(policies); |
4104 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); | 3911 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); |
4105 EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state()); | 3912 EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state()); |
4106 | 3913 |
4107 // Disable ARC. | 3914 // Disable ARC. |
4108 policies.Set(key::kArcEnabled, | 3915 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
4109 POLICY_LEVEL_MANDATORY, | |
4110 POLICY_SCOPE_USER, | |
4111 POLICY_SOURCE_CLOUD, | 3916 POLICY_SOURCE_CLOUD, |
4112 new base::FundamentalValue(false), | 3917 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
4113 nullptr); | |
4114 UpdateProviderPolicy(policies); | 3918 UpdateProviderPolicy(policies); |
4115 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | 3919 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
4116 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); | 3920 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); |
4117 | 3921 |
4118 TearDownTest(); | 3922 TearDownTest(); |
4119 } | 3923 } |
4120 | 3924 |
4121 namespace { | 3925 namespace { |
4122 const char kTestUser1[] = "test1@domain.com"; | 3926 const char kTestUser1[] = "test1@domain.com"; |
4123 } // anonymous namespace | 3927 } // anonymous namespace |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4158 void CheckSystemTimezoneAutomaticDetectionPolicyUnset() { | 3962 void CheckSystemTimezoneAutomaticDetectionPolicyUnset() { |
4159 PrefService* local_state = g_browser_process->local_state(); | 3963 PrefService* local_state = g_browser_process->local_state(); |
4160 EXPECT_FALSE(local_state->IsManagedPreference( | 3964 EXPECT_FALSE(local_state->IsManagedPreference( |
4161 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 3965 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
4162 EXPECT_EQ(0, local_state->GetInteger( | 3966 EXPECT_EQ(0, local_state->GetInteger( |
4163 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 3967 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
4164 } | 3968 } |
4165 | 3969 |
4166 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { | 3970 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { |
4167 PolicyMap policies; | 3971 PolicyMap policies; |
4168 policies.Set(key::kSystemTimezoneAutomaticDetection, | 3972 policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY, |
4169 POLICY_LEVEL_MANDATORY, | 3973 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
4170 POLICY_SCOPE_MACHINE, | 3974 base::WrapUnique(new base::FundamentalValue(policy_value)), |
4171 POLICY_SOURCE_CLOUD, | 3975 nullptr); |
4172 new base::FundamentalValue(policy_value), | |
4173 NULL); | |
4174 UpdateProviderPolicy(policies); | 3976 UpdateProviderPolicy(policies); |
4175 | 3977 |
4176 PrefService* local_state = g_browser_process->local_state(); | 3978 PrefService* local_state = g_browser_process->local_state(); |
4177 | 3979 |
4178 EXPECT_TRUE(local_state->IsManagedPreference( | 3980 EXPECT_TRUE(local_state->IsManagedPreference( |
4179 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 3981 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
4180 EXPECT_EQ(policy_value, | 3982 EXPECT_EQ(policy_value, |
4181 local_state->GetInteger( | 3983 local_state->GetInteger( |
4182 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 3984 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
4183 } | 3985 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 | 4059 |
4258 SetEmptyPolicy(); | 4060 SetEmptyPolicy(); |
4259 // Policy not set. | 4061 // Policy not set. |
4260 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4062 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
4261 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4063 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
4262 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4064 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
4263 } | 4065 } |
4264 #endif // defined(OS_CHROMEOS) | 4066 #endif // defined(OS_CHROMEOS) |
4265 | 4067 |
4266 } // namespace policy | 4068 } // namespace policy |
OLD | NEW |