| 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, | 651 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, |
| 652 make_scoped_refptr(BrowserThread::GetBlockingPool())), | 652 make_scoped_refptr(BrowserThread::GetBlockingPool())), |
| 653 base::MessageLoop::current()->QuitWhenIdleClosure()); | 653 base::MessageLoop::current()->QuitWhenIdleClosure()); |
| 654 content::RunMessageLoop(); | 654 content::RunMessageLoop(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 void SetScreenshotPolicy(bool enabled) { | 657 void SetScreenshotPolicy(bool enabled) { |
| 658 PolicyMap policies; | 658 PolicyMap policies; |
| 659 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, | 659 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, |
| 660 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 660 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 661 base::MakeUnique<base::FundamentalValue>(!enabled), nullptr); | 661 base::MakeUnique<base::Value>(!enabled), nullptr); |
| 662 UpdateProviderPolicy(policies); | 662 UpdateProviderPolicy(policies); |
| 663 } | 663 } |
| 664 | 664 |
| 665 #if defined(OS_CHROMEOS) | 665 #if defined(OS_CHROMEOS) |
| 666 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { | 666 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { |
| 667 public: | 667 public: |
| 668 void OnScreenshotCompleted( | 668 void OnScreenshotCompleted( |
| 669 ScreenshotGrabberObserver::Result screenshot_result, | 669 ScreenshotGrabberObserver::Result screenshot_result, |
| 670 const base::FilePath& screenshot_path) override { | 670 const base::FilePath& screenshot_path) override { |
| 671 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, | 671 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 const char* key, | 806 const char* key, |
| 807 std::unique_ptr<base::Value> value) { | 807 std::unique_ptr<base::Value> value) { |
| 808 if (value) { | 808 if (value) { |
| 809 policies->Set(key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 809 policies->Set(key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 810 POLICY_SOURCE_CLOUD, std::move(value), nullptr); | 810 POLICY_SOURCE_CLOUD, std::move(value), nullptr); |
| 811 } else { | 811 } else { |
| 812 policies->Erase(key); | 812 policies->Erase(key); |
| 813 } | 813 } |
| 814 } | 814 } |
| 815 | 815 |
| 816 void ApplySafeSearchPolicy( | 816 void ApplySafeSearchPolicy(std::unique_ptr<base::Value> legacy_safe_search, |
| 817 std::unique_ptr<base::FundamentalValue> legacy_safe_search, | 817 std::unique_ptr<base::Value> google_safe_search, |
| 818 std::unique_ptr<base::FundamentalValue> google_safe_search, | 818 std::unique_ptr<base::Value> legacy_youtube, |
| 819 std::unique_ptr<base::FundamentalValue> legacy_youtube, | 819 std::unique_ptr<base::Value> youtube_restrict) { |
| 820 std::unique_ptr<base::FundamentalValue> youtube_restrict) { | |
| 821 PolicyMap policies; | 820 PolicyMap policies; |
| 822 SetPolicy(&policies, key::kForceSafeSearch, std::move(legacy_safe_search)); | 821 SetPolicy(&policies, key::kForceSafeSearch, std::move(legacy_safe_search)); |
| 823 SetPolicy(&policies, key::kForceGoogleSafeSearch, | 822 SetPolicy(&policies, key::kForceGoogleSafeSearch, |
| 824 std::move(google_safe_search)); | 823 std::move(google_safe_search)); |
| 825 SetPolicy(&policies, key::kForceYouTubeSafetyMode, | 824 SetPolicy(&policies, key::kForceYouTubeSafetyMode, |
| 826 std::move(legacy_youtube)); | 825 std::move(legacy_youtube)); |
| 827 SetPolicy(&policies, key::kForceYouTubeRestrict, | 826 SetPolicy(&policies, key::kForceYouTubeRestrict, |
| 828 std::move(youtube_restrict)); | 827 std::move(youtube_restrict)); |
| 829 UpdateProviderPolicy(policies); | 828 UpdateProviderPolicy(policies); |
| 830 } | 829 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 | 901 |
| 903 // Test starts in about:blank. | 902 // Test starts in about:blank. |
| 904 PrefService* prefs = browser()->profile()->GetPrefs(); | 903 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 905 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 904 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 906 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 905 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 907 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 906 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 908 | 907 |
| 909 PolicyMap policies; | 908 PolicyMap policies; |
| 910 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 909 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 911 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 910 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 912 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 911 base::MakeUnique<base::Value>(true), nullptr); |
| 913 UpdateProviderPolicy(policies); | 912 UpdateProviderPolicy(policies); |
| 914 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 913 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 915 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 914 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 916 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 915 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 917 | 916 |
| 918 // The NTP has special handling of the bookmark bar. | 917 // The NTP has special handling of the bookmark bar. |
| 919 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 918 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 920 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 919 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 921 | 920 |
| 922 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 921 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 923 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 922 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 924 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 923 base::MakeUnique<base::Value>(false), nullptr); |
| 925 UpdateProviderPolicy(policies); | 924 UpdateProviderPolicy(policies); |
| 926 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 925 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 927 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 926 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 928 // The bookmark bar is hidden in the NTP when disabled by policy. | 927 // The bookmark bar is hidden in the NTP when disabled by policy. |
| 929 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 928 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 930 | 929 |
| 931 policies.Clear(); | 930 policies.Clear(); |
| 932 UpdateProviderPolicy(policies); | 931 UpdateProviderPolicy(policies); |
| 933 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 932 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 934 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 933 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 951 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); | 950 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); |
| 952 } | 951 } |
| 953 | 952 |
| 954 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { | 953 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { |
| 955 // Verify that the cookie persists across restarts. | 954 // Verify that the cookie persists across restarts. |
| 956 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); | 955 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); |
| 957 // Now set the policy and the cookie should be gone after another restart. | 956 // Now set the policy and the cookie should be gone after another restart. |
| 958 PolicyMap policies; | 957 PolicyMap policies; |
| 959 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, | 958 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, |
| 960 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 959 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 961 base::MakeUnique<base::FundamentalValue>(4), nullptr); | 960 base::MakeUnique<base::Value>(4), nullptr); |
| 962 UpdateProviderPolicy(policies); | 961 UpdateProviderPolicy(policies); |
| 963 } | 962 } |
| 964 | 963 |
| 965 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { | 964 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { |
| 966 // Verify that the cookie is gone. | 965 // Verify that the cookie is gone. |
| 967 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); | 966 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); |
| 968 } | 967 } |
| 969 | 968 |
| 970 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { | 969 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { |
| 971 MakeRequestFail make_request_fail("search.example"); | 970 MakeRequestFail make_request_fail("search.example"); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 999 default_search->search_terms_replacement_key() == | 998 default_search->search_terms_replacement_key() == |
| 1000 kSearchTermsReplacementKey && | 999 kSearchTermsReplacementKey && |
| 1001 default_search->image_url() == kImageURL && | 1000 default_search->image_url() == kImageURL && |
| 1002 default_search->image_url_post_params() == kImageURLPostParams && | 1001 default_search->image_url_post_params() == kImageURLPostParams && |
| 1003 default_search->new_tab_url() == kNewTabURL); | 1002 default_search->new_tab_url() == kNewTabURL); |
| 1004 | 1003 |
| 1005 // Override the default search provider using policies. | 1004 // Override the default search provider using policies. |
| 1006 PolicyMap policies; | 1005 PolicyMap policies; |
| 1007 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 1006 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
| 1008 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1007 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1009 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1008 base::MakeUnique<base::Value>(true), nullptr); |
| 1010 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, | 1009 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, |
| 1011 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1010 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1012 base::MakeUnique<base::StringValue>(kKeyword), nullptr); | 1011 base::MakeUnique<base::StringValue>(kKeyword), nullptr); |
| 1013 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, | 1012 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, |
| 1014 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1013 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1015 base::MakeUnique<base::StringValue>(kSearchURL), nullptr); | 1014 base::MakeUnique<base::StringValue>(kSearchURL), nullptr); |
| 1016 policies.Set(key::kDefaultSearchProviderInstantURL, POLICY_LEVEL_MANDATORY, | 1015 policies.Set(key::kDefaultSearchProviderInstantURL, POLICY_LEVEL_MANDATORY, |
| 1017 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1016 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1018 base::MakeUnique<base::StringValue>(kInstantURL), nullptr); | 1017 base::MakeUnique<base::StringValue>(kInstantURL), nullptr); |
| 1019 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); | 1018 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1058 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); |
| 1060 content::WebContents* web_contents = | 1059 content::WebContents* web_contents = |
| 1061 browser()->tab_strip_model()->GetActiveWebContents(); | 1060 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1062 GURL expected("http://search.example/search?q=stuff+to+search+for"); | 1061 GURL expected("http://search.example/search?q=stuff+to+search+for"); |
| 1063 EXPECT_EQ(expected, web_contents->GetURL()); | 1062 EXPECT_EQ(expected, web_contents->GetURL()); |
| 1064 | 1063 |
| 1065 // Verify that searching from the omnibox can be disabled. | 1064 // Verify that searching from the omnibox can be disabled. |
| 1066 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1065 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 1067 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 1066 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
| 1068 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1067 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1069 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 1068 base::MakeUnique<base::Value>(false), nullptr); |
| 1070 EXPECT_TRUE(service->GetDefaultSearchProvider()); | 1069 EXPECT_TRUE(service->GetDefaultSearchProvider()); |
| 1071 UpdateProviderPolicy(policies); | 1070 UpdateProviderPolicy(policies); |
| 1072 EXPECT_FALSE(service->GetDefaultSearchProvider()); | 1071 EXPECT_FALSE(service->GetDefaultSearchProvider()); |
| 1073 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); | 1072 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); |
| 1074 // This means that submitting won't trigger any action. | 1073 // This means that submitting won't trigger any action. |
| 1075 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1074 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); |
| 1076 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); | 1075 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); |
| 1077 } | 1076 } |
| 1078 | 1077 |
| 1079 IN_PROC_BROWSER_TEST_F(PolicyTest, SeparateProxyPoliciesMerging) { | 1078 IN_PROC_BROWSER_TEST_F(PolicyTest, SeparateProxyPoliciesMerging) { |
| 1080 // Add an individual proxy policy value. | 1079 // Add an individual proxy policy value. |
| 1081 PolicyMap policies; | 1080 PolicyMap policies; |
| 1082 policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1081 policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1083 POLICY_SOURCE_CLOUD, base::MakeUnique<base::FundamentalValue>(3), | 1082 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>(3), nullptr); |
| 1084 nullptr); | |
| 1085 UpdateProviderPolicy(policies); | 1083 UpdateProviderPolicy(policies); |
| 1086 | 1084 |
| 1087 // It should be removed and replaced with a dictionary. | 1085 // It should be removed and replaced with a dictionary. |
| 1088 PolicyMap expected; | 1086 PolicyMap expected; |
| 1089 std::unique_ptr<base::DictionaryValue> expected_value( | 1087 std::unique_ptr<base::DictionaryValue> expected_value( |
| 1090 new base::DictionaryValue); | 1088 new base::DictionaryValue); |
| 1091 expected_value->SetInteger(key::kProxyServerMode, 3); | 1089 expected_value->SetInteger(key::kProxyServerMode, 3); |
| 1092 expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1090 expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1093 POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); | 1091 POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); |
| 1094 | 1092 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1121 int val = i; | 1119 int val = i; |
| 1122 int legacy_safe_search = val % 3; val /= 3; | 1120 int legacy_safe_search = val % 3; val /= 3; |
| 1123 int google_safe_search = val % 3; val /= 3; | 1121 int google_safe_search = val % 3; val /= 3; |
| 1124 int legacy_youtube = val % 3; val /= 3; | 1122 int legacy_youtube = val % 3; val /= 3; |
| 1125 int youtube_restrict = val % num_restrict_modes; | 1123 int youtube_restrict = val % num_restrict_modes; |
| 1126 | 1124 |
| 1127 // Override the default SafeSearch setting using policies. | 1125 // Override the default SafeSearch setting using policies. |
| 1128 ApplySafeSearchPolicy( | 1126 ApplySafeSearchPolicy( |
| 1129 legacy_safe_search == 0 | 1127 legacy_safe_search == 0 |
| 1130 ? nullptr | 1128 ? nullptr |
| 1131 : base::MakeUnique<base::FundamentalValue>(legacy_safe_search == 1), | 1129 : base::MakeUnique<base::Value>(legacy_safe_search == 1), |
| 1132 google_safe_search == 0 | 1130 google_safe_search == 0 |
| 1133 ? nullptr | 1131 ? nullptr |
| 1134 : base::MakeUnique<base::FundamentalValue>(google_safe_search == 1), | 1132 : base::MakeUnique<base::Value>(google_safe_search == 1), |
| 1135 legacy_youtube == 0 | 1133 legacy_youtube == 0 |
| 1136 ? nullptr | 1134 ? nullptr |
| 1137 : base::MakeUnique<base::FundamentalValue>(legacy_youtube == 1), | 1135 : base::MakeUnique<base::Value>(legacy_youtube == 1), |
| 1138 youtube_restrict == 0 | 1136 youtube_restrict == 0 |
| 1139 ? nullptr // subtracting 1 gives 0,1,2, see above | 1137 ? nullptr // subtracting 1 gives 0,1,2, see above |
| 1140 : base::MakeUnique<base::FundamentalValue>(youtube_restrict - 1)); | 1138 : base::MakeUnique<base::Value>(youtube_restrict - 1)); |
| 1141 | 1139 |
| 1142 // The legacy ForceSafeSearch policy should only have an effect if none of | 1140 // The legacy ForceSafeSearch policy should only have an effect if none of |
| 1143 // the other 3 policies are defined. | 1141 // the other 3 policies are defined. |
| 1144 bool legacy_safe_search_in_effect = | 1142 bool legacy_safe_search_in_effect = |
| 1145 google_safe_search == 0 && legacy_youtube == 0 && | 1143 google_safe_search == 0 && legacy_youtube == 0 && |
| 1146 youtube_restrict == 0 && legacy_safe_search != 0; | 1144 youtube_restrict == 0 && legacy_safe_search != 0; |
| 1147 bool legacy_safe_search_enabled = | 1145 bool legacy_safe_search_enabled = |
| 1148 legacy_safe_search_in_effect && legacy_safe_search == 1; | 1146 legacy_safe_search_in_effect && legacy_safe_search == 1; |
| 1149 | 1147 |
| 1150 // Likewise, ForceYouTubeSafetyMode should only have an effect if | 1148 // Likewise, ForceYouTubeSafetyMode should only have an effect if |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 | 1191 |
| 1194 // Verifies that requests to Google Search engine with the SafeSearch | 1192 // Verifies that requests to Google Search engine with the SafeSearch |
| 1195 // enabled set the safe=active&ssui=on parameters at the end of the query. | 1193 // enabled set the safe=active&ssui=on parameters at the end of the query. |
| 1196 // First check that nothing happens. | 1194 // First check that nothing happens. |
| 1197 CheckSafeSearch(false); | 1195 CheckSafeSearch(false); |
| 1198 | 1196 |
| 1199 // Go over all combinations of (undefined, true, false) for the | 1197 // Go over all combinations of (undefined, true, false) for the |
| 1200 // ForceGoogleSafeSearch policy. | 1198 // ForceGoogleSafeSearch policy. |
| 1201 for (int safe_search = 0; safe_search < 3; safe_search++) { | 1199 for (int safe_search = 0; safe_search < 3; safe_search++) { |
| 1202 // Override the Google safe search policy. | 1200 // Override the Google safe search policy. |
| 1203 ApplySafeSearchPolicy( | 1201 ApplySafeSearchPolicy(nullptr, // ForceSafeSearch |
| 1204 nullptr, // ForceSafeSearch | 1202 safe_search == 0 // ForceGoogleSafeSearch |
| 1205 safe_search == 0 // ForceGoogleSafeSearch | 1203 ? nullptr |
| 1206 ? nullptr | 1204 : base::MakeUnique<base::Value>(safe_search == 1), |
| 1207 : base::MakeUnique<base::FundamentalValue>(safe_search == 1), | 1205 nullptr, // ForceYouTubeSafetyMode |
| 1208 nullptr, // ForceYouTubeSafetyMode | 1206 nullptr // ForceYouTubeRestrict |
| 1209 nullptr // ForceYouTubeRestrict | 1207 ); |
| 1210 ); | |
| 1211 // Verify that the safe search pref behaves the way we expect. | 1208 // Verify that the safe search pref behaves the way we expect. |
| 1212 PrefService* prefs = browser()->profile()->GetPrefs(); | 1209 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 1213 EXPECT_EQ(safe_search != 0, | 1210 EXPECT_EQ(safe_search != 0, |
| 1214 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); | 1211 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); |
| 1215 EXPECT_EQ(safe_search == 1, | 1212 EXPECT_EQ(safe_search == 1, |
| 1216 prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); | 1213 prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); |
| 1217 | 1214 |
| 1218 // Verify that safe search actually works. | 1215 // Verify that safe search actually works. |
| 1219 CheckSafeSearch(safe_search == 1); | 1216 CheckSafeSearch(safe_search == 1); |
| 1220 } | 1217 } |
| 1221 } | 1218 } |
| 1222 | 1219 |
| 1223 IN_PROC_BROWSER_TEST_F(PolicyTest, Disable3DAPIs) { | 1220 IN_PROC_BROWSER_TEST_F(PolicyTest, Disable3DAPIs) { |
| 1224 // This test assumes Gpu access. | 1221 // This test assumes Gpu access. |
| 1225 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) | 1222 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) |
| 1226 return; | 1223 return; |
| 1227 | 1224 |
| 1228 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1225 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 1229 // WebGL is enabled by default. | 1226 // WebGL is enabled by default. |
| 1230 content::WebContents* contents = | 1227 content::WebContents* contents = |
| 1231 browser()->tab_strip_model()->GetActiveWebContents(); | 1228 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1232 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1229 EXPECT_TRUE(IsWebGLEnabled(contents)); |
| 1233 // Disable with a policy. | 1230 // Disable with a policy. |
| 1234 PolicyMap policies; | 1231 PolicyMap policies; |
| 1235 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1232 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1236 POLICY_SOURCE_CLOUD, | 1233 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>(true), |
| 1237 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1234 nullptr); |
| 1238 UpdateProviderPolicy(policies); | 1235 UpdateProviderPolicy(policies); |
| 1239 // Crash and reload the tab to get a new renderer. | 1236 // Crash and reload the tab to get a new renderer. |
| 1240 content::CrashTab(contents); | 1237 content::CrashTab(contents); |
| 1241 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1238 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
| 1242 EXPECT_FALSE(IsWebGLEnabled(contents)); | 1239 EXPECT_FALSE(IsWebGLEnabled(contents)); |
| 1243 // Enable with a policy. | 1240 // Enable with a policy. |
| 1244 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1241 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1245 POLICY_SOURCE_CLOUD, | 1242 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>(false), |
| 1246 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 1243 nullptr); |
| 1247 UpdateProviderPolicy(policies); | 1244 UpdateProviderPolicy(policies); |
| 1248 content::CrashTab(contents); | 1245 content::CrashTab(contents); |
| 1249 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1246 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
| 1250 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1247 EXPECT_TRUE(IsWebGLEnabled(contents)); |
| 1251 } | 1248 } |
| 1252 | 1249 |
| 1253 namespace { | 1250 namespace { |
| 1254 | 1251 |
| 1255 // The following helpers retrieve whether https:// URL stripping is | 1252 // The following helpers retrieve whether https:// URL stripping is |
| 1256 // enabled for PAC scripts. It needs to run on the IO thread. | 1253 // enabled for PAC scripts. It needs to run on the IO thread. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1277 // be disabled via a policy. Also verifies that stripping is enabled by | 1274 // be disabled via a policy. Also verifies that stripping is enabled by |
| 1278 // default. | 1275 // default. |
| 1279 IN_PROC_BROWSER_TEST_F(PolicyTest, DisablePacHttpsUrlStripping) { | 1276 IN_PROC_BROWSER_TEST_F(PolicyTest, DisablePacHttpsUrlStripping) { |
| 1280 // Stripping is enabled by default. | 1277 // Stripping is enabled by default. |
| 1281 EXPECT_TRUE(GetPacHttpsUrlStrippingEnabled()); | 1278 EXPECT_TRUE(GetPacHttpsUrlStrippingEnabled()); |
| 1282 | 1279 |
| 1283 // Disable it via a policy. | 1280 // Disable it via a policy. |
| 1284 PolicyMap policies; | 1281 PolicyMap policies; |
| 1285 policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY, | 1282 policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY, |
| 1286 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1283 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1287 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 1284 base::WrapUnique(new base::Value(false)), nullptr); |
| 1288 UpdateProviderPolicy(policies); | 1285 UpdateProviderPolicy(policies); |
| 1289 content::RunAllPendingInMessageLoop(); | 1286 content::RunAllPendingInMessageLoop(); |
| 1290 | 1287 |
| 1291 // It should now reflect as disabled. | 1288 // It should now reflect as disabled. |
| 1292 EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled()); | 1289 EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled()); |
| 1293 } | 1290 } |
| 1294 | 1291 |
| 1295 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { | 1292 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { |
| 1296 // Verifies that access to the developer tools can be disabled. | 1293 // Verifies that access to the developer tools can be disabled. |
| 1297 | 1294 |
| 1298 // Open devtools. | 1295 // Open devtools. |
| 1299 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1296 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
| 1300 content::WebContents* contents = | 1297 content::WebContents* contents = |
| 1301 browser()->tab_strip_model()->GetActiveWebContents(); | 1298 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1302 DevToolsWindow* devtools_window = | 1299 DevToolsWindow* devtools_window = |
| 1303 DevToolsWindow::GetInstanceForInspectedWebContents(contents); | 1300 DevToolsWindow::GetInstanceForInspectedWebContents(contents); |
| 1304 EXPECT_TRUE(devtools_window); | 1301 EXPECT_TRUE(devtools_window); |
| 1305 | 1302 |
| 1306 // Disable devtools via policy. | 1303 // Disable devtools via policy. |
| 1307 PolicyMap policies; | 1304 PolicyMap policies; |
| 1308 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, | 1305 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, |
| 1309 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1306 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1310 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1307 base::MakeUnique<base::Value>(true), nullptr); |
| 1311 content::WindowedNotificationObserver close_observer( | 1308 content::WindowedNotificationObserver close_observer( |
| 1312 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1309 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1313 content::Source<content::WebContents>( | 1310 content::Source<content::WebContents>( |
| 1314 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); | 1311 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); |
| 1315 UpdateProviderPolicy(policies); | 1312 UpdateProviderPolicy(policies); |
| 1316 // wait for devtools close | 1313 // wait for devtools close |
| 1317 close_observer.Wait(); | 1314 close_observer.Wait(); |
| 1318 // The existing devtools window should have closed. | 1315 // The existing devtools window should have closed. |
| 1319 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); | 1316 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); |
| 1320 // And it's not possible to open it again. | 1317 // And it's not possible to open it again. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 | 1384 |
| 1388 WaitForExtensionsDevModeControlsVisibility(contents, | 1385 WaitForExtensionsDevModeControlsVisibility(contents, |
| 1389 dev_controls_accessor_js, | 1386 dev_controls_accessor_js, |
| 1390 dev_controls_visibility_check_js, | 1387 dev_controls_visibility_check_js, |
| 1391 true); | 1388 true); |
| 1392 | 1389 |
| 1393 // Disable devtools via policy. | 1390 // Disable devtools via policy. |
| 1394 PolicyMap policies; | 1391 PolicyMap policies; |
| 1395 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, | 1392 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, |
| 1396 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1393 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1397 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1394 base::MakeUnique<base::Value>(true), nullptr); |
| 1398 UpdateProviderPolicy(policies); | 1395 UpdateProviderPolicy(policies); |
| 1399 | 1396 |
| 1400 // Expect devcontrols to be hidden now... | 1397 // Expect devcontrols to be hidden now... |
| 1401 WaitForExtensionsDevModeControlsVisibility(contents, | 1398 WaitForExtensionsDevModeControlsVisibility(contents, |
| 1402 dev_controls_accessor_js, | 1399 dev_controls_accessor_js, |
| 1403 dev_controls_visibility_check_js, | 1400 dev_controls_visibility_check_js, |
| 1404 false); | 1401 false); |
| 1405 | 1402 |
| 1406 // ... and checkbox is not disabled | 1403 // ... and checkbox is not disabled |
| 1407 bool is_toggle_dev_mode_checkbox_enabled = false; | 1404 bool is_toggle_dev_mode_checkbox_enabled = false; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1430 #endif | 1427 #endif |
| 1431 | 1428 |
| 1432 // The next NTP has no footer. | 1429 // The next NTP has no footer. |
| 1433 if (ContainsVisibleElement(contents, "footer")) | 1430 if (ContainsVisibleElement(contents, "footer")) |
| 1434 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1431 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
| 1435 | 1432 |
| 1436 // Turn off the web store icons. | 1433 // Turn off the web store icons. |
| 1437 PolicyMap policies; | 1434 PolicyMap policies; |
| 1438 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY, | 1435 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY, |
| 1439 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1436 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1440 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 1437 base::WrapUnique(new base::Value(true)), nullptr); |
| 1441 UpdateProviderPolicy(policies); | 1438 UpdateProviderPolicy(policies); |
| 1442 | 1439 |
| 1443 // The web store icons should now be hidden. | 1440 // The web store icons should now be hidden. |
| 1444 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1441 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 1445 EXPECT_FALSE(ContainsVisibleElement(contents, | 1442 EXPECT_FALSE(ContainsVisibleElement(contents, |
| 1446 "ahfgeienlihckogmohjhadlkjgocpleb")); | 1443 "ahfgeienlihckogmohjhadlkjgocpleb")); |
| 1447 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1444 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
| 1448 } | 1445 } |
| 1449 | 1446 |
| 1450 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { | 1447 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2081 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2085 base::MakeUnique<base::StringValue>(chrome::kChromeUICreditsURL), | 2082 base::MakeUnique<base::StringValue>(chrome::kChromeUICreditsURL), |
| 2086 nullptr); | 2083 nullptr); |
| 2087 UpdateProviderPolicy(policies); | 2084 UpdateProviderPolicy(policies); |
| 2088 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2085 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 2089 content::WaitForLoadStop(contents); | 2086 content::WaitForLoadStop(contents); |
| 2090 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); | 2087 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); |
| 2091 | 2088 |
| 2092 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, | 2089 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, |
| 2093 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2090 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2094 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2091 base::MakeUnique<base::Value>(true), nullptr); |
| 2095 UpdateProviderPolicy(policies); | 2092 UpdateProviderPolicy(policies); |
| 2096 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2093 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 2097 content::WaitForLoadStop(contents); | 2094 content::WaitForLoadStop(contents); |
| 2098 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); | 2095 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); |
| 2099 } | 2096 } |
| 2100 | 2097 |
| 2101 #if defined(OS_MACOSX) && defined(ADDRESS_SANITIZER) | 2098 #if defined(OS_MACOSX) && defined(ADDRESS_SANITIZER) |
| 2102 // Flaky on ASAN on Mac. See https://crbug.com/674497. | 2099 // Flaky on ASAN on Mac. See https://crbug.com/674497. |
| 2103 #define MAYBE_IncognitoEnabled DISABLED_IncognitoEnabled | 2100 #define MAYBE_IncognitoEnabled DISABLED_IncognitoEnabled |
| 2104 #else | 2101 #else |
| 2105 #define MAYBE_IncognitoEnabled IncognitoEnabled | 2102 #define MAYBE_IncognitoEnabled IncognitoEnabled |
| 2106 #endif | 2103 #endif |
| 2107 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_IncognitoEnabled) { | 2104 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_IncognitoEnabled) { |
| 2108 // Verifies that incognito windows can't be opened when disabled by policy. | 2105 // Verifies that incognito windows can't be opened when disabled by policy. |
| 2109 | 2106 |
| 2110 const BrowserList* active_browser_list = BrowserList::GetInstance(); | 2107 const BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 2111 | 2108 |
| 2112 // Disable incognito via policy and verify that incognito windows can't be | 2109 // Disable incognito via policy and verify that incognito windows can't be |
| 2113 // opened. | 2110 // opened. |
| 2114 EXPECT_EQ(1u, active_browser_list->size()); | 2111 EXPECT_EQ(1u, active_browser_list->size()); |
| 2115 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); | 2112 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); |
| 2116 PolicyMap policies; | 2113 PolicyMap policies; |
| 2117 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 2114 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
| 2118 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2115 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2119 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2116 base::MakeUnique<base::Value>(false), nullptr); |
| 2120 UpdateProviderPolicy(policies); | 2117 UpdateProviderPolicy(policies); |
| 2121 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2118 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 2122 EXPECT_EQ(1u, active_browser_list->size()); | 2119 EXPECT_EQ(1u, active_browser_list->size()); |
| 2123 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); | 2120 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); |
| 2124 | 2121 |
| 2125 // Enable via policy and verify that incognito windows can be opened. | 2122 // Enable via policy and verify that incognito windows can be opened. |
| 2126 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 2123 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
| 2127 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2124 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2128 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2125 base::MakeUnique<base::Value>(true), nullptr); |
| 2129 UpdateProviderPolicy(policies); | 2126 UpdateProviderPolicy(policies); |
| 2130 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2127 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 2131 EXPECT_EQ(2u, active_browser_list->size()); | 2128 EXPECT_EQ(2u, active_browser_list->size()); |
| 2132 EXPECT_TRUE(BrowserList::IsIncognitoSessionActive()); | 2129 EXPECT_TRUE(BrowserList::IsIncognitoSessionActive()); |
| 2133 } | 2130 } |
| 2134 | 2131 |
| 2135 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 2132 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
| 2136 // Verifies that Javascript can be disabled. | 2133 // Verifies that Javascript can be disabled. |
| 2137 content::WebContents* contents = | 2134 content::WebContents* contents = |
| 2138 browser()->tab_strip_model()->GetActiveWebContents(); | 2135 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2139 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2136 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2140 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2137 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
| 2141 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2138 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
| 2142 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2139 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
| 2143 | 2140 |
| 2144 // Disable Javascript via policy. | 2141 // Disable Javascript via policy. |
| 2145 PolicyMap policies; | 2142 PolicyMap policies; |
| 2146 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, | 2143 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, |
| 2147 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2144 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2148 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2145 base::MakeUnique<base::Value>(false), nullptr); |
| 2149 UpdateProviderPolicy(policies); | 2146 UpdateProviderPolicy(policies); |
| 2150 // Reload the page. | 2147 // Reload the page. |
| 2151 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2148 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2152 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2149 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
| 2153 // Developer tools still work when javascript is disabled. | 2150 // Developer tools still work when javascript is disabled. |
| 2154 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2151 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
| 2155 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2152 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
| 2156 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2153 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
| 2157 // Javascript is always enabled for the internal pages. | 2154 // Javascript is always enabled for the internal pages. |
| 2158 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 2155 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 2159 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2156 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2160 | 2157 |
| 2161 // The javascript content setting policy overrides the javascript policy. | 2158 // The javascript content setting policy overrides the javascript policy. |
| 2162 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2159 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2163 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2160 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
| 2164 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, | 2161 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, |
| 2165 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2162 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2166 base::MakeUnique<base::FundamentalValue>(CONTENT_SETTING_ALLOW), | 2163 base::MakeUnique<base::Value>(CONTENT_SETTING_ALLOW), nullptr); |
| 2167 nullptr); | |
| 2168 UpdateProviderPolicy(policies); | 2164 UpdateProviderPolicy(policies); |
| 2169 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2165 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2170 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2166 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2171 } | 2167 } |
| 2172 | 2168 |
| 2173 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { | 2169 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { |
| 2174 PrefService* prefs = browser()->profile()->GetPrefs(); | 2170 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2175 | 2171 |
| 2176 // Enabled by default. | 2172 // Enabled by default. |
| 2177 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2173 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
| 2178 | 2174 |
| 2179 // Disable by old, deprecated policy. | 2175 // Disable by old, deprecated policy. |
| 2180 PolicyMap policies; | 2176 PolicyMap policies; |
| 2181 policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY, | 2177 policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY, |
| 2182 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2178 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2183 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2179 base::MakeUnique<base::Value>(false), nullptr); |
| 2184 UpdateProviderPolicy(policies); | 2180 UpdateProviderPolicy(policies); |
| 2185 | 2181 |
| 2186 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); | 2182 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); |
| 2187 | 2183 |
| 2188 // Enabled by new policy, this should override old one. | 2184 // Enabled by new policy, this should override old one. |
| 2189 policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY, | 2185 policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY, |
| 2190 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2186 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2191 base::MakeUnique<base::FundamentalValue>( | 2187 base::MakeUnique<base::Value>( |
| 2192 chrome_browser_net::NETWORK_PREDICTION_ALWAYS), | 2188 chrome_browser_net::NETWORK_PREDICTION_ALWAYS), |
| 2193 nullptr); | 2189 nullptr); |
| 2194 UpdateProviderPolicy(policies); | 2190 UpdateProviderPolicy(policies); |
| 2195 | 2191 |
| 2196 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2192 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
| 2197 } | 2193 } |
| 2198 | 2194 |
| 2199 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { | 2195 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { |
| 2200 // Verifies that browsing history is not saved. | 2196 // Verifies that browsing history is not saved. |
| 2201 PolicyMap policies; | 2197 PolicyMap policies; |
| 2202 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, | 2198 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
| 2203 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2199 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2204 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2200 base::MakeUnique<base::Value>(true), nullptr); |
| 2205 UpdateProviderPolicy(policies); | 2201 UpdateProviderPolicy(policies); |
| 2206 GURL url = ui_test_utils::GetTestUrl( | 2202 GURL url = ui_test_utils::GetTestUrl( |
| 2207 base::FilePath(base::FilePath::kCurrentDirectory), | 2203 base::FilePath(base::FilePath::kCurrentDirectory), |
| 2208 base::FilePath(FILE_PATH_LITERAL("empty.html"))); | 2204 base::FilePath(FILE_PATH_LITERAL("empty.html"))); |
| 2209 ui_test_utils::NavigateToURL(browser(), url); | 2205 ui_test_utils::NavigateToURL(browser(), url); |
| 2210 // Verify that the navigation wasn't saved in the history. | 2206 // Verify that the navigation wasn't saved in the history. |
| 2211 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); | 2207 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); |
| 2212 EXPECT_EQ(0u, enumerator1.urls().size()); | 2208 EXPECT_EQ(0u, enumerator1.urls().size()); |
| 2213 | 2209 |
| 2214 // Now flip the policy and try again. | 2210 // Now flip the policy and try again. |
| 2215 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, | 2211 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
| 2216 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2212 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2217 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2213 base::MakeUnique<base::Value>(false), nullptr); |
| 2218 UpdateProviderPolicy(policies); | 2214 UpdateProviderPolicy(policies); |
| 2219 ui_test_utils::NavigateToURL(browser(), url); | 2215 ui_test_utils::NavigateToURL(browser(), url); |
| 2220 // Verify that the navigation was saved in the history. | 2216 // Verify that the navigation was saved in the history. |
| 2221 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); | 2217 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); |
| 2222 ASSERT_EQ(1u, enumerator2.urls().size()); | 2218 ASSERT_EQ(1u, enumerator2.urls().size()); |
| 2223 EXPECT_EQ(url, enumerator2.urls()[0]); | 2219 EXPECT_EQ(url, enumerator2.urls()[0]); |
| 2224 } | 2220 } |
| 2225 | 2221 |
| 2226 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 | 2222 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 |
| 2227 #if !defined(USE_AURA) | 2223 #if !defined(USE_AURA) |
| 2228 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. | 2224 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. |
| 2229 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { | 2225 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { |
| 2230 // Verifies that translate can be forced enabled or disabled by policy. | 2226 // Verifies that translate can be forced enabled or disabled by policy. |
| 2231 | 2227 |
| 2232 // Get the InfoBarService, and verify that there are no infobars on startup. | 2228 // Get the InfoBarService, and verify that there are no infobars on startup. |
| 2233 content::WebContents* contents = | 2229 content::WebContents* contents = |
| 2234 browser()->tab_strip_model()->GetActiveWebContents(); | 2230 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2235 ASSERT_TRUE(contents); | 2231 ASSERT_TRUE(contents); |
| 2236 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); | 2232 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); |
| 2237 ASSERT_TRUE(infobar_service); | 2233 ASSERT_TRUE(infobar_service); |
| 2238 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2234 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 2239 | 2235 |
| 2240 // Force enable the translate feature. | 2236 // Force enable the translate feature. |
| 2241 PolicyMap policies; | 2237 PolicyMap policies; |
| 2242 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, | 2238 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, |
| 2243 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2239 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2244 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2240 base::WrapUnique(new base::Value(true)), nullptr); |
| 2245 UpdateProviderPolicy(policies); | 2241 UpdateProviderPolicy(policies); |
| 2246 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test | 2242 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test |
| 2247 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the | 2243 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the |
| 2248 // TranslateManager observes. This allows checking that an infobar is NOT | 2244 // TranslateManager observes. This allows checking that an infobar is NOT |
| 2249 // shown below, without polling for infobars for some indeterminate amount | 2245 // shown below, without polling for infobars for some indeterminate amount |
| 2250 // of time. | 2246 // of time. |
| 2251 GURL url = ui_test_utils::GetTestUrl( | 2247 GURL url = ui_test_utils::GetTestUrl( |
| 2252 base::FilePath(), | 2248 base::FilePath(), |
| 2253 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html"))); | 2249 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html"))); |
| 2254 content::WindowedNotificationObserver language_observer1( | 2250 content::WindowedNotificationObserver language_observer1( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2277 ASSERT_TRUE(translate_infobar_delegate); | 2273 ASSERT_TRUE(translate_infobar_delegate); |
| 2278 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 2274 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
| 2279 translate_infobar_delegate->translate_step()); | 2275 translate_infobar_delegate->translate_step()); |
| 2280 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); | 2276 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); |
| 2281 | 2277 |
| 2282 // Now force disable translate. | 2278 // Now force disable translate. |
| 2283 infobar_service->RemoveInfoBar(infobar); | 2279 infobar_service->RemoveInfoBar(infobar); |
| 2284 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2280 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 2285 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, | 2281 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, |
| 2286 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2282 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2287 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2283 base::WrapUnique(new base::Value(false)), nullptr); |
| 2288 UpdateProviderPolicy(policies); | 2284 UpdateProviderPolicy(policies); |
| 2289 // Navigating to the same URL now doesn't trigger an infobar. | 2285 // Navigating to the same URL now doesn't trigger an infobar. |
| 2290 content::WindowedNotificationObserver language_observer2( | 2286 content::WindowedNotificationObserver language_observer2( |
| 2291 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 2287 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 2292 content::NotificationService::AllSources()); | 2288 content::NotificationService::AllSources()); |
| 2293 ui_test_utils::NavigateToURL(browser(), url); | 2289 ui_test_utils::NavigateToURL(browser(), url); |
| 2294 language_observer2.Wait(); | 2290 language_observer2.Wait(); |
| 2295 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2291 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 2296 } | 2292 } |
| 2297 #endif // !defined(USE_AURA) | 2293 #endif // !defined(USE_AURA) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2462 | 2458 |
| 2463 CheckCanOpenURL(browser(), file_path1.c_str()); | 2459 CheckCanOpenURL(browser(), file_path1.c_str()); |
| 2464 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2460 CheckURLIsBlocked(browser(), file_path2.c_str()); |
| 2465 } | 2461 } |
| 2466 | 2462 |
| 2467 #if !defined(OS_MACOSX) | 2463 #if !defined(OS_MACOSX) |
| 2468 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { | 2464 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { |
| 2469 PolicyMap policies; | 2465 PolicyMap policies; |
| 2470 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, | 2466 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
| 2471 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2467 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2472 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2468 base::MakeUnique<base::Value>(false), nullptr); |
| 2473 UpdateProviderPolicy(policies); | 2469 UpdateProviderPolicy(policies); |
| 2474 | 2470 |
| 2475 BrowserWindow* browser_window = browser()->window(); | 2471 BrowserWindow* browser_window = browser()->window(); |
| 2476 ASSERT_TRUE(browser_window); | 2472 ASSERT_TRUE(browser_window); |
| 2477 | 2473 |
| 2478 EXPECT_FALSE(browser_window->IsFullscreen()); | 2474 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 2479 chrome::ToggleFullscreenMode(browser()); | 2475 chrome::ToggleFullscreenMode(browser()); |
| 2480 EXPECT_FALSE(browser_window->IsFullscreen()); | 2476 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 2481 } | 2477 } |
| 2482 | 2478 |
| 2483 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { | 2479 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { |
| 2484 PolicyMap policies; | 2480 PolicyMap policies; |
| 2485 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, | 2481 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
| 2486 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2482 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2487 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2483 base::MakeUnique<base::Value>(false), nullptr); |
| 2488 UpdateProviderPolicy(policies); | 2484 UpdateProviderPolicy(policies); |
| 2489 | 2485 |
| 2490 const extensions::Extension* extension = | 2486 const extensions::Extension* extension = |
| 2491 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); | 2487 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); |
| 2492 ASSERT_TRUE(extension); | 2488 ASSERT_TRUE(extension); |
| 2493 | 2489 |
| 2494 // Launch an app that tries to open a fullscreen window. | 2490 // Launch an app that tries to open a fullscreen window. |
| 2495 TestAddAppWindowObserver add_window_observer( | 2491 TestAddAppWindowObserver add_window_observer( |
| 2496 extensions::AppWindowRegistry::Get(browser()->profile())); | 2492 extensions::AppWindowRegistry::Get(browser()->profile())); |
| 2497 OpenApplication(AppLaunchParams( | 2493 OpenApplication(AppLaunchParams( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2545 | 2541 |
| 2546 bool prior_state = audio_handler->IsOutputMuted(); | 2542 bool prior_state = audio_handler->IsOutputMuted(); |
| 2547 // Make sure the audio is not muted and then toggle the policy and observe | 2543 // Make sure the audio is not muted and then toggle the policy and observe |
| 2548 // if the output mute changed event is fired. | 2544 // if the output mute changed event is fired. |
| 2549 audio_handler->SetOutputMute(false); | 2545 audio_handler->SetOutputMute(false); |
| 2550 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2546 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 2551 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2547 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2552 PolicyMap policies; | 2548 PolicyMap policies; |
| 2553 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, | 2549 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
| 2554 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2550 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2555 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2551 base::MakeUnique<base::Value>(false), nullptr); |
| 2556 UpdateProviderPolicy(policies); | 2552 UpdateProviderPolicy(policies); |
| 2557 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2553 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2558 // This should not change the state now and should not trigger output mute | 2554 // This should not change the state now and should not trigger output mute |
| 2559 // changed event. | 2555 // changed event. |
| 2560 audio_handler->SetOutputMute(false); | 2556 audio_handler->SetOutputMute(false); |
| 2561 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2557 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2562 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2558 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2563 | 2559 |
| 2564 // Toggle back and observe if the output mute changed event is fired. | 2560 // Toggle back and observe if the output mute changed event is fired. |
| 2565 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, | 2561 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
| 2566 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2562 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2567 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2563 base::MakeUnique<base::Value>(true), nullptr); |
| 2568 UpdateProviderPolicy(policies); | 2564 UpdateProviderPolicy(policies); |
| 2569 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2565 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 2570 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2566 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2571 audio_handler->SetOutputMute(true); | 2567 audio_handler->SetOutputMute(true); |
| 2572 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2568 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2573 EXPECT_EQ(2, test_observer->output_mute_changed_count()); | 2569 EXPECT_EQ(2, test_observer->output_mute_changed_count()); |
| 2574 // Revert the prior state. | 2570 // Revert the prior state. |
| 2575 audio_handler->SetOutputMute(prior_state); | 2571 audio_handler->SetOutputMute(prior_state); |
| 2576 audio_handler->RemoveAudioObserver(test_observer.get()); | 2572 audio_handler->RemoveAudioObserver(test_observer.get()); |
| 2577 } | 2573 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2592 chrome::NOTIFICATION_APP_TERMINATING, | 2588 chrome::NOTIFICATION_APP_TERMINATING, |
| 2593 content::NotificationService::AllSources()); | 2589 content::NotificationService::AllSources()); |
| 2594 | 2590 |
| 2595 // Set the session length limit to 3 hours. Verify that the session is not | 2591 // Set the session length limit to 3 hours. Verify that the session is not |
| 2596 // terminated. | 2592 // terminated. |
| 2597 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2593 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2598 .Times(0); | 2594 .Times(0); |
| 2599 PolicyMap policies; | 2595 PolicyMap policies; |
| 2600 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2596 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2601 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2597 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2602 base::MakeUnique<base::FundamentalValue>(kThreeHoursInMs), | 2598 base::MakeUnique<base::Value>(kThreeHoursInMs), nullptr); |
| 2603 nullptr); | |
| 2604 UpdateProviderPolicy(policies); | 2599 UpdateProviderPolicy(policies); |
| 2605 base::RunLoop().RunUntilIdle(); | 2600 base::RunLoop().RunUntilIdle(); |
| 2606 Mock::VerifyAndClearExpectations(&observer); | 2601 Mock::VerifyAndClearExpectations(&observer); |
| 2607 | 2602 |
| 2608 // Decrease the session length limit to 1 hour. Verify that the session is | 2603 // Decrease the session length limit to 1 hour. Verify that the session is |
| 2609 // terminated immediately. | 2604 // terminated immediately. |
| 2610 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2605 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
| 2611 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2606 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2612 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2607 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2613 base::MakeUnique<base::FundamentalValue>(kOneHourInMs), nullptr); | 2608 base::MakeUnique<base::Value>(kOneHourInMs), nullptr); |
| 2614 UpdateProviderPolicy(policies); | 2609 UpdateProviderPolicy(policies); |
| 2615 base::RunLoop().RunUntilIdle(); | 2610 base::RunLoop().RunUntilIdle(); |
| 2616 Mock::VerifyAndClearExpectations(&observer); | 2611 Mock::VerifyAndClearExpectations(&observer); |
| 2617 } | 2612 } |
| 2618 | 2613 |
| 2619 // Disabled, see http://crbug.com/554728. | 2614 // Disabled, see http://crbug.com/554728. |
| 2620 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2615 IN_PROC_BROWSER_TEST_F(PolicyTest, |
| 2621 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { | 2616 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { |
| 2622 // Indicate that the session started 2 hours ago and no user activity has | 2617 // Indicate that the session started 2 hours ago and no user activity has |
| 2623 // occurred yet. | 2618 // occurred yet. |
| 2624 g_browser_process->local_state()->SetInt64( | 2619 g_browser_process->local_state()->SetInt64( |
| 2625 prefs::kSessionStartTime, | 2620 prefs::kSessionStartTime, |
| 2626 (base::TimeTicks::Now() - base::TimeDelta::FromHours(2)) | 2621 (base::TimeTicks::Now() - base::TimeDelta::FromHours(2)) |
| 2627 .ToInternalValue()); | 2622 .ToInternalValue()); |
| 2628 } | 2623 } |
| 2629 | 2624 |
| 2630 // Disabled, see http://crbug.com/554728. | 2625 // Disabled, see http://crbug.com/554728. |
| 2631 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2626 IN_PROC_BROWSER_TEST_F(PolicyTest, |
| 2632 DISABLED_WaitForInitialUserActivityUnsatisfied) { | 2627 DISABLED_WaitForInitialUserActivityUnsatisfied) { |
| 2633 content::MockNotificationObserver observer; | 2628 content::MockNotificationObserver observer; |
| 2634 content::NotificationRegistrar registrar; | 2629 content::NotificationRegistrar registrar; |
| 2635 registrar.Add(&observer, | 2630 registrar.Add(&observer, |
| 2636 chrome::NOTIFICATION_APP_TERMINATING, | 2631 chrome::NOTIFICATION_APP_TERMINATING, |
| 2637 content::NotificationService::AllSources()); | 2632 content::NotificationService::AllSources()); |
| 2638 | 2633 |
| 2639 // Require initial user activity. | 2634 // Require initial user activity. |
| 2640 PolicyMap policies; | 2635 PolicyMap policies; |
| 2641 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2636 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
| 2642 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2637 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2643 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2638 base::WrapUnique(new base::Value(true)), nullptr); |
| 2644 UpdateProviderPolicy(policies); | 2639 UpdateProviderPolicy(policies); |
| 2645 base::RunLoop().RunUntilIdle(); | 2640 base::RunLoop().RunUntilIdle(); |
| 2646 | 2641 |
| 2647 // Set the session length limit to 1 hour. Verify that the session is not | 2642 // Set the session length limit to 1 hour. Verify that the session is not |
| 2648 // terminated. | 2643 // terminated. |
| 2649 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2644 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2650 .Times(0); | 2645 .Times(0); |
| 2651 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2646 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2652 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2647 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2653 base::WrapUnique(new base::FundamentalValue(kOneHourInMs)), | 2648 base::WrapUnique(new base::Value(kOneHourInMs)), nullptr); |
| 2654 nullptr); | |
| 2655 UpdateProviderPolicy(policies); | 2649 UpdateProviderPolicy(policies); |
| 2656 base::RunLoop().RunUntilIdle(); | 2650 base::RunLoop().RunUntilIdle(); |
| 2657 Mock::VerifyAndClearExpectations(&observer); | 2651 Mock::VerifyAndClearExpectations(&observer); |
| 2658 } | 2652 } |
| 2659 | 2653 |
| 2660 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2654 IN_PROC_BROWSER_TEST_F(PolicyTest, |
| 2661 PRE_WaitForInitialUserActivitySatisfied) { | 2655 PRE_WaitForInitialUserActivitySatisfied) { |
| 2662 // Indicate that initial user activity in this session occurred 2 hours ago. | 2656 // Indicate that initial user activity in this session occurred 2 hours ago. |
| 2663 g_browser_process->local_state()->SetInt64( | 2657 g_browser_process->local_state()->SetInt64( |
| 2664 prefs::kSessionStartTime, | 2658 prefs::kSessionStartTime, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2677 chrome::NOTIFICATION_APP_TERMINATING, | 2671 chrome::NOTIFICATION_APP_TERMINATING, |
| 2678 content::NotificationService::AllSources()); | 2672 content::NotificationService::AllSources()); |
| 2679 | 2673 |
| 2680 // Require initial user activity and set the session length limit to 3 hours. | 2674 // Require initial user activity and set the session length limit to 3 hours. |
| 2681 // Verify that the session is not terminated. | 2675 // Verify that the session is not terminated. |
| 2682 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2676 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2683 .Times(0); | 2677 .Times(0); |
| 2684 PolicyMap policies; | 2678 PolicyMap policies; |
| 2685 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2679 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
| 2686 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2680 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2687 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2681 base::MakeUnique<base::Value>(true), nullptr); |
| 2688 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2682 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2689 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2683 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2690 base::MakeUnique<base::FundamentalValue>(kThreeHoursInMs), | 2684 base::MakeUnique<base::Value>(kThreeHoursInMs), nullptr); |
| 2691 nullptr); | |
| 2692 UpdateProviderPolicy(policies); | 2685 UpdateProviderPolicy(policies); |
| 2693 base::RunLoop().RunUntilIdle(); | 2686 base::RunLoop().RunUntilIdle(); |
| 2694 Mock::VerifyAndClearExpectations(&observer); | 2687 Mock::VerifyAndClearExpectations(&observer); |
| 2695 | 2688 |
| 2696 // Decrease the session length limit to 1 hour. Verify that the session is | 2689 // Decrease the session length limit to 1 hour. Verify that the session is |
| 2697 // terminated immediately. | 2690 // terminated immediately. |
| 2698 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2691 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
| 2699 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2692 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2700 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2693 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2701 base::MakeUnique<base::FundamentalValue>(kOneHourInMs), nullptr); | 2694 base::MakeUnique<base::Value>(kOneHourInMs), nullptr); |
| 2702 UpdateProviderPolicy(policies); | 2695 UpdateProviderPolicy(policies); |
| 2703 base::RunLoop().RunUntilIdle(); | 2696 base::RunLoop().RunUntilIdle(); |
| 2704 Mock::VerifyAndClearExpectations(&observer); | 2697 Mock::VerifyAndClearExpectations(&observer); |
| 2705 } | 2698 } |
| 2706 | 2699 |
| 2707 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { | 2700 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { |
| 2708 // Verifies that the large cursor accessibility feature can be controlled | 2701 // Verifies that the large cursor accessibility feature can be controlled |
| 2709 // through policy. | 2702 // through policy. |
| 2710 chromeos::AccessibilityManager* accessibility_manager = | 2703 chromeos::AccessibilityManager* accessibility_manager = |
| 2711 chromeos::AccessibilityManager::Get(); | 2704 chromeos::AccessibilityManager::Get(); |
| 2712 | 2705 |
| 2713 // Manually enable the large cursor. | 2706 // Manually enable the large cursor. |
| 2714 accessibility_manager->EnableLargeCursor(true); | 2707 accessibility_manager->EnableLargeCursor(true); |
| 2715 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); | 2708 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); |
| 2716 | 2709 |
| 2717 // Verify that policy overrides the manual setting. | 2710 // Verify that policy overrides the manual setting. |
| 2718 PolicyMap policies; | 2711 PolicyMap policies; |
| 2719 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, | 2712 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, |
| 2720 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2713 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2721 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2714 base::MakeUnique<base::Value>(false), nullptr); |
| 2722 UpdateProviderPolicy(policies); | 2715 UpdateProviderPolicy(policies); |
| 2723 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2716 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
| 2724 | 2717 |
| 2725 // Verify that the large cursor cannot be enabled manually anymore. | 2718 // Verify that the large cursor cannot be enabled manually anymore. |
| 2726 accessibility_manager->EnableLargeCursor(true); | 2719 accessibility_manager->EnableLargeCursor(true); |
| 2727 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2720 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
| 2728 } | 2721 } |
| 2729 | 2722 |
| 2730 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { | 2723 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { |
| 2731 // Verifies that the spoken feedback accessibility feature can be controlled | 2724 // Verifies that the spoken feedback accessibility feature can be controlled |
| 2732 // through policy. | 2725 // through policy. |
| 2733 chromeos::AccessibilityManager* accessibility_manager = | 2726 chromeos::AccessibilityManager* accessibility_manager = |
| 2734 chromeos::AccessibilityManager::Get(); | 2727 chromeos::AccessibilityManager::Get(); |
| 2735 | 2728 |
| 2736 // Manually enable spoken feedback. | 2729 // Manually enable spoken feedback. |
| 2737 accessibility_manager->EnableSpokenFeedback(true, | 2730 accessibility_manager->EnableSpokenFeedback(true, |
| 2738 ash::A11Y_NOTIFICATION_NONE); | 2731 ash::A11Y_NOTIFICATION_NONE); |
| 2739 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2732 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2740 | 2733 |
| 2741 // Verify that policy overrides the manual setting. | 2734 // Verify that policy overrides the manual setting. |
| 2742 PolicyMap policies; | 2735 PolicyMap policies; |
| 2743 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, | 2736 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, |
| 2744 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2737 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2745 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2738 base::MakeUnique<base::Value>(false), nullptr); |
| 2746 UpdateProviderPolicy(policies); | 2739 UpdateProviderPolicy(policies); |
| 2747 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2740 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2748 | 2741 |
| 2749 // Verify that spoken feedback cannot be enabled manually anymore. | 2742 // Verify that spoken feedback cannot be enabled manually anymore. |
| 2750 accessibility_manager->EnableSpokenFeedback(true, | 2743 accessibility_manager->EnableSpokenFeedback(true, |
| 2751 ash::A11Y_NOTIFICATION_NONE); | 2744 ash::A11Y_NOTIFICATION_NONE); |
| 2752 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2745 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2753 } | 2746 } |
| 2754 | 2747 |
| 2755 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { | 2748 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { |
| 2756 // Verifies that the high contrast mode accessibility feature can be | 2749 // Verifies that the high contrast mode accessibility feature can be |
| 2757 // controlled through policy. | 2750 // controlled through policy. |
| 2758 chromeos::AccessibilityManager* accessibility_manager = | 2751 chromeos::AccessibilityManager* accessibility_manager = |
| 2759 chromeos::AccessibilityManager::Get(); | 2752 chromeos::AccessibilityManager::Get(); |
| 2760 | 2753 |
| 2761 // Manually enable high contrast mode. | 2754 // Manually enable high contrast mode. |
| 2762 accessibility_manager->EnableHighContrast(true); | 2755 accessibility_manager->EnableHighContrast(true); |
| 2763 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); | 2756 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); |
| 2764 | 2757 |
| 2765 // Verify that policy overrides the manual setting. | 2758 // Verify that policy overrides the manual setting. |
| 2766 PolicyMap policies; | 2759 PolicyMap policies; |
| 2767 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, | 2760 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, |
| 2768 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2761 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2769 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2762 base::MakeUnique<base::Value>(false), nullptr); |
| 2770 UpdateProviderPolicy(policies); | 2763 UpdateProviderPolicy(policies); |
| 2771 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2764 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
| 2772 | 2765 |
| 2773 // Verify that high contrast mode cannot be enabled manually anymore. | 2766 // Verify that high contrast mode cannot be enabled manually anymore. |
| 2774 accessibility_manager->EnableHighContrast(true); | 2767 accessibility_manager->EnableHighContrast(true); |
| 2775 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2768 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
| 2776 } | 2769 } |
| 2777 | 2770 |
| 2778 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { | 2771 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { |
| 2779 // Verifies that the screen magnifier can be disabled through policy. | 2772 // Verifies that the screen magnifier can be disabled through policy. |
| 2780 chromeos::MagnificationManager* magnification_manager = | 2773 chromeos::MagnificationManager* magnification_manager = |
| 2781 chromeos::MagnificationManager::Get(); | 2774 chromeos::MagnificationManager::Get(); |
| 2782 | 2775 |
| 2783 // Manually enable the full-screen magnifier. | 2776 // Manually enable the full-screen magnifier. |
| 2784 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL); | 2777 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL); |
| 2785 magnification_manager->SetMagnifierEnabled(true); | 2778 magnification_manager->SetMagnifierEnabled(true); |
| 2786 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 2779 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
| 2787 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2780 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2788 | 2781 |
| 2789 // Verify that policy overrides the manual setting. | 2782 // Verify that policy overrides the manual setting. |
| 2790 PolicyMap policies; | 2783 PolicyMap policies; |
| 2791 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, | 2784 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
| 2792 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2785 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2793 base::MakeUnique<base::FundamentalValue>(0), nullptr); | 2786 base::MakeUnique<base::Value>(0), nullptr); |
| 2794 UpdateProviderPolicy(policies); | 2787 UpdateProviderPolicy(policies); |
| 2795 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2788 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2796 | 2789 |
| 2797 // Verify that the screen magnifier cannot be enabled manually anymore. | 2790 // Verify that the screen magnifier cannot be enabled manually anymore. |
| 2798 magnification_manager->SetMagnifierEnabled(true); | 2791 magnification_manager->SetMagnifierEnabled(true); |
| 2799 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2792 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2800 } | 2793 } |
| 2801 | 2794 |
| 2802 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { | 2795 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { |
| 2803 // Verifies that the full-screen magnifier can be enabled through policy. | 2796 // Verifies that the full-screen magnifier can be enabled through policy. |
| 2804 chromeos::MagnificationManager* magnification_manager = | 2797 chromeos::MagnificationManager* magnification_manager = |
| 2805 chromeos::MagnificationManager::Get(); | 2798 chromeos::MagnificationManager::Get(); |
| 2806 | 2799 |
| 2807 // Verify that the screen magnifier is initially disabled. | 2800 // Verify that the screen magnifier is initially disabled. |
| 2808 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2801 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2809 | 2802 |
| 2810 // Verify that policy can enable the full-screen magnifier. | 2803 // Verify that policy can enable the full-screen magnifier. |
| 2811 PolicyMap policies; | 2804 PolicyMap policies; |
| 2812 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, | 2805 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
| 2813 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2806 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2814 base::MakeUnique<base::FundamentalValue>(ash::MAGNIFIER_FULL), | 2807 base::MakeUnique<base::Value>(ash::MAGNIFIER_FULL), nullptr); |
| 2815 nullptr); | |
| 2816 UpdateProviderPolicy(policies); | 2808 UpdateProviderPolicy(policies); |
| 2817 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 2809 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
| 2818 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2810 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2819 | 2811 |
| 2820 // Verify that the screen magnifier cannot be disabled manually anymore. | 2812 // Verify that the screen magnifier cannot be disabled manually anymore. |
| 2821 magnification_manager->SetMagnifierEnabled(false); | 2813 magnification_manager->SetMagnifierEnabled(false); |
| 2822 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2814 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2823 } | 2815 } |
| 2824 | 2816 |
| 2825 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { | 2817 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { |
| 2826 // Verifies that the on-screen keyboard accessibility feature can be | 2818 // Verifies that the on-screen keyboard accessibility feature can be |
| 2827 // controlled through policy. | 2819 // controlled through policy. |
| 2828 chromeos::AccessibilityManager* accessibility_manager = | 2820 chromeos::AccessibilityManager* accessibility_manager = |
| 2829 chromeos::AccessibilityManager::Get(); | 2821 chromeos::AccessibilityManager::Get(); |
| 2830 | 2822 |
| 2831 // Manually enable the on-screen keyboard. | 2823 // Manually enable the on-screen keyboard. |
| 2832 accessibility_manager->EnableVirtualKeyboard(true); | 2824 accessibility_manager->EnableVirtualKeyboard(true); |
| 2833 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2825 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2834 | 2826 |
| 2835 // Verify that policy overrides the manual setting. | 2827 // Verify that policy overrides the manual setting. |
| 2836 PolicyMap policies; | 2828 PolicyMap policies; |
| 2837 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2829 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2838 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2830 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2839 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2831 base::MakeUnique<base::Value>(false), nullptr); |
| 2840 UpdateProviderPolicy(policies); | 2832 UpdateProviderPolicy(policies); |
| 2841 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2833 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2842 | 2834 |
| 2843 // Verify that the on-screen keyboard cannot be enabled manually anymore. | 2835 // Verify that the on-screen keyboard cannot be enabled manually anymore. |
| 2844 accessibility_manager->EnableVirtualKeyboard(true); | 2836 accessibility_manager->EnableVirtualKeyboard(true); |
| 2845 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2837 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2846 } | 2838 } |
| 2847 | 2839 |
| 2848 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { | 2840 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { |
| 2849 // Verify keyboard disabled by default. | 2841 // Verify keyboard disabled by default. |
| 2850 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2842 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2851 // Verify keyboard can be toggled by default. | 2843 // Verify keyboard can be toggled by default. |
| 2852 keyboard::SetTouchKeyboardEnabled(true); | 2844 keyboard::SetTouchKeyboardEnabled(true); |
| 2853 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2845 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2854 keyboard::SetTouchKeyboardEnabled(false); | 2846 keyboard::SetTouchKeyboardEnabled(false); |
| 2855 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2847 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2856 | 2848 |
| 2857 // Verify enabling the policy takes effect immediately and that that user | 2849 // Verify enabling the policy takes effect immediately and that that user |
| 2858 // cannot disable the keyboard.. | 2850 // cannot disable the keyboard.. |
| 2859 PolicyMap policies; | 2851 PolicyMap policies; |
| 2860 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2852 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2861 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2853 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2862 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2854 base::MakeUnique<base::Value>(true), nullptr); |
| 2863 UpdateProviderPolicy(policies); | 2855 UpdateProviderPolicy(policies); |
| 2864 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2856 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2865 keyboard::SetTouchKeyboardEnabled(false); | 2857 keyboard::SetTouchKeyboardEnabled(false); |
| 2866 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2858 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2867 | 2859 |
| 2868 // Verify that disabling the policy takes effect immediately and that the user | 2860 // Verify that disabling the policy takes effect immediately and that the user |
| 2869 // cannot enable the keyboard. | 2861 // cannot enable the keyboard. |
| 2870 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2862 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2871 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2863 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2872 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2864 base::MakeUnique<base::Value>(false), nullptr); |
| 2873 UpdateProviderPolicy(policies); | 2865 UpdateProviderPolicy(policies); |
| 2874 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2866 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2875 keyboard::SetTouchKeyboardEnabled(true); | 2867 keyboard::SetTouchKeyboardEnabled(true); |
| 2876 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2868 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2877 } | 2869 } |
| 2878 | 2870 |
| 2879 #endif | 2871 #endif |
| 2880 | 2872 |
| 2881 namespace { | 2873 namespace { |
| 2882 | 2874 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2935 } | 2927 } |
| 2936 | 2928 |
| 2937 void ListOfURLs() { | 2929 void ListOfURLs() { |
| 2938 // Verifies that policy can set the startup pages to a list of URLs. | 2930 // Verifies that policy can set the startup pages to a list of URLs. |
| 2939 base::ListValue urls; | 2931 base::ListValue urls; |
| 2940 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { | 2932 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { |
| 2941 urls.AppendString(kRestoredURLs[i]); | 2933 urls.AppendString(kRestoredURLs[i]); |
| 2942 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 2934 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
| 2943 } | 2935 } |
| 2944 PolicyMap policies; | 2936 PolicyMap policies; |
| 2945 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 2937 policies.Set( |
| 2946 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2938 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 2947 base::WrapUnique(new base::FundamentalValue( | 2939 POLICY_SOURCE_CLOUD, |
| 2948 SessionStartupPref::kPrefValueURLs)), | 2940 base::WrapUnique(new base::Value(SessionStartupPref::kPrefValueURLs)), |
| 2949 nullptr); | 2941 nullptr); |
| 2950 policies.Set(key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, | 2942 policies.Set(key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, |
| 2951 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, urls.CreateDeepCopy(), | 2943 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, urls.CreateDeepCopy(), |
| 2952 nullptr); | 2944 nullptr); |
| 2953 provider_.UpdateChromePolicy(policies); | 2945 provider_.UpdateChromePolicy(policies); |
| 2954 } | 2946 } |
| 2955 | 2947 |
| 2956 void NTP() { | 2948 void NTP() { |
| 2957 // Verifies that policy can set the startup page to the NTP. | 2949 // Verifies that policy can set the startup page to the NTP. |
| 2958 PolicyMap policies; | 2950 PolicyMap policies; |
| 2959 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 2951 policies.Set( |
| 2960 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2952 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 2961 base::WrapUnique(new base::FundamentalValue( | 2953 POLICY_SOURCE_CLOUD, |
| 2962 SessionStartupPref::kPrefValueNewTab)), | 2954 base::WrapUnique(new base::Value(SessionStartupPref::kPrefValueNewTab)), |
| 2963 nullptr); | 2955 nullptr); |
| 2964 provider_.UpdateChromePolicy(policies); | 2956 provider_.UpdateChromePolicy(policies); |
| 2965 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); | 2957 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); |
| 2966 } | 2958 } |
| 2967 | 2959 |
| 2968 void Last() { | 2960 void Last() { |
| 2969 // Verifies that policy can set the startup pages to the last session. | 2961 // Verifies that policy can set the startup pages to the last session. |
| 2970 PolicyMap policies; | 2962 PolicyMap policies; |
| 2971 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 2963 policies.Set( |
| 2972 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2964 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 2973 base::WrapUnique(new base::FundamentalValue( | 2965 POLICY_SOURCE_CLOUD, |
| 2974 SessionStartupPref::kPrefValueLast)), | 2966 base::WrapUnique(new base::Value(SessionStartupPref::kPrefValueLast)), |
| 2975 nullptr); | 2967 nullptr); |
| 2976 provider_.UpdateChromePolicy(policies); | 2968 provider_.UpdateChromePolicy(policies); |
| 2977 // This should restore the tabs opened at PRE_RunTest below. | 2969 // This should restore the tabs opened at PRE_RunTest below. |
| 2978 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) | 2970 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) |
| 2979 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 2971 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
| 2980 } | 2972 } |
| 2981 | 2973 |
| 2982 std::vector<GURL> expected_urls_; | 2974 std::vector<GURL> expected_urls_; |
| 2983 }; | 2975 }; |
| 2984 | 2976 |
| 2985 IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, PRE_RunTest) { | 2977 IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, PRE_RunTest) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3028 class PolicyStatisticsCollectorTest : public PolicyTest { | 3020 class PolicyStatisticsCollectorTest : public PolicyTest { |
| 3029 public: | 3021 public: |
| 3030 PolicyStatisticsCollectorTest() {} | 3022 PolicyStatisticsCollectorTest() {} |
| 3031 ~PolicyStatisticsCollectorTest() override {} | 3023 ~PolicyStatisticsCollectorTest() override {} |
| 3032 | 3024 |
| 3033 void SetUpInProcessBrowserTestFixture() override { | 3025 void SetUpInProcessBrowserTestFixture() override { |
| 3034 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3026 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3035 PolicyMap policies; | 3027 PolicyMap policies; |
| 3036 policies.Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, | 3028 policies.Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, |
| 3037 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3029 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3038 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 3030 base::MakeUnique<base::Value>(true), nullptr); |
| 3039 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 3031 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 3040 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3032 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3041 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 3033 base::MakeUnique<base::Value>(false), nullptr); |
| 3042 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, | 3034 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, |
| 3043 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3035 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3044 base::MakeUnique<base::StringValue>("http://chromium.org"), | 3036 base::MakeUnique<base::StringValue>("http://chromium.org"), |
| 3045 nullptr); | 3037 nullptr); |
| 3046 provider_.UpdateChromePolicy(policies); | 3038 provider_.UpdateChromePolicy(policies); |
| 3047 } | 3039 } |
| 3048 }; | 3040 }; |
| 3049 | 3041 |
| 3050 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { | 3042 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { |
| 3051 // Verifies that policy usage histograms are collected at startup. | 3043 // Verifies that policy usage histograms are collected at startup. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3100 // Configure a given policy map. The |policy_name| is the name of either the | 3092 // Configure a given policy map. The |policy_name| is the name of either the |
| 3101 // audio or video capture allow policy and must never be NULL. | 3093 // audio or video capture allow policy and must never be NULL. |
| 3102 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist | 3094 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist |
| 3103 // policy is set. If non-NULL, the whitelist policy is set to contain either | 3095 // policy is set. If non-NULL, the whitelist policy is set to contain either |
| 3104 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. | 3096 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. |
| 3105 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, | 3097 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, |
| 3106 const char* whitelist_policy, | 3098 const char* whitelist_policy, |
| 3107 const char* allow_rule) { | 3099 const char* allow_rule) { |
| 3108 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3100 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 3109 POLICY_SOURCE_CLOUD, | 3101 POLICY_SOURCE_CLOUD, |
| 3110 base::MakeUnique<base::FundamentalValue>(policy_value_), | 3102 base::MakeUnique<base::Value>(policy_value_), nullptr); |
| 3111 nullptr); | |
| 3112 | 3103 |
| 3113 if (whitelist_policy) { | 3104 if (whitelist_policy) { |
| 3114 // Add an entry to the whitelist that allows the specified URL regardless | 3105 // Add an entry to the whitelist that allows the specified URL regardless |
| 3115 // of the setting of kAudioCapturedAllowed. | 3106 // of the setting of kAudioCapturedAllowed. |
| 3116 std::unique_ptr<base::ListValue> list(new base::ListValue); | 3107 std::unique_ptr<base::ListValue> list(new base::ListValue); |
| 3117 if (allow_rule) { | 3108 if (allow_rule) { |
| 3118 list->AppendString(allow_rule); | 3109 list->AppendString(allow_rule); |
| 3119 request_url_allowed_via_whitelist_ = true; | 3110 request_url_allowed_via_whitelist_ = true; |
| 3120 } else { | 3111 } else { |
| 3121 list->AppendString(ContentSettingsPattern::Wildcard().ToString()); | 3112 list->AppendString(ContentSettingsPattern::Wildcard().ToString()); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3329 content::WebContents* const web_contents = | 3320 content::WebContents* const web_contents = |
| 3330 browser()->tab_strip_model()->GetActiveWebContents(); | 3321 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3331 EXPECT_THAT( | 3322 EXPECT_THAT( |
| 3332 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), | 3323 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), |
| 3333 testing::StartsWith("http://localhost:")); | 3324 testing::StartsWith("http://localhost:")); |
| 3334 | 3325 |
| 3335 // Set the policy to block Web Bluetooth. | 3326 // Set the policy to block Web Bluetooth. |
| 3336 PolicyMap policies; | 3327 PolicyMap policies; |
| 3337 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, | 3328 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, |
| 3338 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3329 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3339 base::MakeUnique<base::FundamentalValue>(2), nullptr); | 3330 base::MakeUnique<base::Value>(2), nullptr); |
| 3340 UpdateProviderPolicy(policies); | 3331 UpdateProviderPolicy(policies); |
| 3341 | 3332 |
| 3342 std::string rejection; | 3333 std::string rejection; |
| 3343 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 3334 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 3344 web_contents, | 3335 web_contents, |
| 3345 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" | 3336 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" |
| 3346 " .then(() => { domAutomationController.send('Success'); }," | 3337 " .then(() => { domAutomationController.send('Success'); }," |
| 3347 " reason => {" | 3338 " reason => {" |
| 3348 " domAutomationController.send(reason.name + ': ' + reason.message);" | 3339 " domAutomationController.send(reason.name + ': ' + reason.message);" |
| 3349 " });", | 3340 " });", |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3418 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3409 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 3419 ASSERT_TRUE(https_server_expired.Start()); | 3410 ASSERT_TRUE(https_server_expired.Start()); |
| 3420 | 3411 |
| 3421 // Set the enterprise policy to disallow opt-in. | 3412 // Set the enterprise policy to disallow opt-in. |
| 3422 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3413 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3423 EXPECT_TRUE( | 3414 EXPECT_TRUE( |
| 3424 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3415 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
| 3425 PolicyMap policies; | 3416 PolicyMap policies; |
| 3426 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, | 3417 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, |
| 3427 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3418 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3428 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3419 base::WrapUnique(new base::Value(false)), nullptr); |
| 3429 UpdateProviderPolicy(policies); | 3420 UpdateProviderPolicy(policies); |
| 3430 EXPECT_FALSE( | 3421 EXPECT_FALSE( |
| 3431 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3422 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
| 3432 | 3423 |
| 3433 // Navigate to an SSL error page. | 3424 // Navigate to an SSL error page. |
| 3434 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3425 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
| 3435 | 3426 |
| 3436 const content::InterstitialPage* const interstitial = | 3427 const content::InterstitialPage* const interstitial = |
| 3437 content::InterstitialPage::GetInterstitialPage( | 3428 content::InterstitialPage::GetInterstitialPage( |
| 3438 browser()->tab_strip_model()->GetActiveWebContents()); | 3429 browser()->tab_strip_model()->GetActiveWebContents()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3500 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3491 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 3501 ASSERT_TRUE(https_server_expired.Start()); | 3492 ASSERT_TRUE(https_server_expired.Start()); |
| 3502 | 3493 |
| 3503 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3494 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3504 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3495 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
| 3505 | 3496 |
| 3506 // Disallowing the proceed link by setting the policy to |false|. | 3497 // Disallowing the proceed link by setting the policy to |false|. |
| 3507 PolicyMap policies; | 3498 PolicyMap policies; |
| 3508 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, | 3499 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, |
| 3509 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3500 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3510 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3501 base::WrapUnique(new base::Value(false)), nullptr); |
| 3511 UpdateProviderPolicy(policies); | 3502 UpdateProviderPolicy(policies); |
| 3512 | 3503 |
| 3513 // Policy should not allow overriding anymore. | 3504 // Policy should not allow overriding anymore. |
| 3514 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3505 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
| 3515 | 3506 |
| 3516 // Policy disallows overriding - navigate to an SSL error page and expect no | 3507 // Policy disallows overriding - navigate to an SSL error page and expect no |
| 3517 // proceed link. | 3508 // proceed link. |
| 3518 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3509 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
| 3519 const content::InterstitialPage* const interstitial = | 3510 const content::InterstitialPage* const interstitial = |
| 3520 content::InterstitialPage::GetInterstitialPage( | 3511 content::InterstitialPage::GetInterstitialPage( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3548 // Test that TaskManagerInterface::IsEndProcessEnabled is controlled by | 3539 // Test that TaskManagerInterface::IsEndProcessEnabled is controlled by |
| 3549 // TaskManagerEndProcessEnabled policy | 3540 // TaskManagerEndProcessEnabled policy |
| 3550 IN_PROC_BROWSER_TEST_F(PolicyTest, TaskManagerEndProcessEnabled) { | 3541 IN_PROC_BROWSER_TEST_F(PolicyTest, TaskManagerEndProcessEnabled) { |
| 3551 // By default it's allowed to end tasks. | 3542 // By default it's allowed to end tasks. |
| 3552 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); | 3543 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); |
| 3553 | 3544 |
| 3554 // Disabling ending tasks in task manager by policy | 3545 // Disabling ending tasks in task manager by policy |
| 3555 PolicyMap policies1; | 3546 PolicyMap policies1; |
| 3556 policies1.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, | 3547 policies1.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, |
| 3557 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 3548 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 3558 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3549 base::WrapUnique(new base::Value(false)), nullptr); |
| 3559 UpdateProviderPolicy(policies1); | 3550 UpdateProviderPolicy(policies1); |
| 3560 | 3551 |
| 3561 // Policy should not allow ending tasks anymore. | 3552 // Policy should not allow ending tasks anymore. |
| 3562 EXPECT_FALSE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); | 3553 EXPECT_FALSE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); |
| 3563 | 3554 |
| 3564 // Enabling ending tasks in task manager by policy | 3555 // Enabling ending tasks in task manager by policy |
| 3565 PolicyMap policies2; | 3556 PolicyMap policies2; |
| 3566 policies2.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, | 3557 policies2.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, |
| 3567 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 3558 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 3568 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 3559 base::WrapUnique(new base::Value(true)), nullptr); |
| 3569 UpdateProviderPolicy(policies2); | 3560 UpdateProviderPolicy(policies2); |
| 3570 | 3561 |
| 3571 // Policy should allow ending tasks again. | 3562 // Policy should allow ending tasks again. |
| 3572 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); | 3563 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); |
| 3573 } | 3564 } |
| 3574 | 3565 |
| 3575 #if defined(ENABLE_MEDIA_ROUTER) | 3566 #if defined(ENABLE_MEDIA_ROUTER) |
| 3576 // Sets the proper policy before the browser is started. | 3567 // Sets the proper policy before the browser is started. |
| 3577 template<bool enable> | 3568 template<bool enable> |
| 3578 class MediaRouterPolicyTest : public PolicyTest { | 3569 class MediaRouterPolicyTest : public PolicyTest { |
| 3579 public: | 3570 public: |
| 3580 void SetUpInProcessBrowserTestFixture() override { | 3571 void SetUpInProcessBrowserTestFixture() override { |
| 3581 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3572 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3582 PolicyMap policies; | 3573 PolicyMap policies; |
| 3583 policies.Set(key::kEnableMediaRouter, POLICY_LEVEL_MANDATORY, | 3574 policies.Set(key::kEnableMediaRouter, POLICY_LEVEL_MANDATORY, |
| 3584 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3575 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3585 base::MakeUnique<base::FundamentalValue>(enable), nullptr); | 3576 base::MakeUnique<base::Value>(enable), nullptr); |
| 3586 provider_.UpdateChromePolicy(policies); | 3577 provider_.UpdateChromePolicy(policies); |
| 3587 } | 3578 } |
| 3588 }; | 3579 }; |
| 3589 | 3580 |
| 3590 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; | 3581 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; |
| 3591 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; | 3582 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; |
| 3592 | 3583 |
| 3593 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { | 3584 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { |
| 3594 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); | 3585 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3595 } | 3586 } |
| 3596 | 3587 |
| 3597 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { | 3588 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { |
| 3598 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); | 3589 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3599 } | 3590 } |
| 3600 | 3591 |
| 3601 #if !defined(OS_ANDROID) | 3592 #if !defined(OS_ANDROID) |
| 3602 template <bool enable> | 3593 template <bool enable> |
| 3603 class MediaRouterActionPolicyTest : public PolicyTest { | 3594 class MediaRouterActionPolicyTest : public PolicyTest { |
| 3604 public: | 3595 public: |
| 3605 void SetUpInProcessBrowserTestFixture() override { | 3596 void SetUpInProcessBrowserTestFixture() override { |
| 3606 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3597 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3607 PolicyMap policies; | 3598 PolicyMap policies; |
| 3608 policies.Set(key::kShowCastIconInToolbar, POLICY_LEVEL_MANDATORY, | 3599 policies.Set(key::kShowCastIconInToolbar, POLICY_LEVEL_MANDATORY, |
| 3609 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3600 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3610 base::MakeUnique<base::FundamentalValue>(enable), nullptr); | 3601 base::MakeUnique<base::Value>(enable), nullptr); |
| 3611 provider_.UpdateChromePolicy(policies); | 3602 provider_.UpdateChromePolicy(policies); |
| 3612 } | 3603 } |
| 3613 | 3604 |
| 3614 protected: | 3605 protected: |
| 3615 bool HasMediaRouterActionAtInit() const { | 3606 bool HasMediaRouterActionAtInit() const { |
| 3616 const std::set<std::string>& component_ids = | 3607 const std::set<std::string>& component_ids = |
| 3617 ToolbarActionsModel::Get(browser()->profile()) | 3608 ToolbarActionsModel::Get(browser()->profile()) |
| 3618 ->component_actions_factory() | 3609 ->component_actions_factory() |
| 3619 ->GetInitialComponentIds(); | 3610 ->GetInitialComponentIds(); |
| 3620 | 3611 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3759 const char ComponentUpdaterPolicyTest::component_id_[] = | 3750 const char ComponentUpdaterPolicyTest::component_id_[] = |
| 3760 "jebgalgnebhfojomionfpkfelancnnkf"; | 3751 "jebgalgnebhfojomionfpkfelancnnkf"; |
| 3761 | 3752 |
| 3762 ComponentUpdaterPolicyTest::ComponentUpdaterPolicyTest() {} | 3753 ComponentUpdaterPolicyTest::ComponentUpdaterPolicyTest() {} |
| 3763 | 3754 |
| 3764 ComponentUpdaterPolicyTest::~ComponentUpdaterPolicyTest() {} | 3755 ComponentUpdaterPolicyTest::~ComponentUpdaterPolicyTest() {} |
| 3765 | 3756 |
| 3766 void ComponentUpdaterPolicyTest::SetEnableComponentUpdates( | 3757 void ComponentUpdaterPolicyTest::SetEnableComponentUpdates( |
| 3767 bool enable_component_updates) { | 3758 bool enable_component_updates) { |
| 3768 PolicyMap policies; | 3759 PolicyMap policies; |
| 3769 policies.Set( | 3760 policies.Set(key::kComponentUpdatesEnabled, POLICY_LEVEL_MANDATORY, |
| 3770 key::kComponentUpdatesEnabled, POLICY_LEVEL_MANDATORY, | 3761 POLICY_SCOPE_MACHINE, POLICY_SOURCE_ENTERPRISE_DEFAULT, |
| 3771 POLICY_SCOPE_MACHINE, POLICY_SOURCE_ENTERPRISE_DEFAULT, | 3762 base::WrapUnique(new base::Value(enable_component_updates)), |
| 3772 base::WrapUnique(new base::FundamentalValue(enable_component_updates)), | 3763 nullptr); |
| 3773 nullptr); | |
| 3774 UpdateProviderPolicy(policies); | 3764 UpdateProviderPolicy(policies); |
| 3775 } | 3765 } |
| 3776 | 3766 |
| 3777 update_client::CrxComponent ComponentUpdaterPolicyTest::MakeCrxComponent( | 3767 update_client::CrxComponent ComponentUpdaterPolicyTest::MakeCrxComponent( |
| 3778 bool supports_group_policy_enable_component_updates) { | 3768 bool supports_group_policy_enable_component_updates) { |
| 3779 class MockInstaller : public update_client::CrxInstaller { | 3769 class MockInstaller : public update_client::CrxInstaller { |
| 3780 public: | 3770 public: |
| 3781 MockInstaller() {} | 3771 MockInstaller() {} |
| 3782 | 3772 |
| 3783 MOCK_METHOD1(OnUpdateError, void(int error)); | 3773 MOCK_METHOD1(OnUpdateError, void(int error)); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4062 // Sets the hardware acceleration mode policy before the browser is started. | 4052 // Sets the hardware acceleration mode policy before the browser is started. |
| 4063 class HardwareAccelerationModePolicyTest : public PolicyTest { | 4053 class HardwareAccelerationModePolicyTest : public PolicyTest { |
| 4064 public: | 4054 public: |
| 4065 HardwareAccelerationModePolicyTest() {} | 4055 HardwareAccelerationModePolicyTest() {} |
| 4066 | 4056 |
| 4067 void SetUpInProcessBrowserTestFixture() override { | 4057 void SetUpInProcessBrowserTestFixture() override { |
| 4068 PolicyTest::SetUpInProcessBrowserTestFixture(); | 4058 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 4069 PolicyMap policies; | 4059 PolicyMap policies; |
| 4070 policies.Set(key::kHardwareAccelerationModeEnabled, POLICY_LEVEL_MANDATORY, | 4060 policies.Set(key::kHardwareAccelerationModeEnabled, POLICY_LEVEL_MANDATORY, |
| 4071 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4061 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4072 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 4062 base::MakeUnique<base::Value>(false), nullptr); |
| 4073 provider_.UpdateChromePolicy(policies); | 4063 provider_.UpdateChromePolicy(policies); |
| 4074 } | 4064 } |
| 4075 }; | 4065 }; |
| 4076 | 4066 |
| 4077 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, | 4067 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, |
| 4078 HardwareAccelerationDisabled) { | 4068 HardwareAccelerationDisabled) { |
| 4079 // Verifies that hardware acceleration can be disabled with policy. | 4069 // Verifies that hardware acceleration can be disabled with policy. |
| 4080 EXPECT_FALSE( | 4070 EXPECT_FALSE( |
| 4081 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); | 4071 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); |
| 4082 } | 4072 } |
| 4083 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 4073 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 4084 | 4074 |
| 4085 #if defined(OS_CHROMEOS) | 4075 #if defined(OS_CHROMEOS) |
| 4086 // Policy is only available in ChromeOS | 4076 // Policy is only available in ChromeOS |
| 4087 IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) { | 4077 IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) { |
| 4088 // Verify that Unified Desktop can be enabled by policy | 4078 // Verify that Unified Desktop can be enabled by policy |
| 4089 display::DisplayManager* display_manager = | 4079 display::DisplayManager* display_manager = |
| 4090 ash::Shell::GetInstance()->display_manager(); | 4080 ash::Shell::GetInstance()->display_manager(); |
| 4091 | 4081 |
| 4092 // The policy description promises that Unified Desktop is not available | 4082 // The policy description promises that Unified Desktop is not available |
| 4093 // unless the policy is set (or a command line or an extension is used). If | 4083 // unless the policy is set (or a command line or an extension is used). If |
| 4094 // this default behaviour changes, please change the description at | 4084 // this default behaviour changes, please change the description at |
| 4095 // components/policy/resources/policy_templates.json. | 4085 // components/policy/resources/policy_templates.json. |
| 4096 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 4086 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 4097 // Now set the policy and check that unified desktop is turned on. | 4087 // Now set the policy and check that unified desktop is turned on. |
| 4098 PolicyMap policies; | 4088 PolicyMap policies; |
| 4099 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, | 4089 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, |
| 4100 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4090 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4101 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 4091 base::WrapUnique(new base::Value(true)), nullptr); |
| 4102 UpdateProviderPolicy(policies); | 4092 UpdateProviderPolicy(policies); |
| 4103 EXPECT_TRUE(display_manager->unified_desktop_enabled()); | 4093 EXPECT_TRUE(display_manager->unified_desktop_enabled()); |
| 4104 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, | 4094 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, |
| 4105 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4095 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4106 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 4096 base::WrapUnique(new base::Value(false)), nullptr); |
| 4107 UpdateProviderPolicy(policies); | 4097 UpdateProviderPolicy(policies); |
| 4108 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 4098 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 4109 } | 4099 } |
| 4110 | 4100 |
| 4111 class ArcPolicyTest : public PolicyTest { | 4101 class ArcPolicyTest : public PolicyTest { |
| 4112 public: | 4102 public: |
| 4113 ArcPolicyTest() {} | 4103 ArcPolicyTest() {} |
| 4114 ~ArcPolicyTest() override {} | 4104 ~ArcPolicyTest() override {} |
| 4115 | 4105 |
| 4116 protected: | 4106 protected: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4133 | 4123 |
| 4134 void SetUpCommandLine(base::CommandLine* command_line) override { | 4124 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 4135 PolicyTest::SetUpCommandLine(command_line); | 4125 PolicyTest::SetUpCommandLine(command_line); |
| 4136 arc::SetArcAvailableCommandLineForTesting(command_line); | 4126 arc::SetArcAvailableCommandLineForTesting(command_line); |
| 4137 } | 4127 } |
| 4138 | 4128 |
| 4139 void SetArcEnabledByPolicy(bool enabled) { | 4129 void SetArcEnabledByPolicy(bool enabled) { |
| 4140 PolicyMap policies; | 4130 PolicyMap policies; |
| 4141 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 4131 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 4142 POLICY_SOURCE_CLOUD, | 4132 POLICY_SOURCE_CLOUD, |
| 4143 base::WrapUnique(new base::FundamentalValue(enabled)), | 4133 base::WrapUnique(new base::Value(enabled)), nullptr); |
| 4144 nullptr); | |
| 4145 UpdateProviderPolicy(policies); | 4134 UpdateProviderPolicy(policies); |
| 4146 if (browser()) { | 4135 if (browser()) { |
| 4147 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 4136 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 4148 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); | 4137 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); |
| 4149 } | 4138 } |
| 4150 } | 4139 } |
| 4151 | 4140 |
| 4152 private: | 4141 private: |
| 4153 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); | 4142 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); |
| 4154 }; | 4143 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4180 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4169 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4181 | 4170 |
| 4182 // Switch on ARC Backup & Restore in the user prefs. | 4171 // Switch on ARC Backup & Restore in the user prefs. |
| 4183 pref->SetBoolean(prefs::kArcBackupRestoreEnabled, true); | 4172 pref->SetBoolean(prefs::kArcBackupRestoreEnabled, true); |
| 4184 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4173 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4185 | 4174 |
| 4186 // Disable ARC Backup & Restore through the policy. | 4175 // Disable ARC Backup & Restore through the policy. |
| 4187 PolicyMap policies; | 4176 PolicyMap policies; |
| 4188 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4177 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
| 4189 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4178 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4190 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 4179 base::MakeUnique<base::Value>(false), nullptr); |
| 4191 UpdateProviderPolicy(policies); | 4180 UpdateProviderPolicy(policies); |
| 4192 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4181 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4193 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4182 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4194 | 4183 |
| 4195 // Enable ARC Backup & Restore through the policy. | 4184 // Enable ARC Backup & Restore through the policy. |
| 4196 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4185 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
| 4197 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4186 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4198 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 4187 base::MakeUnique<base::Value>(true), nullptr); |
| 4199 UpdateProviderPolicy(policies); | 4188 UpdateProviderPolicy(policies); |
| 4200 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4189 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4201 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4190 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4202 } | 4191 } |
| 4203 | 4192 |
| 4204 // Test ArcLocationServiceEnabled policy and its interplay with the | 4193 // Test ArcLocationServiceEnabled policy and its interplay with the |
| 4205 // DefaultGeolocationSetting policy. | 4194 // DefaultGeolocationSetting policy. |
| 4206 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { | 4195 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { |
| 4207 PrefService* const pref = browser()->profile()->GetPrefs(); | 4196 PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4208 | 4197 |
| 4209 // Values of the ArcLocationServiceEnabled policy to be tested. | 4198 // Values of the ArcLocationServiceEnabled policy to be tested. |
| 4210 const std::vector<base::Value> test_policy_values = { | 4199 const std::vector<base::Value> test_policy_values = { |
| 4211 base::Value(), // unset | 4200 base::Value(), // unset |
| 4212 base::FundamentalValue(false), // disabled | 4201 base::Value(false), // disabled |
| 4213 base::FundamentalValue(true), // enabled | 4202 base::Value(true), // enabled |
| 4214 }; | 4203 }; |
| 4215 // Values of the DefaultGeolocationSetting policy to be tested. | 4204 // Values of the DefaultGeolocationSetting policy to be tested. |
| 4216 const std::vector<base::Value> test_default_geo_policy_values = { | 4205 const std::vector<base::Value> test_default_geo_policy_values = { |
| 4217 base::Value(), // unset | 4206 base::Value(), // unset |
| 4218 base::FundamentalValue(1), // 'AllowGeolocation' | 4207 base::Value(1), // 'AllowGeolocation' |
| 4219 base::FundamentalValue(2), // 'BlockGeolocation' | 4208 base::Value(2), // 'BlockGeolocation' |
| 4220 base::FundamentalValue(3), // 'AskGeolocation' | 4209 base::Value(3), // 'AskGeolocation' |
| 4221 }; | 4210 }; |
| 4222 | 4211 |
| 4223 // The pref is switched off by default. | 4212 // The pref is switched off by default. |
| 4224 EXPECT_FALSE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4213 EXPECT_FALSE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4225 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4214 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4226 | 4215 |
| 4227 // Switch on the pref in the user prefs. | 4216 // Switch on the pref in the user prefs. |
| 4228 pref->SetBoolean(prefs::kArcLocationServiceEnabled, true); | 4217 pref->SetBoolean(prefs::kArcLocationServiceEnabled, true); |
| 4229 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4218 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4230 | 4219 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4310 EXPECT_FALSE(local_state->IsManagedPreference( | 4299 EXPECT_FALSE(local_state->IsManagedPreference( |
| 4311 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4300 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4312 EXPECT_EQ(0, local_state->GetInteger( | 4301 EXPECT_EQ(0, local_state->GetInteger( |
| 4313 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4302 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4314 } | 4303 } |
| 4315 | 4304 |
| 4316 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { | 4305 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { |
| 4317 PolicyMap policies; | 4306 PolicyMap policies; |
| 4318 policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY, | 4307 policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY, |
| 4319 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 4308 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 4320 base::MakeUnique<base::FundamentalValue>(policy_value), | 4309 base::MakeUnique<base::Value>(policy_value), nullptr); |
| 4321 nullptr); | |
| 4322 UpdateProviderPolicy(policies); | 4310 UpdateProviderPolicy(policies); |
| 4323 | 4311 |
| 4324 PrefService* local_state = g_browser_process->local_state(); | 4312 PrefService* local_state = g_browser_process->local_state(); |
| 4325 | 4313 |
| 4326 EXPECT_TRUE(local_state->IsManagedPreference( | 4314 EXPECT_TRUE(local_state->IsManagedPreference( |
| 4327 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4315 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4328 EXPECT_EQ(policy_value, | 4316 EXPECT_EQ(policy_value, |
| 4329 local_state->GetInteger( | 4317 local_state->GetInteger( |
| 4330 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4318 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4331 } | 4319 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4413 | 4401 |
| 4414 SetEmptyPolicy(); | 4402 SetEmptyPolicy(); |
| 4415 // Policy not set. | 4403 // Policy not set. |
| 4416 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4404 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4417 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4405 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4418 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4406 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4419 } | 4407 } |
| 4420 #endif // defined(OS_CHROMEOS) | 4408 #endif // defined(OS_CHROMEOS) |
| 4421 | 4409 |
| 4422 } // namespace policy | 4410 } // namespace policy |
| OLD | NEW |