| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, | 646 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, |
| 647 make_scoped_refptr(BrowserThread::GetBlockingPool())), | 647 make_scoped_refptr(BrowserThread::GetBlockingPool())), |
| 648 base::MessageLoop::current()->QuitWhenIdleClosure()); | 648 base::MessageLoop::current()->QuitWhenIdleClosure()); |
| 649 content::RunMessageLoop(); | 649 content::RunMessageLoop(); |
| 650 } | 650 } |
| 651 | 651 |
| 652 void SetScreenshotPolicy(bool enabled) { | 652 void SetScreenshotPolicy(bool enabled) { |
| 653 PolicyMap policies; | 653 PolicyMap policies; |
| 654 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, | 654 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, |
| 655 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 655 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 656 base::MakeUnique<base::FundamentalValue>(!enabled), nullptr); | 656 base::MakeUnique<base::Value>(!enabled), nullptr); |
| 657 UpdateProviderPolicy(policies); | 657 UpdateProviderPolicy(policies); |
| 658 } | 658 } |
| 659 | 659 |
| 660 #if defined(OS_CHROMEOS) | 660 #if defined(OS_CHROMEOS) |
| 661 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { | 661 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { |
| 662 public: | 662 public: |
| 663 void OnScreenshotCompleted( | 663 void OnScreenshotCompleted( |
| 664 ScreenshotGrabberObserver::Result screenshot_result, | 664 ScreenshotGrabberObserver::Result screenshot_result, |
| 665 const base::FilePath& screenshot_path) override { | 665 const base::FilePath& screenshot_path) override { |
| 666 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, | 666 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 std::unique_ptr<base::Value> value) { | 801 std::unique_ptr<base::Value> value) { |
| 802 if (value) { | 802 if (value) { |
| 803 policies->Set(key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 803 policies->Set(key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 804 POLICY_SOURCE_CLOUD, std::move(value), nullptr); | 804 POLICY_SOURCE_CLOUD, std::move(value), nullptr); |
| 805 } else { | 805 } else { |
| 806 policies->Erase(key); | 806 policies->Erase(key); |
| 807 } | 807 } |
| 808 } | 808 } |
| 809 | 809 |
| 810 void ApplySafeSearchPolicy( | 810 void ApplySafeSearchPolicy( |
| 811 std::unique_ptr<base::FundamentalValue> legacy_safe_search, | 811 std::unique_ptr<base::Value> legacy_safe_search, |
| 812 std::unique_ptr<base::FundamentalValue> google_safe_search, | 812 std::unique_ptr<base::Value> google_safe_search, |
| 813 std::unique_ptr<base::FundamentalValue> legacy_youtube, | 813 std::unique_ptr<base::Value> legacy_youtube, |
| 814 std::unique_ptr<base::FundamentalValue> youtube_restrict) { | 814 std::unique_ptr<base::Value> youtube_restrict) { |
| 815 PolicyMap policies; | 815 PolicyMap policies; |
| 816 SetPolicy(&policies, key::kForceSafeSearch, std::move(legacy_safe_search)); | 816 SetPolicy(&policies, key::kForceSafeSearch, std::move(legacy_safe_search)); |
| 817 SetPolicy(&policies, key::kForceGoogleSafeSearch, | 817 SetPolicy(&policies, key::kForceGoogleSafeSearch, |
| 818 std::move(google_safe_search)); | 818 std::move(google_safe_search)); |
| 819 SetPolicy(&policies, key::kForceYouTubeSafetyMode, | 819 SetPolicy(&policies, key::kForceYouTubeSafetyMode, |
| 820 std::move(legacy_youtube)); | 820 std::move(legacy_youtube)); |
| 821 SetPolicy(&policies, key::kForceYouTubeRestrict, | 821 SetPolicy(&policies, key::kForceYouTubeRestrict, |
| 822 std::move(youtube_restrict)); | 822 std::move(youtube_restrict)); |
| 823 UpdateProviderPolicy(policies); | 823 UpdateProviderPolicy(policies); |
| 824 } | 824 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 896 |
| 897 // Test starts in about:blank. | 897 // Test starts in about:blank. |
| 898 PrefService* prefs = browser()->profile()->GetPrefs(); | 898 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 899 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 899 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 900 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 900 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 901 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 901 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 902 | 902 |
| 903 PolicyMap policies; | 903 PolicyMap policies; |
| 904 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 904 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 905 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 905 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 906 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 906 base::MakeUnique<base::Value>(true), nullptr); |
| 907 UpdateProviderPolicy(policies); | 907 UpdateProviderPolicy(policies); |
| 908 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 908 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 909 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 909 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 910 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 910 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 911 | 911 |
| 912 // The NTP has special handling of the bookmark bar. | 912 // The NTP has special handling of the bookmark bar. |
| 913 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 913 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 914 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 914 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 915 | 915 |
| 916 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 916 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 917 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 917 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 918 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 918 base::MakeUnique<base::Value>(false), nullptr); |
| 919 UpdateProviderPolicy(policies); | 919 UpdateProviderPolicy(policies); |
| 920 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 920 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 921 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 921 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 922 // The bookmark bar is hidden in the NTP when disabled by policy. | 922 // The bookmark bar is hidden in the NTP when disabled by policy. |
| 923 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 923 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 924 | 924 |
| 925 policies.Clear(); | 925 policies.Clear(); |
| 926 UpdateProviderPolicy(policies); | 926 UpdateProviderPolicy(policies); |
| 927 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 927 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 928 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 928 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 945 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); | 945 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); |
| 946 } | 946 } |
| 947 | 947 |
| 948 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { | 948 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { |
| 949 // Verify that the cookie persists across restarts. | 949 // Verify that the cookie persists across restarts. |
| 950 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); | 950 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); |
| 951 // Now set the policy and the cookie should be gone after another restart. | 951 // Now set the policy and the cookie should be gone after another restart. |
| 952 PolicyMap policies; | 952 PolicyMap policies; |
| 953 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, | 953 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, |
| 954 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 954 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 955 base::MakeUnique<base::FundamentalValue>(4), nullptr); | 955 base::MakeUnique<base::Value>(4), nullptr); |
| 956 UpdateProviderPolicy(policies); | 956 UpdateProviderPolicy(policies); |
| 957 } | 957 } |
| 958 | 958 |
| 959 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { | 959 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { |
| 960 // Verify that the cookie is gone. | 960 // Verify that the cookie is gone. |
| 961 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); | 961 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); |
| 962 } | 962 } |
| 963 | 963 |
| 964 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { | 964 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { |
| 965 MakeRequestFail make_request_fail("search.example"); | 965 MakeRequestFail make_request_fail("search.example"); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 993 default_search->search_terms_replacement_key() == | 993 default_search->search_terms_replacement_key() == |
| 994 kSearchTermsReplacementKey && | 994 kSearchTermsReplacementKey && |
| 995 default_search->image_url() == kImageURL && | 995 default_search->image_url() == kImageURL && |
| 996 default_search->image_url_post_params() == kImageURLPostParams && | 996 default_search->image_url_post_params() == kImageURLPostParams && |
| 997 default_search->new_tab_url() == kNewTabURL); | 997 default_search->new_tab_url() == kNewTabURL); |
| 998 | 998 |
| 999 // Override the default search provider using policies. | 999 // Override the default search provider using policies. |
| 1000 PolicyMap policies; | 1000 PolicyMap policies; |
| 1001 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 1001 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
| 1002 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1002 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1003 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1003 base::MakeUnique<base::Value>(true), nullptr); |
| 1004 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, | 1004 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, |
| 1005 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1005 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1006 base::MakeUnique<base::StringValue>(kKeyword), nullptr); | 1006 base::MakeUnique<base::StringValue>(kKeyword), nullptr); |
| 1007 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, | 1007 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, |
| 1008 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1008 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1009 base::MakeUnique<base::StringValue>(kSearchURL), nullptr); | 1009 base::MakeUnique<base::StringValue>(kSearchURL), nullptr); |
| 1010 policies.Set(key::kDefaultSearchProviderInstantURL, POLICY_LEVEL_MANDATORY, | 1010 policies.Set(key::kDefaultSearchProviderInstantURL, POLICY_LEVEL_MANDATORY, |
| 1011 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1011 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1012 base::MakeUnique<base::StringValue>(kInstantURL), nullptr); | 1012 base::MakeUnique<base::StringValue>(kInstantURL), nullptr); |
| 1013 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); | 1013 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1053 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); |
| 1054 content::WebContents* web_contents = | 1054 content::WebContents* web_contents = |
| 1055 browser()->tab_strip_model()->GetActiveWebContents(); | 1055 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1056 GURL expected("http://search.example/search?q=stuff+to+search+for"); | 1056 GURL expected("http://search.example/search?q=stuff+to+search+for"); |
| 1057 EXPECT_EQ(expected, web_contents->GetURL()); | 1057 EXPECT_EQ(expected, web_contents->GetURL()); |
| 1058 | 1058 |
| 1059 // Verify that searching from the omnibox can be disabled. | 1059 // Verify that searching from the omnibox can be disabled. |
| 1060 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1060 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 1061 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 1061 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
| 1062 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1062 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1063 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 1063 base::MakeUnique<base::Value>(false), nullptr); |
| 1064 EXPECT_TRUE(service->GetDefaultSearchProvider()); | 1064 EXPECT_TRUE(service->GetDefaultSearchProvider()); |
| 1065 UpdateProviderPolicy(policies); | 1065 UpdateProviderPolicy(policies); |
| 1066 EXPECT_FALSE(service->GetDefaultSearchProvider()); | 1066 EXPECT_FALSE(service->GetDefaultSearchProvider()); |
| 1067 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); | 1067 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); |
| 1068 // This means that submitting won't trigger any action. | 1068 // This means that submitting won't trigger any action. |
| 1069 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1069 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); |
| 1070 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); | 1070 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { | 1073 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { |
| 1074 // Add an individual proxy policy value. | 1074 // Add an individual proxy policy value. |
| 1075 PolicyMap policies; | 1075 PolicyMap policies; |
| 1076 policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1076 policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1077 POLICY_SOURCE_CLOUD, base::MakeUnique<base::FundamentalValue>(3), | 1077 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>(3), |
| 1078 nullptr); | 1078 nullptr); |
| 1079 UpdateProviderPolicy(policies); | 1079 UpdateProviderPolicy(policies); |
| 1080 | 1080 |
| 1081 // It should be removed and replaced with a dictionary. | 1081 // It should be removed and replaced with a dictionary. |
| 1082 PolicyMap expected; | 1082 PolicyMap expected; |
| 1083 std::unique_ptr<base::DictionaryValue> expected_value( | 1083 std::unique_ptr<base::DictionaryValue> expected_value( |
| 1084 new base::DictionaryValue); | 1084 new base::DictionaryValue); |
| 1085 expected_value->SetInteger(key::kProxyServerMode, 3); | 1085 expected_value->SetInteger(key::kProxyServerMode, 3); |
| 1086 expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1086 expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1087 POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); | 1087 POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1115 int val = i; | 1115 int val = i; |
| 1116 int legacy_safe_search = val % 3; val /= 3; | 1116 int legacy_safe_search = val % 3; val /= 3; |
| 1117 int google_safe_search = val % 3; val /= 3; | 1117 int google_safe_search = val % 3; val /= 3; |
| 1118 int legacy_youtube = val % 3; val /= 3; | 1118 int legacy_youtube = val % 3; val /= 3; |
| 1119 int youtube_restrict = val % num_restrict_modes; | 1119 int youtube_restrict = val % num_restrict_modes; |
| 1120 | 1120 |
| 1121 // Override the default SafeSearch setting using policies. | 1121 // Override the default SafeSearch setting using policies. |
| 1122 ApplySafeSearchPolicy( | 1122 ApplySafeSearchPolicy( |
| 1123 legacy_safe_search == 0 | 1123 legacy_safe_search == 0 |
| 1124 ? nullptr | 1124 ? nullptr |
| 1125 : base::MakeUnique<base::FundamentalValue>(legacy_safe_search == 1), | 1125 : base::MakeUnique<base::Value>(legacy_safe_search == 1), |
| 1126 google_safe_search == 0 | 1126 google_safe_search == 0 |
| 1127 ? nullptr | 1127 ? nullptr |
| 1128 : base::MakeUnique<base::FundamentalValue>(google_safe_search == 1), | 1128 : base::MakeUnique<base::Value>(google_safe_search == 1), |
| 1129 legacy_youtube == 0 | 1129 legacy_youtube == 0 |
| 1130 ? nullptr | 1130 ? nullptr |
| 1131 : base::MakeUnique<base::FundamentalValue>(legacy_youtube == 1), | 1131 : base::MakeUnique<base::Value>(legacy_youtube == 1), |
| 1132 youtube_restrict == 0 | 1132 youtube_restrict == 0 |
| 1133 ? nullptr // subtracting 1 gives 0,1,2, see above | 1133 ? nullptr // subtracting 1 gives 0,1,2, see above |
| 1134 : base::MakeUnique<base::FundamentalValue>(youtube_restrict - 1)); | 1134 : base::MakeUnique<base::Value>(youtube_restrict - 1)); |
| 1135 | 1135 |
| 1136 // The legacy ForceSafeSearch policy should only have an effect if none of | 1136 // The legacy ForceSafeSearch policy should only have an effect if none of |
| 1137 // the other 3 policies are defined. | 1137 // the other 3 policies are defined. |
| 1138 bool legacy_safe_search_in_effect = | 1138 bool legacy_safe_search_in_effect = |
| 1139 google_safe_search == 0 && legacy_youtube == 0 && | 1139 google_safe_search == 0 && legacy_youtube == 0 && |
| 1140 youtube_restrict == 0 && legacy_safe_search != 0; | 1140 youtube_restrict == 0 && legacy_safe_search != 0; |
| 1141 bool legacy_safe_search_enabled = | 1141 bool legacy_safe_search_enabled = |
| 1142 legacy_safe_search_in_effect && legacy_safe_search == 1; | 1142 legacy_safe_search_in_effect && legacy_safe_search == 1; |
| 1143 | 1143 |
| 1144 // Likewise, ForceYouTubeSafetyMode should only have an effect if | 1144 // Likewise, ForceYouTubeSafetyMode should only have an effect if |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 CheckSafeSearch(false); | 1191 CheckSafeSearch(false); |
| 1192 | 1192 |
| 1193 // Go over all combinations of (undefined, true, false) for the | 1193 // Go over all combinations of (undefined, true, false) for the |
| 1194 // ForceGoogleSafeSearch policy. | 1194 // ForceGoogleSafeSearch policy. |
| 1195 for (int safe_search = 0; safe_search < 3; safe_search++) { | 1195 for (int safe_search = 0; safe_search < 3; safe_search++) { |
| 1196 // Override the Google safe search policy. | 1196 // Override the Google safe search policy. |
| 1197 ApplySafeSearchPolicy( | 1197 ApplySafeSearchPolicy( |
| 1198 nullptr, // ForceSafeSearch | 1198 nullptr, // ForceSafeSearch |
| 1199 safe_search == 0 // ForceGoogleSafeSearch | 1199 safe_search == 0 // ForceGoogleSafeSearch |
| 1200 ? nullptr | 1200 ? nullptr |
| 1201 : base::MakeUnique<base::FundamentalValue>(safe_search == 1), | 1201 : base::MakeUnique<base::Value>(safe_search == 1), |
| 1202 nullptr, // ForceYouTubeSafetyMode | 1202 nullptr, // ForceYouTubeSafetyMode |
| 1203 nullptr // ForceYouTubeRestrict | 1203 nullptr // ForceYouTubeRestrict |
| 1204 ); | 1204 ); |
| 1205 | 1205 |
| 1206 // Verify that the safe search pref behaves the way we expect. | 1206 // Verify that the safe search pref behaves the way we expect. |
| 1207 PrefService* prefs = browser()->profile()->GetPrefs(); | 1207 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 1208 EXPECT_EQ(safe_search != 0, | 1208 EXPECT_EQ(safe_search != 0, |
| 1209 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); | 1209 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); |
| 1210 EXPECT_EQ(safe_search == 1, | 1210 EXPECT_EQ(safe_search == 1, |
| 1211 prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); | 1211 prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1222 | 1222 |
| 1223 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1223 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 1224 // WebGL is enabled by default. | 1224 // WebGL is enabled by default. |
| 1225 content::WebContents* contents = | 1225 content::WebContents* contents = |
| 1226 browser()->tab_strip_model()->GetActiveWebContents(); | 1226 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1227 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1227 EXPECT_TRUE(IsWebGLEnabled(contents)); |
| 1228 // Disable with a policy. | 1228 // Disable with a policy. |
| 1229 PolicyMap policies; | 1229 PolicyMap policies; |
| 1230 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1230 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1231 POLICY_SOURCE_CLOUD, | 1231 POLICY_SOURCE_CLOUD, |
| 1232 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1232 base::MakeUnique<base::Value>(true), nullptr); |
| 1233 UpdateProviderPolicy(policies); | 1233 UpdateProviderPolicy(policies); |
| 1234 // Crash and reload the tab to get a new renderer. | 1234 // Crash and reload the tab to get a new renderer. |
| 1235 content::CrashTab(contents); | 1235 content::CrashTab(contents); |
| 1236 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1236 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
| 1237 EXPECT_FALSE(IsWebGLEnabled(contents)); | 1237 EXPECT_FALSE(IsWebGLEnabled(contents)); |
| 1238 // Enable with a policy. | 1238 // Enable with a policy. |
| 1239 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1239 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1240 POLICY_SOURCE_CLOUD, | 1240 POLICY_SOURCE_CLOUD, |
| 1241 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 1241 base::MakeUnique<base::Value>(false), nullptr); |
| 1242 UpdateProviderPolicy(policies); | 1242 UpdateProviderPolicy(policies); |
| 1243 content::CrashTab(contents); | 1243 content::CrashTab(contents); |
| 1244 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1244 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
| 1245 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1245 EXPECT_TRUE(IsWebGLEnabled(contents)); |
| 1246 } | 1246 } |
| 1247 | 1247 |
| 1248 namespace { | 1248 namespace { |
| 1249 | 1249 |
| 1250 // The following helpers retrieve whether https:// URL stripping is | 1250 // The following helpers retrieve whether https:// URL stripping is |
| 1251 // enabled for PAC scripts. It needs to run on the IO thread. | 1251 // enabled for PAC scripts. It needs to run on the IO thread. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1272 // be disabled via a policy. Also verifies that stripping is enabled by | 1272 // be disabled via a policy. Also verifies that stripping is enabled by |
| 1273 // default. | 1273 // default. |
| 1274 IN_PROC_BROWSER_TEST_F(PolicyTest, DisablePacHttpsUrlStripping) { | 1274 IN_PROC_BROWSER_TEST_F(PolicyTest, DisablePacHttpsUrlStripping) { |
| 1275 // Stripping is enabled by default. | 1275 // Stripping is enabled by default. |
| 1276 EXPECT_TRUE(GetPacHttpsUrlStrippingEnabled()); | 1276 EXPECT_TRUE(GetPacHttpsUrlStrippingEnabled()); |
| 1277 | 1277 |
| 1278 // Disable it via a policy. | 1278 // Disable it via a policy. |
| 1279 PolicyMap policies; | 1279 PolicyMap policies; |
| 1280 policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY, | 1280 policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY, |
| 1281 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1281 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1282 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 1282 base::WrapUnique(new base::Value(false)), nullptr); |
| 1283 UpdateProviderPolicy(policies); | 1283 UpdateProviderPolicy(policies); |
| 1284 content::RunAllPendingInMessageLoop(); | 1284 content::RunAllPendingInMessageLoop(); |
| 1285 | 1285 |
| 1286 // It should now reflect as disabled. | 1286 // It should now reflect as disabled. |
| 1287 EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled()); | 1287 EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled()); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { | 1290 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { |
| 1291 // Verifies that access to the developer tools can be disabled. | 1291 // Verifies that access to the developer tools can be disabled. |
| 1292 | 1292 |
| 1293 // Open devtools. | 1293 // Open devtools. |
| 1294 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1294 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
| 1295 content::WebContents* contents = | 1295 content::WebContents* contents = |
| 1296 browser()->tab_strip_model()->GetActiveWebContents(); | 1296 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1297 DevToolsWindow* devtools_window = | 1297 DevToolsWindow* devtools_window = |
| 1298 DevToolsWindow::GetInstanceForInspectedWebContents(contents); | 1298 DevToolsWindow::GetInstanceForInspectedWebContents(contents); |
| 1299 EXPECT_TRUE(devtools_window); | 1299 EXPECT_TRUE(devtools_window); |
| 1300 | 1300 |
| 1301 // Disable devtools via policy. | 1301 // Disable devtools via policy. |
| 1302 PolicyMap policies; | 1302 PolicyMap policies; |
| 1303 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, | 1303 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, |
| 1304 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1304 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1305 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1305 base::MakeUnique<base::Value>(true), nullptr); |
| 1306 content::WindowedNotificationObserver close_observer( | 1306 content::WindowedNotificationObserver close_observer( |
| 1307 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1307 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1308 content::Source<content::WebContents>( | 1308 content::Source<content::WebContents>( |
| 1309 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); | 1309 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); |
| 1310 UpdateProviderPolicy(policies); | 1310 UpdateProviderPolicy(policies); |
| 1311 // wait for devtools close | 1311 // wait for devtools close |
| 1312 close_observer.Wait(); | 1312 close_observer.Wait(); |
| 1313 // The existing devtools window should have closed. | 1313 // The existing devtools window should have closed. |
| 1314 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); | 1314 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); |
| 1315 // And it's not possible to open it again. | 1315 // And it's not possible to open it again. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1333 #endif | 1333 #endif |
| 1334 | 1334 |
| 1335 // The next NTP has no footer. | 1335 // The next NTP has no footer. |
| 1336 if (ContainsVisibleElement(contents, "footer")) | 1336 if (ContainsVisibleElement(contents, "footer")) |
| 1337 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1337 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
| 1338 | 1338 |
| 1339 // Turn off the web store icons. | 1339 // Turn off the web store icons. |
| 1340 PolicyMap policies; | 1340 PolicyMap policies; |
| 1341 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY, | 1341 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY, |
| 1342 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1342 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1343 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 1343 base::WrapUnique(new base::Value(true)), nullptr); |
| 1344 UpdateProviderPolicy(policies); | 1344 UpdateProviderPolicy(policies); |
| 1345 | 1345 |
| 1346 // The web store icons should now be hidden. | 1346 // The web store icons should now be hidden. |
| 1347 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1347 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 1348 EXPECT_FALSE(ContainsVisibleElement(contents, | 1348 EXPECT_FALSE(ContainsVisibleElement(contents, |
| 1349 "ahfgeienlihckogmohjhadlkjgocpleb")); | 1349 "ahfgeienlihckogmohjhadlkjgocpleb")); |
| 1350 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); | 1350 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { | 1353 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1987 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1988 base::MakeUnique<base::StringValue>(chrome::kChromeUICreditsURL), | 1988 base::MakeUnique<base::StringValue>(chrome::kChromeUICreditsURL), |
| 1989 nullptr); | 1989 nullptr); |
| 1990 UpdateProviderPolicy(policies); | 1990 UpdateProviderPolicy(policies); |
| 1991 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1991 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 1992 content::WaitForLoadStop(contents); | 1992 content::WaitForLoadStop(contents); |
| 1993 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); | 1993 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); |
| 1994 | 1994 |
| 1995 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, | 1995 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, |
| 1996 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1996 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1997 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 1997 base::MakeUnique<base::Value>(true), nullptr); |
| 1998 UpdateProviderPolicy(policies); | 1998 UpdateProviderPolicy(policies); |
| 1999 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1999 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 2000 content::WaitForLoadStop(contents); | 2000 content::WaitForLoadStop(contents); |
| 2001 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); | 2001 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); |
| 2002 } | 2002 } |
| 2003 | 2003 |
| 2004 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { | 2004 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
| 2005 // Verifies that incognito windows can't be opened when disabled by policy. | 2005 // Verifies that incognito windows can't be opened when disabled by policy. |
| 2006 | 2006 |
| 2007 const BrowserList* active_browser_list = BrowserList::GetInstance(); | 2007 const BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 2008 | 2008 |
| 2009 // Disable incognito via policy and verify that incognito windows can't be | 2009 // Disable incognito via policy and verify that incognito windows can't be |
| 2010 // opened. | 2010 // opened. |
| 2011 EXPECT_EQ(1u, active_browser_list->size()); | 2011 EXPECT_EQ(1u, active_browser_list->size()); |
| 2012 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); | 2012 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); |
| 2013 PolicyMap policies; | 2013 PolicyMap policies; |
| 2014 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 2014 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
| 2015 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2015 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2016 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2016 base::MakeUnique<base::Value>(false), nullptr); |
| 2017 UpdateProviderPolicy(policies); | 2017 UpdateProviderPolicy(policies); |
| 2018 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2018 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 2019 EXPECT_EQ(1u, active_browser_list->size()); | 2019 EXPECT_EQ(1u, active_browser_list->size()); |
| 2020 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); | 2020 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); |
| 2021 | 2021 |
| 2022 // Enable via policy and verify that incognito windows can be opened. | 2022 // Enable via policy and verify that incognito windows can be opened. |
| 2023 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 2023 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
| 2024 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2024 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2025 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2025 base::MakeUnique<base::Value>(true), nullptr); |
| 2026 UpdateProviderPolicy(policies); | 2026 UpdateProviderPolicy(policies); |
| 2027 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2027 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 2028 EXPECT_EQ(2u, active_browser_list->size()); | 2028 EXPECT_EQ(2u, active_browser_list->size()); |
| 2029 EXPECT_TRUE(BrowserList::IsIncognitoSessionActive()); | 2029 EXPECT_TRUE(BrowserList::IsIncognitoSessionActive()); |
| 2030 } | 2030 } |
| 2031 | 2031 |
| 2032 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 2032 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
| 2033 // Verifies that Javascript can be disabled. | 2033 // Verifies that Javascript can be disabled. |
| 2034 content::WebContents* contents = | 2034 content::WebContents* contents = |
| 2035 browser()->tab_strip_model()->GetActiveWebContents(); | 2035 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2036 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2036 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2037 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2037 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
| 2038 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2038 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
| 2039 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2039 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
| 2040 | 2040 |
| 2041 // Disable Javascript via policy. | 2041 // Disable Javascript via policy. |
| 2042 PolicyMap policies; | 2042 PolicyMap policies; |
| 2043 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, | 2043 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, |
| 2044 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2044 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2045 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2045 base::MakeUnique<base::Value>(false), nullptr); |
| 2046 UpdateProviderPolicy(policies); | 2046 UpdateProviderPolicy(policies); |
| 2047 // Reload the page. | 2047 // Reload the page. |
| 2048 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2048 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2049 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2049 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
| 2050 // Developer tools still work when javascript is disabled. | 2050 // Developer tools still work when javascript is disabled. |
| 2051 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2051 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
| 2052 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2052 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
| 2053 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2053 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
| 2054 // Javascript is always enabled for the internal pages. | 2054 // Javascript is always enabled for the internal pages. |
| 2055 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 2055 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 2056 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2056 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2057 | 2057 |
| 2058 // The javascript content setting policy overrides the javascript policy. | 2058 // The javascript content setting policy overrides the javascript policy. |
| 2059 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2059 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2060 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2060 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
| 2061 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, | 2061 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, |
| 2062 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2062 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2063 base::MakeUnique<base::FundamentalValue>(CONTENT_SETTING_ALLOW), | 2063 base::MakeUnique<base::Value>(CONTENT_SETTING_ALLOW), |
| 2064 nullptr); | 2064 nullptr); |
| 2065 UpdateProviderPolicy(policies); | 2065 UpdateProviderPolicy(policies); |
| 2066 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2066 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2067 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2067 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2068 } | 2068 } |
| 2069 | 2069 |
| 2070 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { | 2070 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { |
| 2071 PrefService* prefs = browser()->profile()->GetPrefs(); | 2071 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2072 | 2072 |
| 2073 // Enabled by default. | 2073 // Enabled by default. |
| 2074 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2074 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
| 2075 | 2075 |
| 2076 // Disable by old, deprecated policy. | 2076 // Disable by old, deprecated policy. |
| 2077 PolicyMap policies; | 2077 PolicyMap policies; |
| 2078 policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY, | 2078 policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY, |
| 2079 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2079 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2080 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2080 base::MakeUnique<base::Value>(false), nullptr); |
| 2081 UpdateProviderPolicy(policies); | 2081 UpdateProviderPolicy(policies); |
| 2082 | 2082 |
| 2083 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); | 2083 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); |
| 2084 | 2084 |
| 2085 // Enabled by new policy, this should override old one. | 2085 // Enabled by new policy, this should override old one. |
| 2086 policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY, | 2086 policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY, |
| 2087 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2087 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2088 base::MakeUnique<base::FundamentalValue>( | 2088 base::MakeUnique<base::Value>( |
| 2089 chrome_browser_net::NETWORK_PREDICTION_ALWAYS), | 2089 chrome_browser_net::NETWORK_PREDICTION_ALWAYS), |
| 2090 nullptr); | 2090 nullptr); |
| 2091 UpdateProviderPolicy(policies); | 2091 UpdateProviderPolicy(policies); |
| 2092 | 2092 |
| 2093 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2093 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
| 2094 } | 2094 } |
| 2095 | 2095 |
| 2096 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { | 2096 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { |
| 2097 // Verifies that browsing history is not saved. | 2097 // Verifies that browsing history is not saved. |
| 2098 PolicyMap policies; | 2098 PolicyMap policies; |
| 2099 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, | 2099 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
| 2100 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2100 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2101 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2101 base::MakeUnique<base::Value>(true), nullptr); |
| 2102 UpdateProviderPolicy(policies); | 2102 UpdateProviderPolicy(policies); |
| 2103 GURL url = ui_test_utils::GetTestUrl( | 2103 GURL url = ui_test_utils::GetTestUrl( |
| 2104 base::FilePath(base::FilePath::kCurrentDirectory), | 2104 base::FilePath(base::FilePath::kCurrentDirectory), |
| 2105 base::FilePath(FILE_PATH_LITERAL("empty.html"))); | 2105 base::FilePath(FILE_PATH_LITERAL("empty.html"))); |
| 2106 ui_test_utils::NavigateToURL(browser(), url); | 2106 ui_test_utils::NavigateToURL(browser(), url); |
| 2107 // Verify that the navigation wasn't saved in the history. | 2107 // Verify that the navigation wasn't saved in the history. |
| 2108 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); | 2108 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); |
| 2109 EXPECT_EQ(0u, enumerator1.urls().size()); | 2109 EXPECT_EQ(0u, enumerator1.urls().size()); |
| 2110 | 2110 |
| 2111 // Now flip the policy and try again. | 2111 // Now flip the policy and try again. |
| 2112 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, | 2112 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
| 2113 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2113 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2114 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2114 base::MakeUnique<base::Value>(false), nullptr); |
| 2115 UpdateProviderPolicy(policies); | 2115 UpdateProviderPolicy(policies); |
| 2116 ui_test_utils::NavigateToURL(browser(), url); | 2116 ui_test_utils::NavigateToURL(browser(), url); |
| 2117 // Verify that the navigation was saved in the history. | 2117 // Verify that the navigation was saved in the history. |
| 2118 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); | 2118 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); |
| 2119 ASSERT_EQ(1u, enumerator2.urls().size()); | 2119 ASSERT_EQ(1u, enumerator2.urls().size()); |
| 2120 EXPECT_EQ(url, enumerator2.urls()[0]); | 2120 EXPECT_EQ(url, enumerator2.urls()[0]); |
| 2121 } | 2121 } |
| 2122 | 2122 |
| 2123 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 | 2123 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 |
| 2124 #if !defined(USE_AURA) | 2124 #if !defined(USE_AURA) |
| 2125 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. | 2125 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. |
| 2126 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { | 2126 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { |
| 2127 // Verifies that translate can be forced enabled or disabled by policy. | 2127 // Verifies that translate can be forced enabled or disabled by policy. |
| 2128 | 2128 |
| 2129 // Get the InfoBarService, and verify that there are no infobars on startup. | 2129 // Get the InfoBarService, and verify that there are no infobars on startup. |
| 2130 content::WebContents* contents = | 2130 content::WebContents* contents = |
| 2131 browser()->tab_strip_model()->GetActiveWebContents(); | 2131 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2132 ASSERT_TRUE(contents); | 2132 ASSERT_TRUE(contents); |
| 2133 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); | 2133 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); |
| 2134 ASSERT_TRUE(infobar_service); | 2134 ASSERT_TRUE(infobar_service); |
| 2135 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2135 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 2136 | 2136 |
| 2137 // Force enable the translate feature. | 2137 // Force enable the translate feature. |
| 2138 PolicyMap policies; | 2138 PolicyMap policies; |
| 2139 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, | 2139 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, |
| 2140 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2140 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2141 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2141 base::WrapUnique(new base::Value(true)), nullptr); |
| 2142 UpdateProviderPolicy(policies); | 2142 UpdateProviderPolicy(policies); |
| 2143 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test | 2143 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test |
| 2144 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the | 2144 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the |
| 2145 // TranslateManager observes. This allows checking that an infobar is NOT | 2145 // TranslateManager observes. This allows checking that an infobar is NOT |
| 2146 // shown below, without polling for infobars for some indeterminate amount | 2146 // shown below, without polling for infobars for some indeterminate amount |
| 2147 // of time. | 2147 // of time. |
| 2148 GURL url = ui_test_utils::GetTestUrl( | 2148 GURL url = ui_test_utils::GetTestUrl( |
| 2149 base::FilePath(), | 2149 base::FilePath(), |
| 2150 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html"))); | 2150 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html"))); |
| 2151 content::WindowedNotificationObserver language_observer1( | 2151 content::WindowedNotificationObserver language_observer1( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2174 ASSERT_TRUE(translate_infobar_delegate); | 2174 ASSERT_TRUE(translate_infobar_delegate); |
| 2175 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 2175 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
| 2176 translate_infobar_delegate->translate_step()); | 2176 translate_infobar_delegate->translate_step()); |
| 2177 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); | 2177 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); |
| 2178 | 2178 |
| 2179 // Now force disable translate. | 2179 // Now force disable translate. |
| 2180 infobar_service->RemoveInfoBar(infobar); | 2180 infobar_service->RemoveInfoBar(infobar); |
| 2181 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2181 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 2182 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, | 2182 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, |
| 2183 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2183 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2184 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2184 base::WrapUnique(new base::Value(false)), nullptr); |
| 2185 UpdateProviderPolicy(policies); | 2185 UpdateProviderPolicy(policies); |
| 2186 // Navigating to the same URL now doesn't trigger an infobar. | 2186 // Navigating to the same URL now doesn't trigger an infobar. |
| 2187 content::WindowedNotificationObserver language_observer2( | 2187 content::WindowedNotificationObserver language_observer2( |
| 2188 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 2188 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 2189 content::NotificationService::AllSources()); | 2189 content::NotificationService::AllSources()); |
| 2190 ui_test_utils::NavigateToURL(browser(), url); | 2190 ui_test_utils::NavigateToURL(browser(), url); |
| 2191 language_observer2.Wait(); | 2191 language_observer2.Wait(); |
| 2192 EXPECT_EQ(0u, infobar_service->infobar_count()); | 2192 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 2193 } | 2193 } |
| 2194 #endif // !defined(USE_AURA) | 2194 #endif // !defined(USE_AURA) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2359 | 2359 |
| 2360 CheckCanOpenURL(browser(), file_path1.c_str()); | 2360 CheckCanOpenURL(browser(), file_path1.c_str()); |
| 2361 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2361 CheckURLIsBlocked(browser(), file_path2.c_str()); |
| 2362 } | 2362 } |
| 2363 | 2363 |
| 2364 #if !defined(OS_MACOSX) | 2364 #if !defined(OS_MACOSX) |
| 2365 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { | 2365 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { |
| 2366 PolicyMap policies; | 2366 PolicyMap policies; |
| 2367 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, | 2367 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
| 2368 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2368 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2369 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2369 base::MakeUnique<base::Value>(false), nullptr); |
| 2370 UpdateProviderPolicy(policies); | 2370 UpdateProviderPolicy(policies); |
| 2371 | 2371 |
| 2372 BrowserWindow* browser_window = browser()->window(); | 2372 BrowserWindow* browser_window = browser()->window(); |
| 2373 ASSERT_TRUE(browser_window); | 2373 ASSERT_TRUE(browser_window); |
| 2374 | 2374 |
| 2375 EXPECT_FALSE(browser_window->IsFullscreen()); | 2375 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 2376 chrome::ToggleFullscreenMode(browser()); | 2376 chrome::ToggleFullscreenMode(browser()); |
| 2377 EXPECT_FALSE(browser_window->IsFullscreen()); | 2377 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 2378 } | 2378 } |
| 2379 | 2379 |
| 2380 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { | 2380 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { |
| 2381 PolicyMap policies; | 2381 PolicyMap policies; |
| 2382 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, | 2382 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
| 2383 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2383 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2384 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2384 base::MakeUnique<base::Value>(false), nullptr); |
| 2385 UpdateProviderPolicy(policies); | 2385 UpdateProviderPolicy(policies); |
| 2386 | 2386 |
| 2387 const extensions::Extension* extension = | 2387 const extensions::Extension* extension = |
| 2388 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); | 2388 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); |
| 2389 ASSERT_TRUE(extension); | 2389 ASSERT_TRUE(extension); |
| 2390 | 2390 |
| 2391 // Launch an app that tries to open a fullscreen window. | 2391 // Launch an app that tries to open a fullscreen window. |
| 2392 TestAddAppWindowObserver add_window_observer( | 2392 TestAddAppWindowObserver add_window_observer( |
| 2393 extensions::AppWindowRegistry::Get(browser()->profile())); | 2393 extensions::AppWindowRegistry::Get(browser()->profile())); |
| 2394 OpenApplication(AppLaunchParams( | 2394 OpenApplication(AppLaunchParams( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2442 | 2442 |
| 2443 bool prior_state = audio_handler->IsOutputMuted(); | 2443 bool prior_state = audio_handler->IsOutputMuted(); |
| 2444 // Make sure the audio is not muted and then toggle the policy and observe | 2444 // Make sure the audio is not muted and then toggle the policy and observe |
| 2445 // if the output mute changed event is fired. | 2445 // if the output mute changed event is fired. |
| 2446 audio_handler->SetOutputMute(false); | 2446 audio_handler->SetOutputMute(false); |
| 2447 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2447 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 2448 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2448 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2449 PolicyMap policies; | 2449 PolicyMap policies; |
| 2450 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, | 2450 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
| 2451 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2451 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2452 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2452 base::MakeUnique<base::Value>(false), nullptr); |
| 2453 UpdateProviderPolicy(policies); | 2453 UpdateProviderPolicy(policies); |
| 2454 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2454 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2455 // This should not change the state now and should not trigger output mute | 2455 // This should not change the state now and should not trigger output mute |
| 2456 // changed event. | 2456 // changed event. |
| 2457 audio_handler->SetOutputMute(false); | 2457 audio_handler->SetOutputMute(false); |
| 2458 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2458 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2459 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2459 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2460 | 2460 |
| 2461 // Toggle back and observe if the output mute changed event is fired. | 2461 // Toggle back and observe if the output mute changed event is fired. |
| 2462 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, | 2462 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
| 2463 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2463 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2464 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2464 base::MakeUnique<base::Value>(true), nullptr); |
| 2465 UpdateProviderPolicy(policies); | 2465 UpdateProviderPolicy(policies); |
| 2466 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2466 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 2467 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2467 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2468 audio_handler->SetOutputMute(true); | 2468 audio_handler->SetOutputMute(true); |
| 2469 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2469 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2470 EXPECT_EQ(2, test_observer->output_mute_changed_count()); | 2470 EXPECT_EQ(2, test_observer->output_mute_changed_count()); |
| 2471 // Revert the prior state. | 2471 // Revert the prior state. |
| 2472 audio_handler->SetOutputMute(prior_state); | 2472 audio_handler->SetOutputMute(prior_state); |
| 2473 audio_handler->RemoveAudioObserver(test_observer.get()); | 2473 audio_handler->RemoveAudioObserver(test_observer.get()); |
| 2474 } | 2474 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2489 chrome::NOTIFICATION_APP_TERMINATING, | 2489 chrome::NOTIFICATION_APP_TERMINATING, |
| 2490 content::NotificationService::AllSources()); | 2490 content::NotificationService::AllSources()); |
| 2491 | 2491 |
| 2492 // Set the session length limit to 3 hours. Verify that the session is not | 2492 // Set the session length limit to 3 hours. Verify that the session is not |
| 2493 // terminated. | 2493 // terminated. |
| 2494 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2494 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2495 .Times(0); | 2495 .Times(0); |
| 2496 PolicyMap policies; | 2496 PolicyMap policies; |
| 2497 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2497 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2498 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2498 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2499 base::MakeUnique<base::FundamentalValue>(kThreeHoursInMs), | 2499 base::MakeUnique<base::Value>(kThreeHoursInMs), |
| 2500 nullptr); | 2500 nullptr); |
| 2501 UpdateProviderPolicy(policies); | 2501 UpdateProviderPolicy(policies); |
| 2502 base::RunLoop().RunUntilIdle(); | 2502 base::RunLoop().RunUntilIdle(); |
| 2503 Mock::VerifyAndClearExpectations(&observer); | 2503 Mock::VerifyAndClearExpectations(&observer); |
| 2504 | 2504 |
| 2505 // Decrease the session length limit to 1 hour. Verify that the session is | 2505 // Decrease the session length limit to 1 hour. Verify that the session is |
| 2506 // terminated immediately. | 2506 // terminated immediately. |
| 2507 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2507 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
| 2508 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2508 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2509 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2509 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2510 base::MakeUnique<base::FundamentalValue>(kOneHourInMs), nullptr); | 2510 base::MakeUnique<base::Value>(kOneHourInMs), nullptr); |
| 2511 UpdateProviderPolicy(policies); | 2511 UpdateProviderPolicy(policies); |
| 2512 base::RunLoop().RunUntilIdle(); | 2512 base::RunLoop().RunUntilIdle(); |
| 2513 Mock::VerifyAndClearExpectations(&observer); | 2513 Mock::VerifyAndClearExpectations(&observer); |
| 2514 } | 2514 } |
| 2515 | 2515 |
| 2516 // Disabled, see http://crbug.com/554728. | 2516 // Disabled, see http://crbug.com/554728. |
| 2517 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2517 IN_PROC_BROWSER_TEST_F(PolicyTest, |
| 2518 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { | 2518 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { |
| 2519 // Indicate that the session started 2 hours ago and no user activity has | 2519 // Indicate that the session started 2 hours ago and no user activity has |
| 2520 // occurred yet. | 2520 // occurred yet. |
| 2521 g_browser_process->local_state()->SetInt64( | 2521 g_browser_process->local_state()->SetInt64( |
| 2522 prefs::kSessionStartTime, | 2522 prefs::kSessionStartTime, |
| 2523 (base::TimeTicks::Now() - base::TimeDelta::FromHours(2)) | 2523 (base::TimeTicks::Now() - base::TimeDelta::FromHours(2)) |
| 2524 .ToInternalValue()); | 2524 .ToInternalValue()); |
| 2525 } | 2525 } |
| 2526 | 2526 |
| 2527 // Disabled, see http://crbug.com/554728. | 2527 // Disabled, see http://crbug.com/554728. |
| 2528 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2528 IN_PROC_BROWSER_TEST_F(PolicyTest, |
| 2529 DISABLED_WaitForInitialUserActivityUnsatisfied) { | 2529 DISABLED_WaitForInitialUserActivityUnsatisfied) { |
| 2530 content::MockNotificationObserver observer; | 2530 content::MockNotificationObserver observer; |
| 2531 content::NotificationRegistrar registrar; | 2531 content::NotificationRegistrar registrar; |
| 2532 registrar.Add(&observer, | 2532 registrar.Add(&observer, |
| 2533 chrome::NOTIFICATION_APP_TERMINATING, | 2533 chrome::NOTIFICATION_APP_TERMINATING, |
| 2534 content::NotificationService::AllSources()); | 2534 content::NotificationService::AllSources()); |
| 2535 | 2535 |
| 2536 // Require initial user activity. | 2536 // Require initial user activity. |
| 2537 PolicyMap policies; | 2537 PolicyMap policies; |
| 2538 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2538 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
| 2539 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2539 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2540 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2540 base::WrapUnique(new base::Value(true)), nullptr); |
| 2541 UpdateProviderPolicy(policies); | 2541 UpdateProviderPolicy(policies); |
| 2542 base::RunLoop().RunUntilIdle(); | 2542 base::RunLoop().RunUntilIdle(); |
| 2543 | 2543 |
| 2544 // Set the session length limit to 1 hour. Verify that the session is not | 2544 // Set the session length limit to 1 hour. Verify that the session is not |
| 2545 // terminated. | 2545 // terminated. |
| 2546 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2546 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2547 .Times(0); | 2547 .Times(0); |
| 2548 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2548 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2549 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2549 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2550 base::WrapUnique(new base::FundamentalValue(kOneHourInMs)), | 2550 base::WrapUnique(new base::Value(kOneHourInMs)), |
| 2551 nullptr); | 2551 nullptr); |
| 2552 UpdateProviderPolicy(policies); | 2552 UpdateProviderPolicy(policies); |
| 2553 base::RunLoop().RunUntilIdle(); | 2553 base::RunLoop().RunUntilIdle(); |
| 2554 Mock::VerifyAndClearExpectations(&observer); | 2554 Mock::VerifyAndClearExpectations(&observer); |
| 2555 } | 2555 } |
| 2556 | 2556 |
| 2557 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2557 IN_PROC_BROWSER_TEST_F(PolicyTest, |
| 2558 PRE_WaitForInitialUserActivitySatisfied) { | 2558 PRE_WaitForInitialUserActivitySatisfied) { |
| 2559 // Indicate that initial user activity in this session occurred 2 hours ago. | 2559 // Indicate that initial user activity in this session occurred 2 hours ago. |
| 2560 g_browser_process->local_state()->SetInt64( | 2560 g_browser_process->local_state()->SetInt64( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2574 chrome::NOTIFICATION_APP_TERMINATING, | 2574 chrome::NOTIFICATION_APP_TERMINATING, |
| 2575 content::NotificationService::AllSources()); | 2575 content::NotificationService::AllSources()); |
| 2576 | 2576 |
| 2577 // Require initial user activity and set the session length limit to 3 hours. | 2577 // Require initial user activity and set the session length limit to 3 hours. |
| 2578 // Verify that the session is not terminated. | 2578 // Verify that the session is not terminated. |
| 2579 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2579 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2580 .Times(0); | 2580 .Times(0); |
| 2581 PolicyMap policies; | 2581 PolicyMap policies; |
| 2582 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2582 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
| 2583 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2583 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2584 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2584 base::MakeUnique<base::Value>(true), nullptr); |
| 2585 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2585 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2586 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2586 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2587 base::MakeUnique<base::FundamentalValue>(kThreeHoursInMs), | 2587 base::MakeUnique<base::Value>(kThreeHoursInMs), |
| 2588 nullptr); | 2588 nullptr); |
| 2589 UpdateProviderPolicy(policies); | 2589 UpdateProviderPolicy(policies); |
| 2590 base::RunLoop().RunUntilIdle(); | 2590 base::RunLoop().RunUntilIdle(); |
| 2591 Mock::VerifyAndClearExpectations(&observer); | 2591 Mock::VerifyAndClearExpectations(&observer); |
| 2592 | 2592 |
| 2593 // Decrease the session length limit to 1 hour. Verify that the session is | 2593 // Decrease the session length limit to 1 hour. Verify that the session is |
| 2594 // terminated immediately. | 2594 // terminated immediately. |
| 2595 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2595 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
| 2596 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2596 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2597 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2597 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2598 base::MakeUnique<base::FundamentalValue>(kOneHourInMs), nullptr); | 2598 base::MakeUnique<base::Value>(kOneHourInMs), nullptr); |
| 2599 UpdateProviderPolicy(policies); | 2599 UpdateProviderPolicy(policies); |
| 2600 base::RunLoop().RunUntilIdle(); | 2600 base::RunLoop().RunUntilIdle(); |
| 2601 Mock::VerifyAndClearExpectations(&observer); | 2601 Mock::VerifyAndClearExpectations(&observer); |
| 2602 } | 2602 } |
| 2603 | 2603 |
| 2604 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { | 2604 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { |
| 2605 // Verifies that the large cursor accessibility feature can be controlled | 2605 // Verifies that the large cursor accessibility feature can be controlled |
| 2606 // through policy. | 2606 // through policy. |
| 2607 chromeos::AccessibilityManager* accessibility_manager = | 2607 chromeos::AccessibilityManager* accessibility_manager = |
| 2608 chromeos::AccessibilityManager::Get(); | 2608 chromeos::AccessibilityManager::Get(); |
| 2609 | 2609 |
| 2610 // Manually enable the large cursor. | 2610 // Manually enable the large cursor. |
| 2611 accessibility_manager->EnableLargeCursor(true); | 2611 accessibility_manager->EnableLargeCursor(true); |
| 2612 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); | 2612 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); |
| 2613 | 2613 |
| 2614 // Verify that policy overrides the manual setting. | 2614 // Verify that policy overrides the manual setting. |
| 2615 PolicyMap policies; | 2615 PolicyMap policies; |
| 2616 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, | 2616 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, |
| 2617 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2617 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2618 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2618 base::MakeUnique<base::Value>(false), nullptr); |
| 2619 UpdateProviderPolicy(policies); | 2619 UpdateProviderPolicy(policies); |
| 2620 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2620 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
| 2621 | 2621 |
| 2622 // Verify that the large cursor cannot be enabled manually anymore. | 2622 // Verify that the large cursor cannot be enabled manually anymore. |
| 2623 accessibility_manager->EnableLargeCursor(true); | 2623 accessibility_manager->EnableLargeCursor(true); |
| 2624 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2624 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
| 2625 } | 2625 } |
| 2626 | 2626 |
| 2627 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { | 2627 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { |
| 2628 // Verifies that the spoken feedback accessibility feature can be controlled | 2628 // Verifies that the spoken feedback accessibility feature can be controlled |
| 2629 // through policy. | 2629 // through policy. |
| 2630 chromeos::AccessibilityManager* accessibility_manager = | 2630 chromeos::AccessibilityManager* accessibility_manager = |
| 2631 chromeos::AccessibilityManager::Get(); | 2631 chromeos::AccessibilityManager::Get(); |
| 2632 | 2632 |
| 2633 // Manually enable spoken feedback. | 2633 // Manually enable spoken feedback. |
| 2634 accessibility_manager->EnableSpokenFeedback(true, | 2634 accessibility_manager->EnableSpokenFeedback(true, |
| 2635 ash::A11Y_NOTIFICATION_NONE); | 2635 ash::A11Y_NOTIFICATION_NONE); |
| 2636 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2636 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2637 | 2637 |
| 2638 // Verify that policy overrides the manual setting. | 2638 // Verify that policy overrides the manual setting. |
| 2639 PolicyMap policies; | 2639 PolicyMap policies; |
| 2640 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, | 2640 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, |
| 2641 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2641 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2642 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2642 base::MakeUnique<base::Value>(false), nullptr); |
| 2643 UpdateProviderPolicy(policies); | 2643 UpdateProviderPolicy(policies); |
| 2644 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2644 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2645 | 2645 |
| 2646 // Verify that spoken feedback cannot be enabled manually anymore. | 2646 // Verify that spoken feedback cannot be enabled manually anymore. |
| 2647 accessibility_manager->EnableSpokenFeedback(true, | 2647 accessibility_manager->EnableSpokenFeedback(true, |
| 2648 ash::A11Y_NOTIFICATION_NONE); | 2648 ash::A11Y_NOTIFICATION_NONE); |
| 2649 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2649 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2650 } | 2650 } |
| 2651 | 2651 |
| 2652 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { | 2652 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { |
| 2653 // Verifies that the high contrast mode accessibility feature can be | 2653 // Verifies that the high contrast mode accessibility feature can be |
| 2654 // controlled through policy. | 2654 // controlled through policy. |
| 2655 chromeos::AccessibilityManager* accessibility_manager = | 2655 chromeos::AccessibilityManager* accessibility_manager = |
| 2656 chromeos::AccessibilityManager::Get(); | 2656 chromeos::AccessibilityManager::Get(); |
| 2657 | 2657 |
| 2658 // Manually enable high contrast mode. | 2658 // Manually enable high contrast mode. |
| 2659 accessibility_manager->EnableHighContrast(true); | 2659 accessibility_manager->EnableHighContrast(true); |
| 2660 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); | 2660 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); |
| 2661 | 2661 |
| 2662 // Verify that policy overrides the manual setting. | 2662 // Verify that policy overrides the manual setting. |
| 2663 PolicyMap policies; | 2663 PolicyMap policies; |
| 2664 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, | 2664 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, |
| 2665 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2665 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2666 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2666 base::MakeUnique<base::Value>(false), nullptr); |
| 2667 UpdateProviderPolicy(policies); | 2667 UpdateProviderPolicy(policies); |
| 2668 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2668 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
| 2669 | 2669 |
| 2670 // Verify that high contrast mode cannot be enabled manually anymore. | 2670 // Verify that high contrast mode cannot be enabled manually anymore. |
| 2671 accessibility_manager->EnableHighContrast(true); | 2671 accessibility_manager->EnableHighContrast(true); |
| 2672 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2672 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
| 2673 } | 2673 } |
| 2674 | 2674 |
| 2675 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { | 2675 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { |
| 2676 // Verifies that the screen magnifier can be disabled through policy. | 2676 // Verifies that the screen magnifier can be disabled through policy. |
| 2677 chromeos::MagnificationManager* magnification_manager = | 2677 chromeos::MagnificationManager* magnification_manager = |
| 2678 chromeos::MagnificationManager::Get(); | 2678 chromeos::MagnificationManager::Get(); |
| 2679 | 2679 |
| 2680 // Manually enable the full-screen magnifier. | 2680 // Manually enable the full-screen magnifier. |
| 2681 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL); | 2681 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL); |
| 2682 magnification_manager->SetMagnifierEnabled(true); | 2682 magnification_manager->SetMagnifierEnabled(true); |
| 2683 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 2683 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
| 2684 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2684 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2685 | 2685 |
| 2686 // Verify that policy overrides the manual setting. | 2686 // Verify that policy overrides the manual setting. |
| 2687 PolicyMap policies; | 2687 PolicyMap policies; |
| 2688 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, | 2688 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
| 2689 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2689 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2690 base::MakeUnique<base::FundamentalValue>(0), nullptr); | 2690 base::MakeUnique<base::Value>(0), nullptr); |
| 2691 UpdateProviderPolicy(policies); | 2691 UpdateProviderPolicy(policies); |
| 2692 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2692 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2693 | 2693 |
| 2694 // Verify that the screen magnifier cannot be enabled manually anymore. | 2694 // Verify that the screen magnifier cannot be enabled manually anymore. |
| 2695 magnification_manager->SetMagnifierEnabled(true); | 2695 magnification_manager->SetMagnifierEnabled(true); |
| 2696 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2696 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2697 } | 2697 } |
| 2698 | 2698 |
| 2699 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { | 2699 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { |
| 2700 // Verifies that the full-screen magnifier can be enabled through policy. | 2700 // Verifies that the full-screen magnifier can be enabled through policy. |
| 2701 chromeos::MagnificationManager* magnification_manager = | 2701 chromeos::MagnificationManager* magnification_manager = |
| 2702 chromeos::MagnificationManager::Get(); | 2702 chromeos::MagnificationManager::Get(); |
| 2703 | 2703 |
| 2704 // Verify that the screen magnifier is initially disabled. | 2704 // Verify that the screen magnifier is initially disabled. |
| 2705 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2705 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2706 | 2706 |
| 2707 // Verify that policy can enable the full-screen magnifier. | 2707 // Verify that policy can enable the full-screen magnifier. |
| 2708 PolicyMap policies; | 2708 PolicyMap policies; |
| 2709 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, | 2709 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
| 2710 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2710 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2711 base::MakeUnique<base::FundamentalValue>(ash::MAGNIFIER_FULL), | 2711 base::MakeUnique<base::Value>(ash::MAGNIFIER_FULL), |
| 2712 nullptr); | 2712 nullptr); |
| 2713 UpdateProviderPolicy(policies); | 2713 UpdateProviderPolicy(policies); |
| 2714 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 2714 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
| 2715 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2715 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2716 | 2716 |
| 2717 // Verify that the screen magnifier cannot be disabled manually anymore. | 2717 // Verify that the screen magnifier cannot be disabled manually anymore. |
| 2718 magnification_manager->SetMagnifierEnabled(false); | 2718 magnification_manager->SetMagnifierEnabled(false); |
| 2719 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2719 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2720 } | 2720 } |
| 2721 | 2721 |
| 2722 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { | 2722 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { |
| 2723 // Verifies that the on-screen keyboard accessibility feature can be | 2723 // Verifies that the on-screen keyboard accessibility feature can be |
| 2724 // controlled through policy. | 2724 // controlled through policy. |
| 2725 chromeos::AccessibilityManager* accessibility_manager = | 2725 chromeos::AccessibilityManager* accessibility_manager = |
| 2726 chromeos::AccessibilityManager::Get(); | 2726 chromeos::AccessibilityManager::Get(); |
| 2727 | 2727 |
| 2728 // Manually enable the on-screen keyboard. | 2728 // Manually enable the on-screen keyboard. |
| 2729 accessibility_manager->EnableVirtualKeyboard(true); | 2729 accessibility_manager->EnableVirtualKeyboard(true); |
| 2730 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2730 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2731 | 2731 |
| 2732 // Verify that policy overrides the manual setting. | 2732 // Verify that policy overrides the manual setting. |
| 2733 PolicyMap policies; | 2733 PolicyMap policies; |
| 2734 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2734 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2735 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2735 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2736 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2736 base::MakeUnique<base::Value>(false), nullptr); |
| 2737 UpdateProviderPolicy(policies); | 2737 UpdateProviderPolicy(policies); |
| 2738 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2738 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2739 | 2739 |
| 2740 // Verify that the on-screen keyboard cannot be enabled manually anymore. | 2740 // Verify that the on-screen keyboard cannot be enabled manually anymore. |
| 2741 accessibility_manager->EnableVirtualKeyboard(true); | 2741 accessibility_manager->EnableVirtualKeyboard(true); |
| 2742 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2742 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2743 } | 2743 } |
| 2744 | 2744 |
| 2745 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { | 2745 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { |
| 2746 // Verify keyboard disabled by default. | 2746 // Verify keyboard disabled by default. |
| 2747 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2747 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2748 // Verify keyboard can be toggled by default. | 2748 // Verify keyboard can be toggled by default. |
| 2749 keyboard::SetTouchKeyboardEnabled(true); | 2749 keyboard::SetTouchKeyboardEnabled(true); |
| 2750 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2750 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2751 keyboard::SetTouchKeyboardEnabled(false); | 2751 keyboard::SetTouchKeyboardEnabled(false); |
| 2752 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2752 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2753 | 2753 |
| 2754 // Verify enabling the policy takes effect immediately and that that user | 2754 // Verify enabling the policy takes effect immediately and that that user |
| 2755 // cannot disable the keyboard.. | 2755 // cannot disable the keyboard.. |
| 2756 PolicyMap policies; | 2756 PolicyMap policies; |
| 2757 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2757 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2758 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2758 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2759 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2759 base::MakeUnique<base::Value>(true), nullptr); |
| 2760 UpdateProviderPolicy(policies); | 2760 UpdateProviderPolicy(policies); |
| 2761 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2761 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2762 keyboard::SetTouchKeyboardEnabled(false); | 2762 keyboard::SetTouchKeyboardEnabled(false); |
| 2763 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2763 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2764 | 2764 |
| 2765 // Verify that disabling the policy takes effect immediately and that the user | 2765 // Verify that disabling the policy takes effect immediately and that the user |
| 2766 // cannot enable the keyboard. | 2766 // cannot enable the keyboard. |
| 2767 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2767 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2768 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2768 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2769 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2769 base::MakeUnique<base::Value>(false), nullptr); |
| 2770 UpdateProviderPolicy(policies); | 2770 UpdateProviderPolicy(policies); |
| 2771 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2771 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2772 keyboard::SetTouchKeyboardEnabled(true); | 2772 keyboard::SetTouchKeyboardEnabled(true); |
| 2773 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2773 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2774 } | 2774 } |
| 2775 | 2775 |
| 2776 #endif | 2776 #endif |
| 2777 | 2777 |
| 2778 namespace { | 2778 namespace { |
| 2779 | 2779 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2834 void ListOfURLs() { | 2834 void ListOfURLs() { |
| 2835 // Verifies that policy can set the startup pages to a list of URLs. | 2835 // Verifies that policy can set the startup pages to a list of URLs. |
| 2836 base::ListValue urls; | 2836 base::ListValue urls; |
| 2837 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { | 2837 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { |
| 2838 urls.AppendString(kRestoredURLs[i]); | 2838 urls.AppendString(kRestoredURLs[i]); |
| 2839 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 2839 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
| 2840 } | 2840 } |
| 2841 PolicyMap policies; | 2841 PolicyMap policies; |
| 2842 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 2842 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
| 2843 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2843 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2844 base::WrapUnique(new base::FundamentalValue( | 2844 base::WrapUnique(new base::Value( |
| 2845 SessionStartupPref::kPrefValueURLs)), | 2845 SessionStartupPref::kPrefValueURLs)), |
| 2846 nullptr); | 2846 nullptr); |
| 2847 policies.Set(key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, | 2847 policies.Set(key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, |
| 2848 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, urls.CreateDeepCopy(), | 2848 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, urls.CreateDeepCopy(), |
| 2849 nullptr); | 2849 nullptr); |
| 2850 provider_.UpdateChromePolicy(policies); | 2850 provider_.UpdateChromePolicy(policies); |
| 2851 } | 2851 } |
| 2852 | 2852 |
| 2853 void NTP() { | 2853 void NTP() { |
| 2854 // Verifies that policy can set the startup page to the NTP. | 2854 // Verifies that policy can set the startup page to the NTP. |
| 2855 PolicyMap policies; | 2855 PolicyMap policies; |
| 2856 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 2856 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
| 2857 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2857 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2858 base::WrapUnique(new base::FundamentalValue( | 2858 base::WrapUnique(new base::Value( |
| 2859 SessionStartupPref::kPrefValueNewTab)), | 2859 SessionStartupPref::kPrefValueNewTab)), |
| 2860 nullptr); | 2860 nullptr); |
| 2861 provider_.UpdateChromePolicy(policies); | 2861 provider_.UpdateChromePolicy(policies); |
| 2862 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); | 2862 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); |
| 2863 } | 2863 } |
| 2864 | 2864 |
| 2865 void Last() { | 2865 void Last() { |
| 2866 // Verifies that policy can set the startup pages to the last session. | 2866 // Verifies that policy can set the startup pages to the last session. |
| 2867 PolicyMap policies; | 2867 PolicyMap policies; |
| 2868 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 2868 policies.Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
| 2869 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2869 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2870 base::WrapUnique(new base::FundamentalValue( | 2870 base::WrapUnique(new base::Value( |
| 2871 SessionStartupPref::kPrefValueLast)), | 2871 SessionStartupPref::kPrefValueLast)), |
| 2872 nullptr); | 2872 nullptr); |
| 2873 provider_.UpdateChromePolicy(policies); | 2873 provider_.UpdateChromePolicy(policies); |
| 2874 // This should restore the tabs opened at PRE_RunTest below. | 2874 // This should restore the tabs opened at PRE_RunTest below. |
| 2875 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) | 2875 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) |
| 2876 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 2876 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
| 2877 } | 2877 } |
| 2878 | 2878 |
| 2879 std::vector<GURL> expected_urls_; | 2879 std::vector<GURL> expected_urls_; |
| 2880 }; | 2880 }; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2915 class PolicyStatisticsCollectorTest : public PolicyTest { | 2915 class PolicyStatisticsCollectorTest : public PolicyTest { |
| 2916 public: | 2916 public: |
| 2917 PolicyStatisticsCollectorTest() {} | 2917 PolicyStatisticsCollectorTest() {} |
| 2918 ~PolicyStatisticsCollectorTest() override {} | 2918 ~PolicyStatisticsCollectorTest() override {} |
| 2919 | 2919 |
| 2920 void SetUpInProcessBrowserTestFixture() override { | 2920 void SetUpInProcessBrowserTestFixture() override { |
| 2921 PolicyTest::SetUpInProcessBrowserTestFixture(); | 2921 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 2922 PolicyMap policies; | 2922 PolicyMap policies; |
| 2923 policies.Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, | 2923 policies.Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, |
| 2924 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2924 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2925 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 2925 base::MakeUnique<base::Value>(true), nullptr); |
| 2926 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 2926 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 2927 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2927 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2928 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 2928 base::MakeUnique<base::Value>(false), nullptr); |
| 2929 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, | 2929 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, |
| 2930 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2930 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2931 base::MakeUnique<base::StringValue>("http://chromium.org"), | 2931 base::MakeUnique<base::StringValue>("http://chromium.org"), |
| 2932 nullptr); | 2932 nullptr); |
| 2933 provider_.UpdateChromePolicy(policies); | 2933 provider_.UpdateChromePolicy(policies); |
| 2934 } | 2934 } |
| 2935 }; | 2935 }; |
| 2936 | 2936 |
| 2937 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { | 2937 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { |
| 2938 // Verifies that policy usage histograms are collected at startup. | 2938 // Verifies that policy usage histograms are collected at startup. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 // Configure a given policy map. The |policy_name| is the name of either the | 2987 // Configure a given policy map. The |policy_name| is the name of either the |
| 2988 // audio or video capture allow policy and must never be NULL. | 2988 // audio or video capture allow policy and must never be NULL. |
| 2989 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist | 2989 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist |
| 2990 // policy is set. If non-NULL, the whitelist policy is set to contain either | 2990 // policy is set. If non-NULL, the whitelist policy is set to contain either |
| 2991 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. | 2991 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. |
| 2992 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, | 2992 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, |
| 2993 const char* whitelist_policy, | 2993 const char* whitelist_policy, |
| 2994 const char* allow_rule) { | 2994 const char* allow_rule) { |
| 2995 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2995 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 2996 POLICY_SOURCE_CLOUD, | 2996 POLICY_SOURCE_CLOUD, |
| 2997 base::MakeUnique<base::FundamentalValue>(policy_value_), | 2997 base::MakeUnique<base::Value>(policy_value_), |
| 2998 nullptr); | 2998 nullptr); |
| 2999 | 2999 |
| 3000 if (whitelist_policy) { | 3000 if (whitelist_policy) { |
| 3001 // Add an entry to the whitelist that allows the specified URL regardless | 3001 // Add an entry to the whitelist that allows the specified URL regardless |
| 3002 // of the setting of kAudioCapturedAllowed. | 3002 // of the setting of kAudioCapturedAllowed. |
| 3003 std::unique_ptr<base::ListValue> list(new base::ListValue); | 3003 std::unique_ptr<base::ListValue> list(new base::ListValue); |
| 3004 if (allow_rule) { | 3004 if (allow_rule) { |
| 3005 list->AppendString(allow_rule); | 3005 list->AppendString(allow_rule); |
| 3006 request_url_allowed_via_whitelist_ = true; | 3006 request_url_allowed_via_whitelist_ = true; |
| 3007 } else { | 3007 } else { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3216 content::WebContents* const web_contents = | 3216 content::WebContents* const web_contents = |
| 3217 browser()->tab_strip_model()->GetActiveWebContents(); | 3217 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3218 EXPECT_THAT( | 3218 EXPECT_THAT( |
| 3219 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), | 3219 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), |
| 3220 testing::StartsWith("http://localhost:")); | 3220 testing::StartsWith("http://localhost:")); |
| 3221 | 3221 |
| 3222 // Set the policy to block Web Bluetooth. | 3222 // Set the policy to block Web Bluetooth. |
| 3223 PolicyMap policies; | 3223 PolicyMap policies; |
| 3224 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, | 3224 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, |
| 3225 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3225 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3226 base::MakeUnique<base::FundamentalValue>(2), nullptr); | 3226 base::MakeUnique<base::Value>(2), nullptr); |
| 3227 UpdateProviderPolicy(policies); | 3227 UpdateProviderPolicy(policies); |
| 3228 | 3228 |
| 3229 std::string rejection; | 3229 std::string rejection; |
| 3230 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 3230 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 3231 web_contents, | 3231 web_contents, |
| 3232 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" | 3232 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" |
| 3233 " .then(() => { domAutomationController.send('Success'); }," | 3233 " .then(() => { domAutomationController.send('Success'); }," |
| 3234 " reason => {" | 3234 " reason => {" |
| 3235 " domAutomationController.send(reason.name + ': ' + reason.message);" | 3235 " domAutomationController.send(reason.name + ': ' + reason.message);" |
| 3236 " });", | 3236 " });", |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3305 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3305 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 3306 ASSERT_TRUE(https_server_expired.Start()); | 3306 ASSERT_TRUE(https_server_expired.Start()); |
| 3307 | 3307 |
| 3308 // Set the enterprise policy to disallow opt-in. | 3308 // Set the enterprise policy to disallow opt-in. |
| 3309 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3309 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3310 EXPECT_TRUE( | 3310 EXPECT_TRUE( |
| 3311 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3311 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
| 3312 PolicyMap policies; | 3312 PolicyMap policies; |
| 3313 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, | 3313 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, |
| 3314 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3314 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3315 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3315 base::WrapUnique(new base::Value(false)), nullptr); |
| 3316 UpdateProviderPolicy(policies); | 3316 UpdateProviderPolicy(policies); |
| 3317 EXPECT_FALSE( | 3317 EXPECT_FALSE( |
| 3318 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); | 3318 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); |
| 3319 | 3319 |
| 3320 // Navigate to an SSL error page. | 3320 // Navigate to an SSL error page. |
| 3321 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3321 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
| 3322 | 3322 |
| 3323 const content::InterstitialPage* const interstitial = | 3323 const content::InterstitialPage* const interstitial = |
| 3324 content::InterstitialPage::GetInterstitialPage( | 3324 content::InterstitialPage::GetInterstitialPage( |
| 3325 browser()->tab_strip_model()->GetActiveWebContents()); | 3325 browser()->tab_strip_model()->GetActiveWebContents()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3387 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); | 3387 https_server_expired.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 3388 ASSERT_TRUE(https_server_expired.Start()); | 3388 ASSERT_TRUE(https_server_expired.Start()); |
| 3389 | 3389 |
| 3390 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3390 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3391 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3391 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
| 3392 | 3392 |
| 3393 // Disallowing the proceed link by setting the policy to |false|. | 3393 // Disallowing the proceed link by setting the policy to |false|. |
| 3394 PolicyMap policies; | 3394 PolicyMap policies; |
| 3395 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, | 3395 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, |
| 3396 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3396 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3397 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3397 base::WrapUnique(new base::Value(false)), nullptr); |
| 3398 UpdateProviderPolicy(policies); | 3398 UpdateProviderPolicy(policies); |
| 3399 | 3399 |
| 3400 // Policy should not allow overriding anymore. | 3400 // Policy should not allow overriding anymore. |
| 3401 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); | 3401 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); |
| 3402 | 3402 |
| 3403 // Policy disallows overriding - navigate to an SSL error page and expect no | 3403 // Policy disallows overriding - navigate to an SSL error page and expect no |
| 3404 // proceed link. | 3404 // proceed link. |
| 3405 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); | 3405 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); |
| 3406 const content::InterstitialPage* const interstitial = | 3406 const content::InterstitialPage* const interstitial = |
| 3407 content::InterstitialPage::GetInterstitialPage( | 3407 content::InterstitialPage::GetInterstitialPage( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3435 // Test that TaskManagerInterface::IsEndProcessEnabled is controlled by | 3435 // Test that TaskManagerInterface::IsEndProcessEnabled is controlled by |
| 3436 // TaskManagerEndProcessEnabled policy | 3436 // TaskManagerEndProcessEnabled policy |
| 3437 IN_PROC_BROWSER_TEST_F(PolicyTest, TaskManagerEndProcessEnabled) { | 3437 IN_PROC_BROWSER_TEST_F(PolicyTest, TaskManagerEndProcessEnabled) { |
| 3438 // By default it's allowed to end tasks. | 3438 // By default it's allowed to end tasks. |
| 3439 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); | 3439 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); |
| 3440 | 3440 |
| 3441 // Disabling ending tasks in task manager by policy | 3441 // Disabling ending tasks in task manager by policy |
| 3442 PolicyMap policies1; | 3442 PolicyMap policies1; |
| 3443 policies1.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, | 3443 policies1.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, |
| 3444 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 3444 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 3445 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3445 base::WrapUnique(new base::Value(false)), nullptr); |
| 3446 UpdateProviderPolicy(policies1); | 3446 UpdateProviderPolicy(policies1); |
| 3447 | 3447 |
| 3448 // Policy should not allow ending tasks anymore. | 3448 // Policy should not allow ending tasks anymore. |
| 3449 EXPECT_FALSE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); | 3449 EXPECT_FALSE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); |
| 3450 | 3450 |
| 3451 // Enabling ending tasks in task manager by policy | 3451 // Enabling ending tasks in task manager by policy |
| 3452 PolicyMap policies2; | 3452 PolicyMap policies2; |
| 3453 policies2.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, | 3453 policies2.Set(key::kTaskManagerEndProcessEnabled, POLICY_LEVEL_MANDATORY, |
| 3454 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 3454 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 3455 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 3455 base::WrapUnique(new base::Value(true)), nullptr); |
| 3456 UpdateProviderPolicy(policies2); | 3456 UpdateProviderPolicy(policies2); |
| 3457 | 3457 |
| 3458 // Policy should allow ending tasks again. | 3458 // Policy should allow ending tasks again. |
| 3459 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); | 3459 EXPECT_TRUE(task_manager::TaskManagerInterface::IsEndProcessEnabled()); |
| 3460 } | 3460 } |
| 3461 | 3461 |
| 3462 #if defined(ENABLE_MEDIA_ROUTER) | 3462 #if defined(ENABLE_MEDIA_ROUTER) |
| 3463 // Sets the proper policy before the browser is started. | 3463 // Sets the proper policy before the browser is started. |
| 3464 template<bool enable> | 3464 template<bool enable> |
| 3465 class MediaRouterPolicyTest : public PolicyTest { | 3465 class MediaRouterPolicyTest : public PolicyTest { |
| 3466 public: | 3466 public: |
| 3467 void SetUpInProcessBrowserTestFixture() override { | 3467 void SetUpInProcessBrowserTestFixture() override { |
| 3468 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3468 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3469 PolicyMap policies; | 3469 PolicyMap policies; |
| 3470 policies.Set(key::kEnableMediaRouter, POLICY_LEVEL_MANDATORY, | 3470 policies.Set(key::kEnableMediaRouter, POLICY_LEVEL_MANDATORY, |
| 3471 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3471 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3472 base::MakeUnique<base::FundamentalValue>(enable), nullptr); | 3472 base::MakeUnique<base::Value>(enable), nullptr); |
| 3473 provider_.UpdateChromePolicy(policies); | 3473 provider_.UpdateChromePolicy(policies); |
| 3474 } | 3474 } |
| 3475 }; | 3475 }; |
| 3476 | 3476 |
| 3477 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; | 3477 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; |
| 3478 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; | 3478 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; |
| 3479 | 3479 |
| 3480 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { | 3480 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { |
| 3481 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); | 3481 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3482 } | 3482 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3606 ComponentUpdaterPolicyTest::ComponentUpdaterPolicyTest() {} | 3606 ComponentUpdaterPolicyTest::ComponentUpdaterPolicyTest() {} |
| 3607 | 3607 |
| 3608 ComponentUpdaterPolicyTest::~ComponentUpdaterPolicyTest() {} | 3608 ComponentUpdaterPolicyTest::~ComponentUpdaterPolicyTest() {} |
| 3609 | 3609 |
| 3610 void ComponentUpdaterPolicyTest::SetEnableComponentUpdates( | 3610 void ComponentUpdaterPolicyTest::SetEnableComponentUpdates( |
| 3611 bool enable_component_updates) { | 3611 bool enable_component_updates) { |
| 3612 PolicyMap policies; | 3612 PolicyMap policies; |
| 3613 policies.Set( | 3613 policies.Set( |
| 3614 key::kComponentUpdatesEnabled, POLICY_LEVEL_MANDATORY, | 3614 key::kComponentUpdatesEnabled, POLICY_LEVEL_MANDATORY, |
| 3615 POLICY_SCOPE_MACHINE, POLICY_SOURCE_ENTERPRISE_DEFAULT, | 3615 POLICY_SCOPE_MACHINE, POLICY_SOURCE_ENTERPRISE_DEFAULT, |
| 3616 base::WrapUnique(new base::FundamentalValue(enable_component_updates)), | 3616 base::WrapUnique(new base::Value(enable_component_updates)), |
| 3617 nullptr); | 3617 nullptr); |
| 3618 UpdateProviderPolicy(policies); | 3618 UpdateProviderPolicy(policies); |
| 3619 } | 3619 } |
| 3620 | 3620 |
| 3621 update_client::CrxComponent ComponentUpdaterPolicyTest::MakeCrxComponent( | 3621 update_client::CrxComponent ComponentUpdaterPolicyTest::MakeCrxComponent( |
| 3622 bool supports_group_policy_enable_component_updates) { | 3622 bool supports_group_policy_enable_component_updates) { |
| 3623 class MockInstaller : public update_client::CrxInstaller { | 3623 class MockInstaller : public update_client::CrxInstaller { |
| 3624 public: | 3624 public: |
| 3625 MockInstaller() {} | 3625 MockInstaller() {} |
| 3626 | 3626 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3899 // Sets the hardware acceleration mode policy before the browser is started. | 3899 // Sets the hardware acceleration mode policy before the browser is started. |
| 3900 class HardwareAccelerationModePolicyTest : public PolicyTest { | 3900 class HardwareAccelerationModePolicyTest : public PolicyTest { |
| 3901 public: | 3901 public: |
| 3902 HardwareAccelerationModePolicyTest() {} | 3902 HardwareAccelerationModePolicyTest() {} |
| 3903 | 3903 |
| 3904 void SetUpInProcessBrowserTestFixture() override { | 3904 void SetUpInProcessBrowserTestFixture() override { |
| 3905 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3905 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3906 PolicyMap policies; | 3906 PolicyMap policies; |
| 3907 policies.Set(key::kHardwareAccelerationModeEnabled, POLICY_LEVEL_MANDATORY, | 3907 policies.Set(key::kHardwareAccelerationModeEnabled, POLICY_LEVEL_MANDATORY, |
| 3908 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3908 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3909 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 3909 base::MakeUnique<base::Value>(false), nullptr); |
| 3910 provider_.UpdateChromePolicy(policies); | 3910 provider_.UpdateChromePolicy(policies); |
| 3911 } | 3911 } |
| 3912 }; | 3912 }; |
| 3913 | 3913 |
| 3914 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, | 3914 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, |
| 3915 HardwareAccelerationDisabled) { | 3915 HardwareAccelerationDisabled) { |
| 3916 // Verifies that hardware acceleration can be disabled with policy. | 3916 // Verifies that hardware acceleration can be disabled with policy. |
| 3917 EXPECT_FALSE( | 3917 EXPECT_FALSE( |
| 3918 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); | 3918 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); |
| 3919 } | 3919 } |
| 3920 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 3920 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 3921 | 3921 |
| 3922 #if defined(OS_CHROMEOS) | 3922 #if defined(OS_CHROMEOS) |
| 3923 // Policy is only available in ChromeOS | 3923 // Policy is only available in ChromeOS |
| 3924 IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) { | 3924 IN_PROC_BROWSER_TEST_F(PolicyTest, UnifiedDesktopEnabledByDefault) { |
| 3925 // Verify that Unified Desktop can be enabled by policy | 3925 // Verify that Unified Desktop can be enabled by policy |
| 3926 display::DisplayManager* display_manager = | 3926 display::DisplayManager* display_manager = |
| 3927 ash::Shell::GetInstance()->display_manager(); | 3927 ash::Shell::GetInstance()->display_manager(); |
| 3928 | 3928 |
| 3929 // The policy description promises that Unified Desktop is not available | 3929 // The policy description promises that Unified Desktop is not available |
| 3930 // unless the policy is set (or a command line or an extension is used). If | 3930 // unless the policy is set (or a command line or an extension is used). If |
| 3931 // this default behaviour changes, please change the description at | 3931 // this default behaviour changes, please change the description at |
| 3932 // components/policy/resources/policy_templates.json. | 3932 // components/policy/resources/policy_templates.json. |
| 3933 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3933 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 3934 // Now set the policy and check that unified desktop is turned on. | 3934 // Now set the policy and check that unified desktop is turned on. |
| 3935 PolicyMap policies; | 3935 PolicyMap policies; |
| 3936 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, | 3936 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, |
| 3937 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3937 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3938 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 3938 base::WrapUnique(new base::Value(true)), nullptr); |
| 3939 UpdateProviderPolicy(policies); | 3939 UpdateProviderPolicy(policies); |
| 3940 EXPECT_TRUE(display_manager->unified_desktop_enabled()); | 3940 EXPECT_TRUE(display_manager->unified_desktop_enabled()); |
| 3941 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, | 3941 policies.Set(key::kUnifiedDesktopEnabledByDefault, POLICY_LEVEL_MANDATORY, |
| 3942 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3942 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3943 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3943 base::WrapUnique(new base::Value(false)), nullptr); |
| 3944 UpdateProviderPolicy(policies); | 3944 UpdateProviderPolicy(policies); |
| 3945 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3945 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 3946 } | 3946 } |
| 3947 | 3947 |
| 3948 class ArcPolicyTest : public PolicyTest { | 3948 class ArcPolicyTest : public PolicyTest { |
| 3949 public: | 3949 public: |
| 3950 ArcPolicyTest() {} | 3950 ArcPolicyTest() {} |
| 3951 ~ArcPolicyTest() override {} | 3951 ~ArcPolicyTest() override {} |
| 3952 | 3952 |
| 3953 protected: | 3953 protected: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3977 void SetUpCommandLine(base::CommandLine* command_line) override { | 3977 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 3978 // ArcSessionManager functionality is available only when Arc is enabled. | 3978 // ArcSessionManager functionality is available only when Arc is enabled. |
| 3979 // Use kEnableArc switch that activates it. | 3979 // Use kEnableArc switch that activates it. |
| 3980 command_line->AppendSwitch(chromeos::switches::kEnableArc); | 3980 command_line->AppendSwitch(chromeos::switches::kEnableArc); |
| 3981 } | 3981 } |
| 3982 | 3982 |
| 3983 void SetArcEnabledByPolicy(bool enabled) { | 3983 void SetArcEnabledByPolicy(bool enabled) { |
| 3984 PolicyMap policies; | 3984 PolicyMap policies; |
| 3985 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3985 policies.Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 3986 POLICY_SOURCE_CLOUD, | 3986 POLICY_SOURCE_CLOUD, |
| 3987 base::WrapUnique(new base::FundamentalValue(enabled)), | 3987 base::WrapUnique(new base::Value(enabled)), |
| 3988 nullptr); | 3988 nullptr); |
| 3989 UpdateProviderPolicy(policies); | 3989 UpdateProviderPolicy(policies); |
| 3990 if (browser()) { | 3990 if (browser()) { |
| 3991 const PrefService* const prefs = browser()->profile()->GetPrefs(); | 3991 const PrefService* const prefs = browser()->profile()->GetPrefs(); |
| 3992 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); | 3992 EXPECT_EQ(prefs->GetBoolean(prefs::kArcEnabled), enabled); |
| 3993 } | 3993 } |
| 3994 } | 3994 } |
| 3995 | 3995 |
| 3996 private: | 3996 private: |
| 3997 chromeos::FakeSessionManagerClient *fake_session_manager_client_; | 3997 chromeos::FakeSessionManagerClient *fake_session_manager_client_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4029 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4029 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4030 | 4030 |
| 4031 // ARC Backup & Restore is switched on by default. | 4031 // ARC Backup & Restore is switched on by default. |
| 4032 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4032 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4033 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4033 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4034 | 4034 |
| 4035 // Disable ARC Backup & Restore. | 4035 // Disable ARC Backup & Restore. |
| 4036 PolicyMap policies; | 4036 PolicyMap policies; |
| 4037 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4037 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
| 4038 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4038 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4039 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 4039 base::MakeUnique<base::Value>(false), nullptr); |
| 4040 UpdateProviderPolicy(policies); | 4040 UpdateProviderPolicy(policies); |
| 4041 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4041 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4042 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4042 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4043 | 4043 |
| 4044 // Enable ARC Backup & Restore. | 4044 // Enable ARC Backup & Restore. |
| 4045 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4045 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
| 4046 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4046 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4047 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 4047 base::MakeUnique<base::Value>(true), nullptr); |
| 4048 UpdateProviderPolicy(policies); | 4048 UpdateProviderPolicy(policies); |
| 4049 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4049 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4050 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4050 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
| 4051 | 4051 |
| 4052 TearDownTest(); | 4052 TearDownTest(); |
| 4053 } | 4053 } |
| 4054 | 4054 |
| 4055 // Test ArcLocationServiceEnabled policy. | 4055 // Test ArcLocationServiceEnabled policy. |
| 4056 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { | 4056 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { |
| 4057 SetUpTest(); | 4057 SetUpTest(); |
| 4058 | 4058 |
| 4059 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4059 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4060 | 4060 |
| 4061 // ARC Location Service is switched on by default. | 4061 // ARC Location Service is switched on by default. |
| 4062 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4062 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4063 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4063 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4064 | 4064 |
| 4065 // Managed Location Service. | 4065 // Managed Location Service. |
| 4066 PolicyMap policies; | 4066 PolicyMap policies; |
| 4067 // AllowGeolocation | 4067 // AllowGeolocation |
| 4068 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, | 4068 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
| 4069 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4069 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4070 base::MakeUnique<base::FundamentalValue>(1), nullptr); | 4070 base::MakeUnique<base::Value>(1), nullptr); |
| 4071 UpdateProviderPolicy(policies); | 4071 UpdateProviderPolicy(policies); |
| 4072 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4072 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4073 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4073 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4074 | 4074 |
| 4075 // BlockGeolocation | 4075 // BlockGeolocation |
| 4076 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, | 4076 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
| 4077 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4077 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4078 base::MakeUnique<base::FundamentalValue>(2), nullptr); | 4078 base::MakeUnique<base::Value>(2), nullptr); |
| 4079 UpdateProviderPolicy(policies); | 4079 UpdateProviderPolicy(policies); |
| 4080 EXPECT_FALSE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4080 EXPECT_FALSE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4081 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4081 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4082 | 4082 |
| 4083 // AskGeolocation | 4083 // AskGeolocation |
| 4084 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, | 4084 policies.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
| 4085 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4085 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4086 base::MakeUnique<base::FundamentalValue>(3), nullptr); | 4086 base::MakeUnique<base::Value>(3), nullptr); |
| 4087 UpdateProviderPolicy(policies); | 4087 UpdateProviderPolicy(policies); |
| 4088 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); | 4088 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4089 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); | 4089 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4090 | 4090 |
| 4091 TearDownTest(); | 4091 TearDownTest(); |
| 4092 } | 4092 } |
| 4093 | 4093 |
| 4094 namespace { | 4094 namespace { |
| 4095 const char kTestUser1[] = "test1@domain.com"; | 4095 const char kTestUser1[] = "test1@domain.com"; |
| 4096 } // anonymous namespace | 4096 } // anonymous namespace |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4130 EXPECT_FALSE(local_state->IsManagedPreference( | 4130 EXPECT_FALSE(local_state->IsManagedPreference( |
| 4131 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4131 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4132 EXPECT_EQ(0, local_state->GetInteger( | 4132 EXPECT_EQ(0, local_state->GetInteger( |
| 4133 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4133 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4134 } | 4134 } |
| 4135 | 4135 |
| 4136 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { | 4136 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { |
| 4137 PolicyMap policies; | 4137 PolicyMap policies; |
| 4138 policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY, | 4138 policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY, |
| 4139 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 4139 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 4140 base::MakeUnique<base::FundamentalValue>(policy_value), | 4140 base::MakeUnique<base::Value>(policy_value), |
| 4141 nullptr); | 4141 nullptr); |
| 4142 UpdateProviderPolicy(policies); | 4142 UpdateProviderPolicy(policies); |
| 4143 | 4143 |
| 4144 PrefService* local_state = g_browser_process->local_state(); | 4144 PrefService* local_state = g_browser_process->local_state(); |
| 4145 | 4145 |
| 4146 EXPECT_TRUE(local_state->IsManagedPreference( | 4146 EXPECT_TRUE(local_state->IsManagedPreference( |
| 4147 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4147 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4148 EXPECT_EQ(policy_value, | 4148 EXPECT_EQ(policy_value, |
| 4149 local_state->GetInteger( | 4149 local_state->GetInteger( |
| 4150 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4150 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4225 | 4225 |
| 4226 SetEmptyPolicy(); | 4226 SetEmptyPolicy(); |
| 4227 // Policy not set. | 4227 // Policy not set. |
| 4228 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4228 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4229 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4229 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4230 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4230 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4231 } | 4231 } |
| 4232 #endif // defined(OS_CHROMEOS) | 4232 #endif // defined(OS_CHROMEOS) |
| 4233 | 4233 |
| 4234 } // namespace policy | 4234 } // namespace policy |
| OLD | NEW |