| 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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, | 718 base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http, |
| 719 make_scoped_refptr(BrowserThread::GetBlockingPool())), | 719 make_scoped_refptr(BrowserThread::GetBlockingPool())), |
| 720 base::MessageLoop::current()->QuitWhenIdleClosure()); | 720 base::MessageLoop::current()->QuitWhenIdleClosure()); |
| 721 content::RunMessageLoop(); | 721 content::RunMessageLoop(); |
| 722 } | 722 } |
| 723 | 723 |
| 724 void SetScreenshotPolicy(bool enabled) { | 724 void SetScreenshotPolicy(bool enabled) { |
| 725 PolicyMap policies; | 725 PolicyMap policies; |
| 726 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, | 726 policies.Set(key::kDisableScreenshots, POLICY_LEVEL_MANDATORY, |
| 727 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 727 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 728 base::WrapUnique(new base::FundamentalValue(!enabled)), | 728 base::MakeUnique<base::FundamentalValue>(!enabled), nullptr); |
| 729 nullptr); | |
| 730 UpdateProviderPolicy(policies); | 729 UpdateProviderPolicy(policies); |
| 731 } | 730 } |
| 732 | 731 |
| 733 #if defined(OS_CHROMEOS) | 732 #if defined(OS_CHROMEOS) |
| 734 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { | 733 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { |
| 735 public: | 734 public: |
| 736 void OnScreenshotCompleted( | 735 void OnScreenshotCompleted( |
| 737 ScreenshotGrabberObserver::Result screenshot_result, | 736 ScreenshotGrabberObserver::Result screenshot_result, |
| 738 const base::FilePath& screenshot_path) override { | 737 const base::FilePath& screenshot_path) override { |
| 739 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, | 738 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 class LocalePolicyTest : public PolicyTest { | 926 class LocalePolicyTest : public PolicyTest { |
| 928 public: | 927 public: |
| 929 LocalePolicyTest() {} | 928 LocalePolicyTest() {} |
| 930 ~LocalePolicyTest() override {} | 929 ~LocalePolicyTest() override {} |
| 931 | 930 |
| 932 void SetUpInProcessBrowserTestFixture() override { | 931 void SetUpInProcessBrowserTestFixture() override { |
| 933 PolicyTest::SetUpInProcessBrowserTestFixture(); | 932 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 934 PolicyMap policies; | 933 PolicyMap policies; |
| 935 policies.Set(key::kApplicationLocaleValue, POLICY_LEVEL_MANDATORY, | 934 policies.Set(key::kApplicationLocaleValue, POLICY_LEVEL_MANDATORY, |
| 936 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 935 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 937 base::WrapUnique(new base::StringValue("fr")), nullptr); | 936 base::MakeUnique<base::StringValue>("fr"), nullptr); |
| 938 provider_.UpdateChromePolicy(policies); | 937 provider_.UpdateChromePolicy(policies); |
| 939 // The "en-US" ResourceBundle is always loaded before this step for tests, | 938 // The "en-US" ResourceBundle is always loaded before this step for tests, |
| 940 // but in this test we want the browser to load the bundle as it | 939 // but in this test we want the browser to load the bundle as it |
| 941 // normally would. | 940 // normally would. |
| 942 ResourceBundle::CleanupSharedInstance(); | 941 ResourceBundle::CleanupSharedInstance(); |
| 943 } | 942 } |
| 944 }; | 943 }; |
| 945 | 944 |
| 946 IN_PROC_BROWSER_TEST_F(LocalePolicyTest, ApplicationLocaleValue) { | 945 IN_PROC_BROWSER_TEST_F(LocalePolicyTest, ApplicationLocaleValue) { |
| 947 // Verifies that the default locale can be overridden with policy. | 946 // Verifies that the default locale can be overridden with policy. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 966 | 965 |
| 967 // Test starts in about:blank. | 966 // Test starts in about:blank. |
| 968 PrefService* prefs = browser()->profile()->GetPrefs(); | 967 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 969 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 968 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 970 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 969 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 971 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 970 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 972 | 971 |
| 973 PolicyMap policies; | 972 PolicyMap policies; |
| 974 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 973 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 975 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 974 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 976 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 975 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 977 UpdateProviderPolicy(policies); | 976 UpdateProviderPolicy(policies); |
| 978 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 977 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 979 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 978 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 980 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 979 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 981 | 980 |
| 982 // The NTP has special handling of the bookmark bar. | 981 // The NTP has special handling of the bookmark bar. |
| 983 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 982 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 984 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 983 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 985 | 984 |
| 986 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 985 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 987 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 986 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 988 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 987 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 989 UpdateProviderPolicy(policies); | 988 UpdateProviderPolicy(policies); |
| 990 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 989 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 991 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 990 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| 992 // The bookmark bar is hidden in the NTP when disabled by policy. | 991 // The bookmark bar is hidden in the NTP when disabled by policy. |
| 993 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 992 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 994 | 993 |
| 995 policies.Clear(); | 994 policies.Clear(); |
| 996 UpdateProviderPolicy(policies); | 995 UpdateProviderPolicy(policies); |
| 997 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); | 996 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); |
| 998 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 997 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1015 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); | 1014 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); |
| 1016 } | 1015 } |
| 1017 | 1016 |
| 1018 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { | 1017 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { |
| 1019 // Verify that the cookie persists across restarts. | 1018 // Verify that the cookie persists across restarts. |
| 1020 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); | 1019 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); |
| 1021 // Now set the policy and the cookie should be gone after another restart. | 1020 // Now set the policy and the cookie should be gone after another restart. |
| 1022 PolicyMap policies; | 1021 PolicyMap policies; |
| 1023 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, | 1022 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, |
| 1024 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1023 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1025 base::WrapUnique(new base::FundamentalValue(4)), nullptr); | 1024 base::MakeUnique<base::FundamentalValue>(4), nullptr); |
| 1026 UpdateProviderPolicy(policies); | 1025 UpdateProviderPolicy(policies); |
| 1027 } | 1026 } |
| 1028 | 1027 |
| 1029 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { | 1028 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { |
| 1030 // Verify that the cookie is gone. | 1029 // Verify that the cookie is gone. |
| 1031 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); | 1030 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); |
| 1032 } | 1031 } |
| 1033 | 1032 |
| 1034 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { | 1033 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { |
| 1035 MakeRequestFail make_request_fail("search.example"); | 1034 MakeRequestFail make_request_fail("search.example"); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1063 default_search->search_terms_replacement_key() == | 1062 default_search->search_terms_replacement_key() == |
| 1064 kSearchTermsReplacementKey && | 1063 kSearchTermsReplacementKey && |
| 1065 default_search->image_url() == kImageURL && | 1064 default_search->image_url() == kImageURL && |
| 1066 default_search->image_url_post_params() == kImageURLPostParams && | 1065 default_search->image_url_post_params() == kImageURLPostParams && |
| 1067 default_search->new_tab_url() == kNewTabURL); | 1066 default_search->new_tab_url() == kNewTabURL); |
| 1068 | 1067 |
| 1069 // Override the default search provider using policies. | 1068 // Override the default search provider using policies. |
| 1070 PolicyMap policies; | 1069 PolicyMap policies; |
| 1071 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 1070 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
| 1072 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1071 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1073 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 1072 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 1074 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, | 1073 policies.Set(key::kDefaultSearchProviderKeyword, POLICY_LEVEL_MANDATORY, |
| 1075 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1074 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1076 base::WrapUnique(new base::StringValue(kKeyword)), nullptr); | 1075 base::MakeUnique<base::StringValue>(kKeyword), nullptr); |
| 1077 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, | 1076 policies.Set(key::kDefaultSearchProviderSearchURL, POLICY_LEVEL_MANDATORY, |
| 1078 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1077 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1079 base::WrapUnique(new base::StringValue(kSearchURL)), nullptr); | 1078 base::MakeUnique<base::StringValue>(kSearchURL), nullptr); |
| 1080 policies.Set(key::kDefaultSearchProviderInstantURL, POLICY_LEVEL_MANDATORY, | 1079 policies.Set(key::kDefaultSearchProviderInstantURL, POLICY_LEVEL_MANDATORY, |
| 1081 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1080 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1082 base::WrapUnique(new base::StringValue(kInstantURL)), nullptr); | 1081 base::MakeUnique<base::StringValue>(kInstantURL), nullptr); |
| 1083 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); | 1082 std::unique_ptr<base::ListValue> alternate_urls(new base::ListValue); |
| 1084 alternate_urls->AppendString(kAlternateURL0); | 1083 alternate_urls->AppendString(kAlternateURL0); |
| 1085 alternate_urls->AppendString(kAlternateURL1); | 1084 alternate_urls->AppendString(kAlternateURL1); |
| 1086 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, | 1085 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, |
| 1087 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1086 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1088 std::move(alternate_urls), nullptr); | 1087 std::move(alternate_urls), nullptr); |
| 1089 policies.Set( | 1088 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, |
| 1090 key::kDefaultSearchProviderSearchTermsReplacementKey, | 1089 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1091 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1090 base::MakeUnique<base::StringValue>(kSearchTermsReplacementKey), |
| 1092 base::WrapUnique(new base::StringValue(kSearchTermsReplacementKey)), | 1091 nullptr); |
| 1093 nullptr); | |
| 1094 policies.Set(key::kDefaultSearchProviderImageURL, POLICY_LEVEL_MANDATORY, | 1092 policies.Set(key::kDefaultSearchProviderImageURL, POLICY_LEVEL_MANDATORY, |
| 1095 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1093 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1096 base::WrapUnique(new base::StringValue(kImageURL)), nullptr); | 1094 base::MakeUnique<base::StringValue>(kImageURL), nullptr); |
| 1097 policies.Set(key::kDefaultSearchProviderImageURLPostParams, | 1095 policies.Set(key::kDefaultSearchProviderImageURLPostParams, |
| 1098 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1096 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1099 base::WrapUnique(new base::StringValue(kImageURLPostParams)), | 1097 base::MakeUnique<base::StringValue>(kImageURLPostParams), |
| 1100 nullptr); | 1098 nullptr); |
| 1101 policies.Set(key::kDefaultSearchProviderNewTabURL, POLICY_LEVEL_MANDATORY, | 1099 policies.Set(key::kDefaultSearchProviderNewTabURL, POLICY_LEVEL_MANDATORY, |
| 1102 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1100 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1103 base::WrapUnique(new base::StringValue(kNewTabURL)), nullptr); | 1101 base::MakeUnique<base::StringValue>(kNewTabURL), nullptr); |
| 1104 UpdateProviderPolicy(policies); | 1102 UpdateProviderPolicy(policies); |
| 1105 default_search = service->GetDefaultSearchProvider(); | 1103 default_search = service->GetDefaultSearchProvider(); |
| 1106 ASSERT_TRUE(default_search); | 1104 ASSERT_TRUE(default_search); |
| 1107 EXPECT_EQ(kKeyword, default_search->keyword()); | 1105 EXPECT_EQ(kKeyword, default_search->keyword()); |
| 1108 EXPECT_EQ(kSearchURL, default_search->url()); | 1106 EXPECT_EQ(kSearchURL, default_search->url()); |
| 1109 EXPECT_EQ(kInstantURL, default_search->instant_url()); | 1107 EXPECT_EQ(kInstantURL, default_search->instant_url()); |
| 1110 EXPECT_EQ(2U, default_search->alternate_urls().size()); | 1108 EXPECT_EQ(2U, default_search->alternate_urls().size()); |
| 1111 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); | 1109 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); |
| 1112 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); | 1110 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); |
| 1113 EXPECT_EQ(kSearchTermsReplacementKey, | 1111 EXPECT_EQ(kSearchTermsReplacementKey, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1124 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1122 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); |
| 1125 content::WebContents* web_contents = | 1123 content::WebContents* web_contents = |
| 1126 browser()->tab_strip_model()->GetActiveWebContents(); | 1124 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1127 GURL expected("http://search.example/search?q=stuff+to+search+for"); | 1125 GURL expected("http://search.example/search?q=stuff+to+search+for"); |
| 1128 EXPECT_EQ(expected, web_contents->GetURL()); | 1126 EXPECT_EQ(expected, web_contents->GetURL()); |
| 1129 | 1127 |
| 1130 // Verify that searching from the omnibox can be disabled. | 1128 // Verify that searching from the omnibox can be disabled. |
| 1131 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1129 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 1132 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 1130 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
| 1133 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1131 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1134 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 1132 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 1135 EXPECT_TRUE(service->GetDefaultSearchProvider()); | 1133 EXPECT_TRUE(service->GetDefaultSearchProvider()); |
| 1136 UpdateProviderPolicy(policies); | 1134 UpdateProviderPolicy(policies); |
| 1137 EXPECT_FALSE(service->GetDefaultSearchProvider()); | 1135 EXPECT_FALSE(service->GetDefaultSearchProvider()); |
| 1138 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); | 1136 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); |
| 1139 // This means that submitting won't trigger any action. | 1137 // This means that submitting won't trigger any action. |
| 1140 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); | 1138 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); |
| 1141 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); | 1139 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); |
| 1142 } | 1140 } |
| 1143 | 1141 |
| 1144 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { | 1142 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { |
| 1145 // Add an individual proxy policy value. | 1143 // Add an individual proxy policy value. |
| 1146 PolicyMap policies; | 1144 PolicyMap policies; |
| 1147 policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1145 policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1148 POLICY_SOURCE_CLOUD, | 1146 POLICY_SOURCE_CLOUD, base::MakeUnique<base::FundamentalValue>(3), |
| 1149 base::WrapUnique(new base::FundamentalValue(3)), nullptr); | 1147 nullptr); |
| 1150 UpdateProviderPolicy(policies); | 1148 UpdateProviderPolicy(policies); |
| 1151 | 1149 |
| 1152 // It should be removed and replaced with a dictionary. | 1150 // It should be removed and replaced with a dictionary. |
| 1153 PolicyMap expected; | 1151 PolicyMap expected; |
| 1154 std::unique_ptr<base::DictionaryValue> expected_value( | 1152 std::unique_ptr<base::DictionaryValue> expected_value( |
| 1155 new base::DictionaryValue); | 1153 new base::DictionaryValue); |
| 1156 expected_value->SetInteger(key::kProxyServerMode, 3); | 1154 expected_value->SetInteger(key::kProxyServerMode, 3); |
| 1157 expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1155 expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1158 POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); | 1156 POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); |
| 1159 | 1157 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1182 | 1180 |
| 1183 // Go over all combinations of (undefined,true,false) for the three policies. | 1181 // Go over all combinations of (undefined,true,false) for the three policies. |
| 1184 for (int i = 0; i < 3 * 3 * 3; i++) { | 1182 for (int i = 0; i < 3 * 3 * 3; i++) { |
| 1185 int legacy = i % 3; | 1183 int legacy = i % 3; |
| 1186 int google = (i / 3) % 3; | 1184 int google = (i / 3) % 3; |
| 1187 int youtube = i / (3 * 3); | 1185 int youtube = i / (3 * 3); |
| 1188 | 1186 |
| 1189 // Override the default SafeSearch setting using policies. | 1187 // Override the default SafeSearch setting using policies. |
| 1190 ApplySafeSearchPolicy( | 1188 ApplySafeSearchPolicy( |
| 1191 legacy == 0 ? nullptr | 1189 legacy == 0 ? nullptr |
| 1192 : base::WrapUnique(new base::FundamentalValue(legacy == 1)), | 1190 : base::MakeUnique<base::FundamentalValue>(legacy == 1), |
| 1193 google == 0 ? nullptr | 1191 google == 0 ? nullptr |
| 1194 : base::WrapUnique(new base::FundamentalValue(google == 1)), | 1192 : base::MakeUnique<base::FundamentalValue>(google == 1), |
| 1195 youtube == 0 ? nullptr : base::WrapUnique( | 1193 youtube == 0 ? nullptr |
| 1196 new base::FundamentalValue(youtube == 1))); | 1194 : base::MakeUnique<base::FundamentalValue>(youtube == 1)); |
| 1197 | 1195 |
| 1198 // The legacy policy should only have an effect if both google and youtube | 1196 // The legacy policy should only have an effect if both google and youtube |
| 1199 // are undefined. | 1197 // are undefined. |
| 1200 bool legacy_in_effect = (google == 0 && youtube == 0 && legacy != 0); | 1198 bool legacy_in_effect = (google == 0 && youtube == 0 && legacy != 0); |
| 1201 bool legacy_enabled = legacy_in_effect && legacy == 1; | 1199 bool legacy_enabled = legacy_in_effect && legacy == 1; |
| 1202 | 1200 |
| 1203 PrefService* prefs = browser()->profile()->GetPrefs(); | 1201 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 1204 EXPECT_EQ(google != 0 || legacy_in_effect, | 1202 EXPECT_EQ(google != 0 || legacy_in_effect, |
| 1205 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); | 1203 prefs->IsManagedPreference(prefs::kForceGoogleSafeSearch)); |
| 1206 EXPECT_EQ(google == 1 || legacy_enabled, | 1204 EXPECT_EQ(google == 1 || legacy_enabled, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1222 | 1220 |
| 1223 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1221 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 1224 // WebGL is enabled by default. | 1222 // WebGL is enabled by default. |
| 1225 content::WebContents* contents = | 1223 content::WebContents* contents = |
| 1226 browser()->tab_strip_model()->GetActiveWebContents(); | 1224 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1227 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1225 EXPECT_TRUE(IsWebGLEnabled(contents)); |
| 1228 // Disable with a policy. | 1226 // Disable with a policy. |
| 1229 PolicyMap policies; | 1227 PolicyMap policies; |
| 1230 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1228 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1231 POLICY_SOURCE_CLOUD, | 1229 POLICY_SOURCE_CLOUD, |
| 1232 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 1230 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 1233 UpdateProviderPolicy(policies); | 1231 UpdateProviderPolicy(policies); |
| 1234 // Crash and reload the tab to get a new renderer. | 1232 // Crash and reload the tab to get a new renderer. |
| 1235 content::CrashTab(contents); | 1233 content::CrashTab(contents); |
| 1236 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1234 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
| 1237 EXPECT_FALSE(IsWebGLEnabled(contents)); | 1235 EXPECT_FALSE(IsWebGLEnabled(contents)); |
| 1238 // Enable with a policy. | 1236 // Enable with a policy. |
| 1239 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1237 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 1240 POLICY_SOURCE_CLOUD, | 1238 POLICY_SOURCE_CLOUD, |
| 1241 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 1239 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 1242 UpdateProviderPolicy(policies); | 1240 UpdateProviderPolicy(policies); |
| 1243 content::CrashTab(contents); | 1241 content::CrashTab(contents); |
| 1244 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 1242 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
| 1245 EXPECT_TRUE(IsWebGLEnabled(contents)); | 1243 EXPECT_TRUE(IsWebGLEnabled(contents)); |
| 1246 } | 1244 } |
| 1247 | 1245 |
| 1248 namespace { | 1246 namespace { |
| 1249 | 1247 |
| 1250 // The following helpers retrieve whether https:// URL stripping is | 1248 // The following helpers retrieve whether https:// URL stripping is |
| 1251 // enabled for PAC scripts. It needs to run on the IO thread. | 1249 // enabled for PAC scripts. It needs to run on the IO thread. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 ASSERT_EQ(1u, infobar_service->infobar_count()); | 1421 ASSERT_EQ(1u, infobar_service->infobar_count()); |
| 1424 EXPECT_TRUE( | 1422 EXPECT_TRUE( |
| 1425 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); | 1423 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); |
| 1426 // And the plugin isn't running. | 1424 // And the plugin isn't running. |
| 1427 EXPECT_EQ(0, CountPlugins()); | 1425 EXPECT_EQ(0, CountPlugins()); |
| 1428 | 1426 |
| 1429 // Now set a policy to always authorize this. | 1427 // Now set a policy to always authorize this. |
| 1430 PolicyMap policies; | 1428 PolicyMap policies; |
| 1431 policies.Set(key::kAlwaysAuthorizePlugins, POLICY_LEVEL_MANDATORY, | 1429 policies.Set(key::kAlwaysAuthorizePlugins, POLICY_LEVEL_MANDATORY, |
| 1432 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1430 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1433 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 1431 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 1434 UpdateProviderPolicy(policies); | 1432 UpdateProviderPolicy(policies); |
| 1435 // Reloading the page shouldn't trigger the infobar this time. | 1433 // Reloading the page shouldn't trigger the infobar this time. |
| 1436 ui_test_utils::NavigateToURL(browser(), url); | 1434 ui_test_utils::NavigateToURL(browser(), url); |
| 1437 EXPECT_EQ(0u, infobar_service->infobar_count()); | 1435 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 1438 // And the plugin started automatically. | 1436 // And the plugin started automatically. |
| 1439 EXPECT_EQ(1, CountPlugins()); | 1437 EXPECT_EQ(1, CountPlugins()); |
| 1440 } | 1438 } |
| 1441 | 1439 |
| 1442 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { | 1440 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { |
| 1443 // Verifies that access to the developer tools can be disabled. | 1441 // Verifies that access to the developer tools can be disabled. |
| 1444 | 1442 |
| 1445 // Open devtools. | 1443 // Open devtools. |
| 1446 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1444 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
| 1447 content::WebContents* contents = | 1445 content::WebContents* contents = |
| 1448 browser()->tab_strip_model()->GetActiveWebContents(); | 1446 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1449 DevToolsWindow* devtools_window = | 1447 DevToolsWindow* devtools_window = |
| 1450 DevToolsWindow::GetInstanceForInspectedWebContents(contents); | 1448 DevToolsWindow::GetInstanceForInspectedWebContents(contents); |
| 1451 EXPECT_TRUE(devtools_window); | 1449 EXPECT_TRUE(devtools_window); |
| 1452 | 1450 |
| 1453 // Disable devtools via policy. | 1451 // Disable devtools via policy. |
| 1454 PolicyMap policies; | 1452 PolicyMap policies; |
| 1455 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, | 1453 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, |
| 1456 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1454 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1457 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 1455 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 1458 content::WindowedNotificationObserver close_observer( | 1456 content::WindowedNotificationObserver close_observer( |
| 1459 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1457 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1460 content::Source<content::WebContents>( | 1458 content::Source<content::WebContents>( |
| 1461 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); | 1459 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); |
| 1462 UpdateProviderPolicy(policies); | 1460 UpdateProviderPolicy(policies); |
| 1463 // wait for devtools close | 1461 // wait for devtools close |
| 1464 close_observer.Wait(); | 1462 close_observer.Wait(); |
| 1465 // The existing devtools window should have closed. | 1463 // The existing devtools window should have closed. |
| 1466 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); | 1464 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); |
| 1467 // And it's not possible to open it again. | 1465 // And it's not possible to open it again. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 | 1514 |
| 1517 // Verify that downloads end up on the default directory. | 1515 // Verify that downloads end up on the default directory. |
| 1518 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1516 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 1519 DownloadAndVerifyFile(browser(), initial_dir.path(), file); | 1517 DownloadAndVerifyFile(browser(), initial_dir.path(), file); |
| 1520 base::DieFileDie(initial_dir.path().Append(file), false); | 1518 base::DieFileDie(initial_dir.path().Append(file), false); |
| 1521 | 1519 |
| 1522 // Override the download directory with the policy and verify a download. | 1520 // Override the download directory with the policy and verify a download. |
| 1523 base::ScopedTempDir forced_dir; | 1521 base::ScopedTempDir forced_dir; |
| 1524 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); | 1522 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); |
| 1525 PolicyMap policies; | 1523 PolicyMap policies; |
| 1526 policies.Set( | 1524 policies.Set(key::kDownloadDirectory, POLICY_LEVEL_MANDATORY, |
| 1527 key::kDownloadDirectory, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1525 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1528 POLICY_SOURCE_CLOUD, | 1526 base::MakeUnique<base::StringValue>(forced_dir.path().value()), |
| 1529 base::WrapUnique(new base::StringValue(forced_dir.path().value())), | 1527 nullptr); |
| 1530 nullptr); | |
| 1531 UpdateProviderPolicy(policies); | 1528 UpdateProviderPolicy(policies); |
| 1532 DownloadAndVerifyFile(browser(), forced_dir.path(), file); | 1529 DownloadAndVerifyFile(browser(), forced_dir.path(), file); |
| 1533 // Verify that the first download location wasn't affected. | 1530 // Verify that the first download location wasn't affected. |
| 1534 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); | 1531 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); |
| 1535 } | 1532 } |
| 1536 | 1533 |
| 1537 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) { | 1534 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) { |
| 1538 // Verifies that blacklisted extensions can't be installed. | 1535 // Verifies that blacklisted extensions can't be installed. |
| 1539 ExtensionService* service = extension_service(); | 1536 ExtensionService* service = extension_service(); |
| 1540 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1537 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), | 2125 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), |
| 2129 browser()->profile()->GetHomePage()); | 2126 browser()->profile()->GetHomePage()); |
| 2130 content::WebContents* contents = | 2127 content::WebContents* contents = |
| 2131 browser()->tab_strip_model()->GetActiveWebContents(); | 2128 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2132 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); | 2129 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); |
| 2133 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2130 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 2134 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); | 2131 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); |
| 2135 | 2132 |
| 2136 // Now override with policy. | 2133 // Now override with policy. |
| 2137 PolicyMap policies; | 2134 PolicyMap policies; |
| 2138 policies.Set( | 2135 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, |
| 2139 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2136 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2140 POLICY_SOURCE_CLOUD, | 2137 base::MakeUnique<base::StringValue>(chrome::kChromeUICreditsURL), |
| 2141 base::WrapUnique(new base::StringValue(chrome::kChromeUICreditsURL)), | 2138 nullptr); |
| 2142 nullptr); | |
| 2143 UpdateProviderPolicy(policies); | 2139 UpdateProviderPolicy(policies); |
| 2144 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2140 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 2145 content::WaitForLoadStop(contents); | 2141 content::WaitForLoadStop(contents); |
| 2146 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); | 2142 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); |
| 2147 | 2143 |
| 2148 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, | 2144 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, |
| 2149 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2145 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2150 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2146 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 2151 UpdateProviderPolicy(policies); | 2147 UpdateProviderPolicy(policies); |
| 2152 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 2148 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 2153 content::WaitForLoadStop(contents); | 2149 content::WaitForLoadStop(contents); |
| 2154 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); | 2150 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); |
| 2155 } | 2151 } |
| 2156 | 2152 |
| 2157 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { | 2153 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
| 2158 // Verifies that incognito windows can't be opened when disabled by policy. | 2154 // Verifies that incognito windows can't be opened when disabled by policy. |
| 2159 | 2155 |
| 2160 const BrowserList* active_browser_list = BrowserList::GetInstance(); | 2156 const BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 2161 | 2157 |
| 2162 // Disable incognito via policy and verify that incognito windows can't be | 2158 // Disable incognito via policy and verify that incognito windows can't be |
| 2163 // opened. | 2159 // opened. |
| 2164 EXPECT_EQ(1u, active_browser_list->size()); | 2160 EXPECT_EQ(1u, active_browser_list->size()); |
| 2165 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); | 2161 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); |
| 2166 PolicyMap policies; | 2162 PolicyMap policies; |
| 2167 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 2163 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
| 2168 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2164 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2169 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2165 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2170 UpdateProviderPolicy(policies); | 2166 UpdateProviderPolicy(policies); |
| 2171 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2167 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 2172 EXPECT_EQ(1u, active_browser_list->size()); | 2168 EXPECT_EQ(1u, active_browser_list->size()); |
| 2173 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); | 2169 EXPECT_FALSE(BrowserList::IsIncognitoSessionActive()); |
| 2174 | 2170 |
| 2175 // Enable via policy and verify that incognito windows can be opened. | 2171 // Enable via policy and verify that incognito windows can be opened. |
| 2176 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 2172 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
| 2177 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2173 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2178 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2174 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 2179 UpdateProviderPolicy(policies); | 2175 UpdateProviderPolicy(policies); |
| 2180 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 2176 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 2181 EXPECT_EQ(2u, active_browser_list->size()); | 2177 EXPECT_EQ(2u, active_browser_list->size()); |
| 2182 EXPECT_TRUE(BrowserList::IsIncognitoSessionActive()); | 2178 EXPECT_TRUE(BrowserList::IsIncognitoSessionActive()); |
| 2183 } | 2179 } |
| 2184 | 2180 |
| 2185 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 2181 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
| 2186 // Verifies that Javascript can be disabled. | 2182 // Verifies that Javascript can be disabled. |
| 2187 content::WebContents* contents = | 2183 content::WebContents* contents = |
| 2188 browser()->tab_strip_model()->GetActiveWebContents(); | 2184 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2189 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2185 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2190 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2186 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
| 2191 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2187 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
| 2192 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2188 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
| 2193 | 2189 |
| 2194 // Disable Javascript via policy. | 2190 // Disable Javascript via policy. |
| 2195 PolicyMap policies; | 2191 PolicyMap policies; |
| 2196 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, | 2192 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, |
| 2197 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2193 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2198 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2194 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2199 UpdateProviderPolicy(policies); | 2195 UpdateProviderPolicy(policies); |
| 2200 // Reload the page. | 2196 // Reload the page. |
| 2201 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2197 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2202 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2198 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
| 2203 // Developer tools still work when javascript is disabled. | 2199 // Developer tools still work when javascript is disabled. |
| 2204 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 2200 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
| 2205 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 2201 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
| 2206 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); | 2202 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); |
| 2207 // Javascript is always enabled for the internal pages. | 2203 // Javascript is always enabled for the internal pages. |
| 2208 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 2204 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 2209 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2205 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2210 | 2206 |
| 2211 // The javascript content setting policy overrides the javascript policy. | 2207 // The javascript content setting policy overrides the javascript policy. |
| 2212 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2208 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2213 EXPECT_FALSE(IsJavascriptEnabled(contents)); | 2209 EXPECT_FALSE(IsJavascriptEnabled(contents)); |
| 2214 policies.Set( | 2210 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, |
| 2215 key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2211 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2216 POLICY_SOURCE_CLOUD, | 2212 base::MakeUnique<base::FundamentalValue>(CONTENT_SETTING_ALLOW), |
| 2217 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ALLOW)), | 2213 nullptr); |
| 2218 nullptr); | |
| 2219 UpdateProviderPolicy(policies); | 2214 UpdateProviderPolicy(policies); |
| 2220 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 2215 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 2221 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 2216 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 2222 } | 2217 } |
| 2223 | 2218 |
| 2224 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { | 2219 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { |
| 2225 PrefService* prefs = browser()->profile()->GetPrefs(); | 2220 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2226 | 2221 |
| 2227 // Enabled by default. | 2222 // Enabled by default. |
| 2228 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2223 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
| 2229 | 2224 |
| 2230 // Disable by old, deprecated policy. | 2225 // Disable by old, deprecated policy. |
| 2231 PolicyMap policies; | 2226 PolicyMap policies; |
| 2232 policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY, | 2227 policies.Set(key::kDnsPrefetchingEnabled, POLICY_LEVEL_MANDATORY, |
| 2233 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2228 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2234 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2229 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2235 UpdateProviderPolicy(policies); | 2230 UpdateProviderPolicy(policies); |
| 2236 | 2231 |
| 2237 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); | 2232 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); |
| 2238 | 2233 |
| 2239 // Enabled by new policy, this should override old one. | 2234 // Enabled by new policy, this should override old one. |
| 2240 policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY, | 2235 policies.Set(key::kNetworkPredictionOptions, POLICY_LEVEL_MANDATORY, |
| 2241 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2236 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2242 base::WrapUnique(new base::FundamentalValue( | 2237 base::MakeUnique<base::FundamentalValue>( |
| 2243 chrome_browser_net::NETWORK_PREDICTION_ALWAYS)), | 2238 chrome_browser_net::NETWORK_PREDICTION_ALWAYS), |
| 2244 nullptr); | 2239 nullptr); |
| 2245 UpdateProviderPolicy(policies); | 2240 UpdateProviderPolicy(policies); |
| 2246 | 2241 |
| 2247 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); | 2242 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
| 2248 } | 2243 } |
| 2249 | 2244 |
| 2250 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { | 2245 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { |
| 2251 // Verifies that browsing history is not saved. | 2246 // Verifies that browsing history is not saved. |
| 2252 PolicyMap policies; | 2247 PolicyMap policies; |
| 2253 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, | 2248 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
| 2254 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2249 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2255 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2250 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 2256 UpdateProviderPolicy(policies); | 2251 UpdateProviderPolicy(policies); |
| 2257 GURL url = ui_test_utils::GetTestUrl( | 2252 GURL url = ui_test_utils::GetTestUrl( |
| 2258 base::FilePath(base::FilePath::kCurrentDirectory), | 2253 base::FilePath(base::FilePath::kCurrentDirectory), |
| 2259 base::FilePath(FILE_PATH_LITERAL("empty.html"))); | 2254 base::FilePath(FILE_PATH_LITERAL("empty.html"))); |
| 2260 ui_test_utils::NavigateToURL(browser(), url); | 2255 ui_test_utils::NavigateToURL(browser(), url); |
| 2261 // Verify that the navigation wasn't saved in the history. | 2256 // Verify that the navigation wasn't saved in the history. |
| 2262 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); | 2257 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); |
| 2263 EXPECT_EQ(0u, enumerator1.urls().size()); | 2258 EXPECT_EQ(0u, enumerator1.urls().size()); |
| 2264 | 2259 |
| 2265 // Now flip the policy and try again. | 2260 // Now flip the policy and try again. |
| 2266 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, | 2261 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, |
| 2267 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2262 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2268 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2263 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2269 UpdateProviderPolicy(policies); | 2264 UpdateProviderPolicy(policies); |
| 2270 ui_test_utils::NavigateToURL(browser(), url); | 2265 ui_test_utils::NavigateToURL(browser(), url); |
| 2271 // Verify that the navigation was saved in the history. | 2266 // Verify that the navigation was saved in the history. |
| 2272 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); | 2267 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); |
| 2273 ASSERT_EQ(1u, enumerator2.urls().size()); | 2268 ASSERT_EQ(1u, enumerator2.urls().size()); |
| 2274 EXPECT_EQ(url, enumerator2.urls()[0]); | 2269 EXPECT_EQ(url, enumerator2.urls()[0]); |
| 2275 } | 2270 } |
| 2276 | 2271 |
| 2277 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 | 2272 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 |
| 2278 #if !defined(USE_AURA) | 2273 #if !defined(USE_AURA) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2513 | 2508 |
| 2514 CheckCanOpenURL(browser(), file_path1.c_str()); | 2509 CheckCanOpenURL(browser(), file_path1.c_str()); |
| 2515 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2510 CheckURLIsBlocked(browser(), file_path2.c_str()); |
| 2516 } | 2511 } |
| 2517 | 2512 |
| 2518 #if !defined(OS_MACOSX) | 2513 #if !defined(OS_MACOSX) |
| 2519 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { | 2514 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { |
| 2520 PolicyMap policies; | 2515 PolicyMap policies; |
| 2521 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, | 2516 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
| 2522 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2517 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2523 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2518 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2524 UpdateProviderPolicy(policies); | 2519 UpdateProviderPolicy(policies); |
| 2525 | 2520 |
| 2526 BrowserWindow* browser_window = browser()->window(); | 2521 BrowserWindow* browser_window = browser()->window(); |
| 2527 ASSERT_TRUE(browser_window); | 2522 ASSERT_TRUE(browser_window); |
| 2528 | 2523 |
| 2529 EXPECT_FALSE(browser_window->IsFullscreen()); | 2524 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 2530 chrome::ToggleFullscreenMode(browser()); | 2525 chrome::ToggleFullscreenMode(browser()); |
| 2531 EXPECT_FALSE(browser_window->IsFullscreen()); | 2526 EXPECT_FALSE(browser_window->IsFullscreen()); |
| 2532 } | 2527 } |
| 2533 | 2528 |
| 2534 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { | 2529 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { |
| 2535 PolicyMap policies; | 2530 PolicyMap policies; |
| 2536 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, | 2531 policies.Set(key::kFullscreenAllowed, POLICY_LEVEL_MANDATORY, |
| 2537 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2532 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2538 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2533 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2539 UpdateProviderPolicy(policies); | 2534 UpdateProviderPolicy(policies); |
| 2540 | 2535 |
| 2541 const extensions::Extension* extension = | 2536 const extensions::Extension* extension = |
| 2542 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); | 2537 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); |
| 2543 ASSERT_TRUE(extension); | 2538 ASSERT_TRUE(extension); |
| 2544 | 2539 |
| 2545 // Launch an app that tries to open a fullscreen window. | 2540 // Launch an app that tries to open a fullscreen window. |
| 2546 TestAddAppWindowObserver add_window_observer( | 2541 TestAddAppWindowObserver add_window_observer( |
| 2547 extensions::AppWindowRegistry::Get(browser()->profile())); | 2542 extensions::AppWindowRegistry::Get(browser()->profile())); |
| 2548 OpenApplication(AppLaunchParams( | 2543 OpenApplication(AppLaunchParams( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2597 | 2592 |
| 2598 bool prior_state = audio_handler->IsOutputMuted(); | 2593 bool prior_state = audio_handler->IsOutputMuted(); |
| 2599 // Make sure the audio is not muted and then toggle the policy and observe | 2594 // Make sure the audio is not muted and then toggle the policy and observe |
| 2600 // if the output mute changed event is fired. | 2595 // if the output mute changed event is fired. |
| 2601 audio_handler->SetOutputMute(false); | 2596 audio_handler->SetOutputMute(false); |
| 2602 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2597 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 2603 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2598 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2604 PolicyMap policies; | 2599 PolicyMap policies; |
| 2605 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, | 2600 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
| 2606 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2601 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2607 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2602 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2608 UpdateProviderPolicy(policies); | 2603 UpdateProviderPolicy(policies); |
| 2609 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2604 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2610 // This should not change the state now and should not trigger output mute | 2605 // This should not change the state now and should not trigger output mute |
| 2611 // changed event. | 2606 // changed event. |
| 2612 audio_handler->SetOutputMute(false); | 2607 audio_handler->SetOutputMute(false); |
| 2613 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2608 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2614 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2609 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2615 | 2610 |
| 2616 // Toggle back and observe if the output mute changed event is fired. | 2611 // Toggle back and observe if the output mute changed event is fired. |
| 2617 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, | 2612 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, |
| 2618 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2613 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2619 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2614 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 2620 UpdateProviderPolicy(policies); | 2615 UpdateProviderPolicy(policies); |
| 2621 EXPECT_FALSE(audio_handler->IsOutputMuted()); | 2616 EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 2622 EXPECT_EQ(1, test_observer->output_mute_changed_count()); | 2617 EXPECT_EQ(1, test_observer->output_mute_changed_count()); |
| 2623 audio_handler->SetOutputMute(true); | 2618 audio_handler->SetOutputMute(true); |
| 2624 EXPECT_TRUE(audio_handler->IsOutputMuted()); | 2619 EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 2625 EXPECT_EQ(2, test_observer->output_mute_changed_count()); | 2620 EXPECT_EQ(2, test_observer->output_mute_changed_count()); |
| 2626 // Revert the prior state. | 2621 // Revert the prior state. |
| 2627 audio_handler->SetOutputMute(prior_state); | 2622 audio_handler->SetOutputMute(prior_state); |
| 2628 audio_handler->RemoveAudioObserver(test_observer.get()); | 2623 audio_handler->RemoveAudioObserver(test_observer.get()); |
| 2629 } | 2624 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2644 chrome::NOTIFICATION_APP_TERMINATING, | 2639 chrome::NOTIFICATION_APP_TERMINATING, |
| 2645 content::NotificationService::AllSources()); | 2640 content::NotificationService::AllSources()); |
| 2646 | 2641 |
| 2647 // Set the session length limit to 3 hours. Verify that the session is not | 2642 // Set the session length limit to 3 hours. Verify that the session is not |
| 2648 // terminated. | 2643 // terminated. |
| 2649 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2644 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2650 .Times(0); | 2645 .Times(0); |
| 2651 PolicyMap policies; | 2646 PolicyMap policies; |
| 2652 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2647 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2653 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2648 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2654 base::WrapUnique(new base::FundamentalValue(kThreeHoursInMs)), | 2649 base::MakeUnique<base::FundamentalValue>(kThreeHoursInMs), |
| 2655 nullptr); | 2650 nullptr); |
| 2656 UpdateProviderPolicy(policies); | 2651 UpdateProviderPolicy(policies); |
| 2657 base::RunLoop().RunUntilIdle(); | 2652 base::RunLoop().RunUntilIdle(); |
| 2658 Mock::VerifyAndClearExpectations(&observer); | 2653 Mock::VerifyAndClearExpectations(&observer); |
| 2659 | 2654 |
| 2660 // Decrease the session length limit to 1 hour. Verify that the session is | 2655 // Decrease the session length limit to 1 hour. Verify that the session is |
| 2661 // terminated immediately. | 2656 // terminated immediately. |
| 2662 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2657 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
| 2663 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2658 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2664 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2659 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2665 base::WrapUnique(new base::FundamentalValue(kOneHourInMs)), | 2660 base::MakeUnique<base::FundamentalValue>(kOneHourInMs), nullptr); |
| 2666 nullptr); | |
| 2667 UpdateProviderPolicy(policies); | 2661 UpdateProviderPolicy(policies); |
| 2668 base::RunLoop().RunUntilIdle(); | 2662 base::RunLoop().RunUntilIdle(); |
| 2669 Mock::VerifyAndClearExpectations(&observer); | 2663 Mock::VerifyAndClearExpectations(&observer); |
| 2670 } | 2664 } |
| 2671 | 2665 |
| 2672 // Disabled, see http://crbug.com/554728. | 2666 // Disabled, see http://crbug.com/554728. |
| 2673 IN_PROC_BROWSER_TEST_F(PolicyTest, | 2667 IN_PROC_BROWSER_TEST_F(PolicyTest, |
| 2674 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { | 2668 DISABLED_PRE_WaitForInitialUserActivityUnsatisfied) { |
| 2675 // Indicate that the session started 2 hours ago and no user activity has | 2669 // Indicate that the session started 2 hours ago and no user activity has |
| 2676 // occurred yet. | 2670 // occurred yet. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2730 chrome::NOTIFICATION_APP_TERMINATING, | 2724 chrome::NOTIFICATION_APP_TERMINATING, |
| 2731 content::NotificationService::AllSources()); | 2725 content::NotificationService::AllSources()); |
| 2732 | 2726 |
| 2733 // Require initial user activity and set the session length limit to 3 hours. | 2727 // Require initial user activity and set the session length limit to 3 hours. |
| 2734 // Verify that the session is not terminated. | 2728 // Verify that the session is not terminated. |
| 2735 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) | 2729 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) |
| 2736 .Times(0); | 2730 .Times(0); |
| 2737 PolicyMap policies; | 2731 PolicyMap policies; |
| 2738 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, | 2732 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, |
| 2739 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2733 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2740 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2734 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 2741 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2735 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2742 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2736 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2743 base::WrapUnique(new base::FundamentalValue(kThreeHoursInMs)), | 2737 base::MakeUnique<base::FundamentalValue>(kThreeHoursInMs), |
| 2744 nullptr); | 2738 nullptr); |
| 2745 UpdateProviderPolicy(policies); | 2739 UpdateProviderPolicy(policies); |
| 2746 base::RunLoop().RunUntilIdle(); | 2740 base::RunLoop().RunUntilIdle(); |
| 2747 Mock::VerifyAndClearExpectations(&observer); | 2741 Mock::VerifyAndClearExpectations(&observer); |
| 2748 | 2742 |
| 2749 // Decrease the session length limit to 1 hour. Verify that the session is | 2743 // Decrease the session length limit to 1 hour. Verify that the session is |
| 2750 // terminated immediately. | 2744 // terminated immediately. |
| 2751 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); | 2745 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); |
| 2752 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, | 2746 policies.Set(key::kSessionLengthLimit, POLICY_LEVEL_MANDATORY, |
| 2753 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2747 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2754 base::WrapUnique(new base::FundamentalValue(kOneHourInMs)), | 2748 base::MakeUnique<base::FundamentalValue>(kOneHourInMs), nullptr); |
| 2755 nullptr); | |
| 2756 UpdateProviderPolicy(policies); | 2749 UpdateProviderPolicy(policies); |
| 2757 base::RunLoop().RunUntilIdle(); | 2750 base::RunLoop().RunUntilIdle(); |
| 2758 Mock::VerifyAndClearExpectations(&observer); | 2751 Mock::VerifyAndClearExpectations(&observer); |
| 2759 } | 2752 } |
| 2760 | 2753 |
| 2761 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { | 2754 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { |
| 2762 // Verifies that the large cursor accessibility feature can be controlled | 2755 // Verifies that the large cursor accessibility feature can be controlled |
| 2763 // through policy. | 2756 // through policy. |
| 2764 chromeos::AccessibilityManager* accessibility_manager = | 2757 chromeos::AccessibilityManager* accessibility_manager = |
| 2765 chromeos::AccessibilityManager::Get(); | 2758 chromeos::AccessibilityManager::Get(); |
| 2766 | 2759 |
| 2767 // Manually enable the large cursor. | 2760 // Manually enable the large cursor. |
| 2768 accessibility_manager->EnableLargeCursor(true); | 2761 accessibility_manager->EnableLargeCursor(true); |
| 2769 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); | 2762 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); |
| 2770 | 2763 |
| 2771 // Verify that policy overrides the manual setting. | 2764 // Verify that policy overrides the manual setting. |
| 2772 PolicyMap policies; | 2765 PolicyMap policies; |
| 2773 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, | 2766 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, |
| 2774 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2767 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2775 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2768 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2776 UpdateProviderPolicy(policies); | 2769 UpdateProviderPolicy(policies); |
| 2777 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2770 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
| 2778 | 2771 |
| 2779 // Verify that the large cursor cannot be enabled manually anymore. | 2772 // Verify that the large cursor cannot be enabled manually anymore. |
| 2780 accessibility_manager->EnableLargeCursor(true); | 2773 accessibility_manager->EnableLargeCursor(true); |
| 2781 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); | 2774 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); |
| 2782 } | 2775 } |
| 2783 | 2776 |
| 2784 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { | 2777 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { |
| 2785 // Verifies that the spoken feedback accessibility feature can be controlled | 2778 // Verifies that the spoken feedback accessibility feature can be controlled |
| 2786 // through policy. | 2779 // through policy. |
| 2787 chromeos::AccessibilityManager* accessibility_manager = | 2780 chromeos::AccessibilityManager* accessibility_manager = |
| 2788 chromeos::AccessibilityManager::Get(); | 2781 chromeos::AccessibilityManager::Get(); |
| 2789 | 2782 |
| 2790 // Manually enable spoken feedback. | 2783 // Manually enable spoken feedback. |
| 2791 accessibility_manager->EnableSpokenFeedback(true, | 2784 accessibility_manager->EnableSpokenFeedback(true, |
| 2792 ash::A11Y_NOTIFICATION_NONE); | 2785 ash::A11Y_NOTIFICATION_NONE); |
| 2793 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2786 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2794 | 2787 |
| 2795 // Verify that policy overrides the manual setting. | 2788 // Verify that policy overrides the manual setting. |
| 2796 PolicyMap policies; | 2789 PolicyMap policies; |
| 2797 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, | 2790 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, |
| 2798 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2791 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2799 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2792 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2800 UpdateProviderPolicy(policies); | 2793 UpdateProviderPolicy(policies); |
| 2801 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2794 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2802 | 2795 |
| 2803 // Verify that spoken feedback cannot be enabled manually anymore. | 2796 // Verify that spoken feedback cannot be enabled manually anymore. |
| 2804 accessibility_manager->EnableSpokenFeedback(true, | 2797 accessibility_manager->EnableSpokenFeedback(true, |
| 2805 ash::A11Y_NOTIFICATION_NONE); | 2798 ash::A11Y_NOTIFICATION_NONE); |
| 2806 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); | 2799 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); |
| 2807 } | 2800 } |
| 2808 | 2801 |
| 2809 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { | 2802 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { |
| 2810 // Verifies that the high contrast mode accessibility feature can be | 2803 // Verifies that the high contrast mode accessibility feature can be |
| 2811 // controlled through policy. | 2804 // controlled through policy. |
| 2812 chromeos::AccessibilityManager* accessibility_manager = | 2805 chromeos::AccessibilityManager* accessibility_manager = |
| 2813 chromeos::AccessibilityManager::Get(); | 2806 chromeos::AccessibilityManager::Get(); |
| 2814 | 2807 |
| 2815 // Manually enable high contrast mode. | 2808 // Manually enable high contrast mode. |
| 2816 accessibility_manager->EnableHighContrast(true); | 2809 accessibility_manager->EnableHighContrast(true); |
| 2817 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); | 2810 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); |
| 2818 | 2811 |
| 2819 // Verify that policy overrides the manual setting. | 2812 // Verify that policy overrides the manual setting. |
| 2820 PolicyMap policies; | 2813 PolicyMap policies; |
| 2821 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, | 2814 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, |
| 2822 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2815 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2823 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2816 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2824 UpdateProviderPolicy(policies); | 2817 UpdateProviderPolicy(policies); |
| 2825 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2818 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
| 2826 | 2819 |
| 2827 // Verify that high contrast mode cannot be enabled manually anymore. | 2820 // Verify that high contrast mode cannot be enabled manually anymore. |
| 2828 accessibility_manager->EnableHighContrast(true); | 2821 accessibility_manager->EnableHighContrast(true); |
| 2829 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); | 2822 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); |
| 2830 } | 2823 } |
| 2831 | 2824 |
| 2832 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { | 2825 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { |
| 2833 // Verifies that the screen magnifier can be disabled through policy. | 2826 // Verifies that the screen magnifier can be disabled through policy. |
| 2834 chromeos::MagnificationManager* magnification_manager = | 2827 chromeos::MagnificationManager* magnification_manager = |
| 2835 chromeos::MagnificationManager::Get(); | 2828 chromeos::MagnificationManager::Get(); |
| 2836 | 2829 |
| 2837 // Manually enable the full-screen magnifier. | 2830 // Manually enable the full-screen magnifier. |
| 2838 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL); | 2831 magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL); |
| 2839 magnification_manager->SetMagnifierEnabled(true); | 2832 magnification_manager->SetMagnifierEnabled(true); |
| 2840 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 2833 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
| 2841 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2834 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2842 | 2835 |
| 2843 // Verify that policy overrides the manual setting. | 2836 // Verify that policy overrides the manual setting. |
| 2844 PolicyMap policies; | 2837 PolicyMap policies; |
| 2845 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, | 2838 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
| 2846 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2839 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2847 base::WrapUnique(new base::FundamentalValue(0)), nullptr); | 2840 base::MakeUnique<base::FundamentalValue>(0), nullptr); |
| 2848 UpdateProviderPolicy(policies); | 2841 UpdateProviderPolicy(policies); |
| 2849 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2842 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2850 | 2843 |
| 2851 // Verify that the screen magnifier cannot be enabled manually anymore. | 2844 // Verify that the screen magnifier cannot be enabled manually anymore. |
| 2852 magnification_manager->SetMagnifierEnabled(true); | 2845 magnification_manager->SetMagnifierEnabled(true); |
| 2853 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2846 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2854 } | 2847 } |
| 2855 | 2848 |
| 2856 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { | 2849 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { |
| 2857 // Verifies that the full-screen magnifier can be enabled through policy. | 2850 // Verifies that the full-screen magnifier can be enabled through policy. |
| 2858 chromeos::MagnificationManager* magnification_manager = | 2851 chromeos::MagnificationManager* magnification_manager = |
| 2859 chromeos::MagnificationManager::Get(); | 2852 chromeos::MagnificationManager::Get(); |
| 2860 | 2853 |
| 2861 // Verify that the screen magnifier is initially disabled. | 2854 // Verify that the screen magnifier is initially disabled. |
| 2862 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); | 2855 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); |
| 2863 | 2856 |
| 2864 // Verify that policy can enable the full-screen magnifier. | 2857 // Verify that policy can enable the full-screen magnifier. |
| 2865 PolicyMap policies; | 2858 PolicyMap policies; |
| 2866 policies.Set( | 2859 policies.Set(key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, |
| 2867 key::kScreenMagnifierType, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2860 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2868 POLICY_SOURCE_CLOUD, | 2861 base::MakeUnique<base::FundamentalValue>(ash::MAGNIFIER_FULL), |
| 2869 base::WrapUnique(new base::FundamentalValue(ash::MAGNIFIER_FULL)), | 2862 nullptr); |
| 2870 nullptr); | |
| 2871 UpdateProviderPolicy(policies); | 2863 UpdateProviderPolicy(policies); |
| 2872 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); | 2864 EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); |
| 2873 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2865 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2874 | 2866 |
| 2875 // Verify that the screen magnifier cannot be disabled manually anymore. | 2867 // Verify that the screen magnifier cannot be disabled manually anymore. |
| 2876 magnification_manager->SetMagnifierEnabled(false); | 2868 magnification_manager->SetMagnifierEnabled(false); |
| 2877 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); | 2869 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); |
| 2878 } | 2870 } |
| 2879 | 2871 |
| 2880 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { | 2872 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { |
| 2881 // Verifies that the on-screen keyboard accessibility feature can be | 2873 // Verifies that the on-screen keyboard accessibility feature can be |
| 2882 // controlled through policy. | 2874 // controlled through policy. |
| 2883 chromeos::AccessibilityManager* accessibility_manager = | 2875 chromeos::AccessibilityManager* accessibility_manager = |
| 2884 chromeos::AccessibilityManager::Get(); | 2876 chromeos::AccessibilityManager::Get(); |
| 2885 | 2877 |
| 2886 // Manually enable the on-screen keyboard. | 2878 // Manually enable the on-screen keyboard. |
| 2887 accessibility_manager->EnableVirtualKeyboard(true); | 2879 accessibility_manager->EnableVirtualKeyboard(true); |
| 2888 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2880 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2889 | 2881 |
| 2890 // Verify that policy overrides the manual setting. | 2882 // Verify that policy overrides the manual setting. |
| 2891 PolicyMap policies; | 2883 PolicyMap policies; |
| 2892 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2884 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2893 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2885 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2894 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2886 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2895 UpdateProviderPolicy(policies); | 2887 UpdateProviderPolicy(policies); |
| 2896 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2888 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2897 | 2889 |
| 2898 // Verify that the on-screen keyboard cannot be enabled manually anymore. | 2890 // Verify that the on-screen keyboard cannot be enabled manually anymore. |
| 2899 accessibility_manager->EnableVirtualKeyboard(true); | 2891 accessibility_manager->EnableVirtualKeyboard(true); |
| 2900 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); | 2892 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); |
| 2901 } | 2893 } |
| 2902 | 2894 |
| 2903 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { | 2895 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { |
| 2904 // Verify keyboard disabled by default. | 2896 // Verify keyboard disabled by default. |
| 2905 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2897 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2906 // Verify keyboard can be toggled by default. | 2898 // Verify keyboard can be toggled by default. |
| 2907 keyboard::SetTouchKeyboardEnabled(true); | 2899 keyboard::SetTouchKeyboardEnabled(true); |
| 2908 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2900 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2909 keyboard::SetTouchKeyboardEnabled(false); | 2901 keyboard::SetTouchKeyboardEnabled(false); |
| 2910 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2902 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2911 | 2903 |
| 2912 // Verify enabling the policy takes effect immediately and that that user | 2904 // Verify enabling the policy takes effect immediately and that that user |
| 2913 // cannot disable the keyboard.. | 2905 // cannot disable the keyboard.. |
| 2914 PolicyMap policies; | 2906 PolicyMap policies; |
| 2915 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2907 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2916 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2908 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2917 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 2909 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 2918 UpdateProviderPolicy(policies); | 2910 UpdateProviderPolicy(policies); |
| 2919 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2911 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2920 keyboard::SetTouchKeyboardEnabled(false); | 2912 keyboard::SetTouchKeyboardEnabled(false); |
| 2921 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 2913 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
| 2922 | 2914 |
| 2923 // Verify that disabling the policy takes effect immediately and that the user | 2915 // Verify that disabling the policy takes effect immediately and that the user |
| 2924 // cannot enable the keyboard. | 2916 // cannot enable the keyboard. |
| 2925 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, | 2917 policies.Set(key::kTouchVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, |
| 2926 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 2918 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 2927 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 2919 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 2928 UpdateProviderPolicy(policies); | 2920 UpdateProviderPolicy(policies); |
| 2929 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2921 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2930 keyboard::SetTouchKeyboardEnabled(true); | 2922 keyboard::SetTouchKeyboardEnabled(true); |
| 2931 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 2923 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
| 2932 } | 2924 } |
| 2933 | 2925 |
| 2934 #endif | 2926 #endif |
| 2935 | 2927 |
| 2936 namespace { | 2928 namespace { |
| 2937 | 2929 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3073 class PolicyStatisticsCollectorTest : public PolicyTest { | 3065 class PolicyStatisticsCollectorTest : public PolicyTest { |
| 3074 public: | 3066 public: |
| 3075 PolicyStatisticsCollectorTest() {} | 3067 PolicyStatisticsCollectorTest() {} |
| 3076 ~PolicyStatisticsCollectorTest() override {} | 3068 ~PolicyStatisticsCollectorTest() override {} |
| 3077 | 3069 |
| 3078 void SetUpInProcessBrowserTestFixture() override { | 3070 void SetUpInProcessBrowserTestFixture() override { |
| 3079 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3071 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3080 PolicyMap policies; | 3072 PolicyMap policies; |
| 3081 policies.Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, | 3073 policies.Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, |
| 3082 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3074 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3083 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | 3075 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 3084 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 3076 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 3085 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3077 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3086 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 3078 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 3087 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, | 3079 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, |
| 3088 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3080 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3089 base::WrapUnique(new base::StringValue("http://chromium.org")), | 3081 base::MakeUnique<base::StringValue>("http://chromium.org"), |
| 3090 nullptr); | 3082 nullptr); |
| 3091 provider_.UpdateChromePolicy(policies); | 3083 provider_.UpdateChromePolicy(policies); |
| 3092 } | 3084 } |
| 3093 }; | 3085 }; |
| 3094 | 3086 |
| 3095 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { | 3087 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { |
| 3096 // Verifies that policy usage histograms are collected at startup. | 3088 // Verifies that policy usage histograms are collected at startup. |
| 3097 | 3089 |
| 3098 // BrowserPolicyConnector::Init() has already been called. Make sure the | 3090 // BrowserPolicyConnector::Init() has already been called. Make sure the |
| 3099 // CompleteInitialization() task has executed as well. | 3091 // CompleteInitialization() task has executed as well. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3145 // Configure a given policy map. The |policy_name| is the name of either the | 3137 // Configure a given policy map. The |policy_name| is the name of either the |
| 3146 // audio or video capture allow policy and must never be NULL. | 3138 // audio or video capture allow policy and must never be NULL. |
| 3147 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist | 3139 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist |
| 3148 // policy is set. If non-NULL, the whitelist policy is set to contain either | 3140 // policy is set. If non-NULL, the whitelist policy is set to contain either |
| 3149 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. | 3141 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. |
| 3150 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, | 3142 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, |
| 3151 const char* whitelist_policy, | 3143 const char* whitelist_policy, |
| 3152 const char* allow_rule) { | 3144 const char* allow_rule) { |
| 3153 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3145 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 3154 POLICY_SOURCE_CLOUD, | 3146 POLICY_SOURCE_CLOUD, |
| 3155 base::WrapUnique(new base::FundamentalValue(policy_value_)), | 3147 base::MakeUnique<base::FundamentalValue>(policy_value_), |
| 3156 nullptr); | 3148 nullptr); |
| 3157 | 3149 |
| 3158 if (whitelist_policy) { | 3150 if (whitelist_policy) { |
| 3159 // Add an entry to the whitelist that allows the specified URL regardless | 3151 // Add an entry to the whitelist that allows the specified URL regardless |
| 3160 // of the setting of kAudioCapturedAllowed. | 3152 // of the setting of kAudioCapturedAllowed. |
| 3161 std::unique_ptr<base::ListValue> list(new base::ListValue); | 3153 std::unique_ptr<base::ListValue> list(new base::ListValue); |
| 3162 if (allow_rule) { | 3154 if (allow_rule) { |
| 3163 list->AppendString(allow_rule); | 3155 list->AppendString(allow_rule); |
| 3164 request_url_allowed_via_whitelist_ = true; | 3156 request_url_allowed_via_whitelist_ = true; |
| 3165 } else { | 3157 } else { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3376 content::WebContents* const web_contents = | 3368 content::WebContents* const web_contents = |
| 3377 browser()->tab_strip_model()->GetActiveWebContents(); | 3369 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3378 EXPECT_THAT( | 3370 EXPECT_THAT( |
| 3379 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), | 3371 web_contents->GetMainFrame()->GetLastCommittedOrigin().Serialize(), |
| 3380 testing::StartsWith("http://localhost:")); | 3372 testing::StartsWith("http://localhost:")); |
| 3381 | 3373 |
| 3382 // Set the policy to block Web Bluetooth. | 3374 // Set the policy to block Web Bluetooth. |
| 3383 PolicyMap policies; | 3375 PolicyMap policies; |
| 3384 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, | 3376 policies.Set(key::kDefaultWebBluetoothGuardSetting, POLICY_LEVEL_MANDATORY, |
| 3385 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3377 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3386 base::WrapUnique(new base::FundamentalValue(2)), nullptr); | 3378 base::MakeUnique<base::FundamentalValue>(2), nullptr); |
| 3387 UpdateProviderPolicy(policies); | 3379 UpdateProviderPolicy(policies); |
| 3388 | 3380 |
| 3389 std::string rejection; | 3381 std::string rejection; |
| 3390 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 3382 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 3391 web_contents, | 3383 web_contents, |
| 3392 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" | 3384 "navigator.bluetooth.requestDevice({filters: [{name: 'Hello'}]})" |
| 3393 " .then(() => { domAutomationController.send('Success'); }," | 3385 " .then(() => { domAutomationController.send('Success'); }," |
| 3394 " reason => {" | 3386 " reason => {" |
| 3395 " domAutomationController.send(reason.name + ': ' + reason.message);" | 3387 " domAutomationController.send(reason.name + ': ' + reason.message);" |
| 3396 " });", | 3388 " });", |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3622 #if defined(ENABLE_MEDIA_ROUTER) | 3614 #if defined(ENABLE_MEDIA_ROUTER) |
| 3623 // Sets the proper policy before the browser is started. | 3615 // Sets the proper policy before the browser is started. |
| 3624 template<bool enable> | 3616 template<bool enable> |
| 3625 class MediaRouterPolicyTest : public PolicyTest { | 3617 class MediaRouterPolicyTest : public PolicyTest { |
| 3626 public: | 3618 public: |
| 3627 void SetUpInProcessBrowserTestFixture() override { | 3619 void SetUpInProcessBrowserTestFixture() override { |
| 3628 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3620 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3629 PolicyMap policies; | 3621 PolicyMap policies; |
| 3630 policies.Set(key::kEnableMediaRouter, POLICY_LEVEL_MANDATORY, | 3622 policies.Set(key::kEnableMediaRouter, POLICY_LEVEL_MANDATORY, |
| 3631 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3623 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3632 base::WrapUnique(new base::FundamentalValue(enable)), | 3624 base::MakeUnique<base::FundamentalValue>(enable), nullptr); |
| 3633 nullptr); | |
| 3634 provider_.UpdateChromePolicy(policies); | 3625 provider_.UpdateChromePolicy(policies); |
| 3635 } | 3626 } |
| 3636 }; | 3627 }; |
| 3637 | 3628 |
| 3638 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; | 3629 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; |
| 3639 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; | 3630 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; |
| 3640 | 3631 |
| 3641 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { | 3632 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { |
| 3642 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); | 3633 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3643 } | 3634 } |
| 3644 | 3635 |
| 3645 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { | 3636 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { |
| 3646 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); | 3637 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3647 } | 3638 } |
| 3648 #endif // defined(ENABLE_MEDIA_ROUTER) | 3639 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 3649 | 3640 |
| 3650 #if defined(ENABLE_WEBRTC) | 3641 #if defined(ENABLE_WEBRTC) |
| 3651 // Sets the proper policy before the browser is started. | 3642 // Sets the proper policy before the browser is started. |
| 3652 template <bool enable> | 3643 template <bool enable> |
| 3653 class WebRtcUdpPortRangePolicyTest : public PolicyTest { | 3644 class WebRtcUdpPortRangePolicyTest : public PolicyTest { |
| 3654 public: | 3645 public: |
| 3655 WebRtcUdpPortRangePolicyTest() = default; | 3646 WebRtcUdpPortRangePolicyTest() = default; |
| 3656 void SetUpInProcessBrowserTestFixture() override { | 3647 void SetUpInProcessBrowserTestFixture() override { |
| 3657 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3648 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3658 PolicyMap policies; | 3649 PolicyMap policies; |
| 3659 if (enable) { | 3650 if (enable) { |
| 3660 policies.Set( | 3651 policies.Set(key::kWebRtcUdpPortRange, POLICY_LEVEL_MANDATORY, |
| 3661 key::kWebRtcUdpPortRange, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 3652 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3662 POLICY_SOURCE_CLOUD, | 3653 base::MakeUnique<base::StringValue>(kTestWebRtcUdpPortRange), |
| 3663 base::WrapUnique(new base::StringValue(kTestWebRtcUdpPortRange)), | 3654 nullptr); |
| 3664 nullptr); | |
| 3665 } | 3655 } |
| 3666 provider_.UpdateChromePolicy(policies); | 3656 provider_.UpdateChromePolicy(policies); |
| 3667 } | 3657 } |
| 3668 | 3658 |
| 3669 private: | 3659 private: |
| 3670 DISALLOW_COPY_AND_ASSIGN(WebRtcUdpPortRangePolicyTest<enable>); | 3660 DISALLOW_COPY_AND_ASSIGN(WebRtcUdpPortRangePolicyTest<enable>); |
| 3671 }; | 3661 }; |
| 3672 | 3662 |
| 3673 using WebRtcUdpPortRangeEnabledPolicyTest = WebRtcUdpPortRangePolicyTest<true>; | 3663 using WebRtcUdpPortRangeEnabledPolicyTest = WebRtcUdpPortRangePolicyTest<true>; |
| 3674 using WebRtcUdpPortRangeDisabledPolicyTest = | 3664 using WebRtcUdpPortRangeDisabledPolicyTest = |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3968 #if !defined(OS_CHROMEOS) | 3958 #if !defined(OS_CHROMEOS) |
| 3969 // Similar to PolicyTest but sets the proper policy before the browser is | 3959 // Similar to PolicyTest but sets the proper policy before the browser is |
| 3970 // started. | 3960 // started. |
| 3971 class PolicyVariationsServiceTest : public PolicyTest { | 3961 class PolicyVariationsServiceTest : public PolicyTest { |
| 3972 public: | 3962 public: |
| 3973 void SetUpInProcessBrowserTestFixture() override { | 3963 void SetUpInProcessBrowserTestFixture() override { |
| 3974 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3964 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3975 PolicyMap policies; | 3965 PolicyMap policies; |
| 3976 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY, | 3966 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY, |
| 3977 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 3967 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3978 base::WrapUnique(new base::StringValue("restricted")), | 3968 base::MakeUnique<base::StringValue>("restricted"), nullptr); |
| 3979 nullptr); | |
| 3980 provider_.UpdateChromePolicy(policies); | 3969 provider_.UpdateChromePolicy(policies); |
| 3981 } | 3970 } |
| 3982 }; | 3971 }; |
| 3983 | 3972 |
| 3984 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { | 3973 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { |
| 3985 const std::string default_variations_url = | 3974 const std::string default_variations_url = |
| 3986 variations::VariationsService::GetDefaultVariationsServerURLForTesting(); | 3975 variations::VariationsService::GetDefaultVariationsServerURLForTesting(); |
| 3987 | 3976 |
| 3988 // g_browser_process->variations_service() is null by default in Chromium | 3977 // g_browser_process->variations_service() is null by default in Chromium |
| 3989 // builds, so construct a VariationsService locally instead. | 3978 // builds, so construct a VariationsService locally instead. |
| 3990 std::unique_ptr<variations::VariationsService> service = | 3979 std::unique_ptr<variations::VariationsService> service = |
| 3991 variations::VariationsService::CreateForTesting( | 3980 variations::VariationsService::CreateForTesting( |
| 3992 base::WrapUnique(new ChromeVariationsServiceClient()), | 3981 base::MakeUnique<ChromeVariationsServiceClient>(), |
| 3993 g_browser_process->local_state()); | 3982 g_browser_process->local_state()); |
| 3994 | 3983 |
| 3995 const GURL url = service->GetVariationsServerURL( | 3984 const GURL url = service->GetVariationsServerURL( |
| 3996 g_browser_process->local_state(), std::string()); | 3985 g_browser_process->local_state(), std::string()); |
| 3997 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, | 3986 EXPECT_TRUE(base::StartsWith(url.spec(), default_variations_url, |
| 3998 base::CompareCase::SENSITIVE)); | 3987 base::CompareCase::SENSITIVE)); |
| 3999 std::string value; | 3988 std::string value; |
| 4000 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 3989 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
| 4001 EXPECT_EQ("restricted", value); | 3990 EXPECT_EQ("restricted", value); |
| 4002 } | 3991 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4061 // Sets the hardware acceleration mode policy before the browser is started. | 4050 // Sets the hardware acceleration mode policy before the browser is started. |
| 4062 class HardwareAccelerationModePolicyTest : public PolicyTest { | 4051 class HardwareAccelerationModePolicyTest : public PolicyTest { |
| 4063 public: | 4052 public: |
| 4064 HardwareAccelerationModePolicyTest() {} | 4053 HardwareAccelerationModePolicyTest() {} |
| 4065 | 4054 |
| 4066 void SetUpInProcessBrowserTestFixture() override { | 4055 void SetUpInProcessBrowserTestFixture() override { |
| 4067 PolicyTest::SetUpInProcessBrowserTestFixture(); | 4056 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 4068 PolicyMap policies; | 4057 PolicyMap policies; |
| 4069 policies.Set(key::kHardwareAccelerationModeEnabled, POLICY_LEVEL_MANDATORY, | 4058 policies.Set(key::kHardwareAccelerationModeEnabled, POLICY_LEVEL_MANDATORY, |
| 4070 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4059 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 4071 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 4060 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
| 4072 provider_.UpdateChromePolicy(policies); | 4061 provider_.UpdateChromePolicy(policies); |
| 4073 } | 4062 } |
| 4074 }; | 4063 }; |
| 4075 | 4064 |
| 4076 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, | 4065 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, |
| 4077 HardwareAccelerationDisabled) { | 4066 HardwareAccelerationDisabled) { |
| 4078 // Verifies that hardware acceleration can be disabled with policy. | 4067 // Verifies that hardware acceleration can be disabled with policy. |
| 4079 EXPECT_FALSE( | 4068 EXPECT_FALSE( |
| 4080 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); | 4069 content::GpuDataManager::GetInstance()->GpuAccessAllowed(nullptr)); |
| 4081 } | 4070 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4126 void SetUpInProcessBrowserTestFixture() override { | 4115 void SetUpInProcessBrowserTestFixture() override { |
| 4127 PolicyTest::SetUpInProcessBrowserTestFixture(); | 4116 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 4128 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient; | 4117 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient; |
| 4129 fake_session_manager_client_->set_arc_available(true); | 4118 fake_session_manager_client_->set_arc_available(true); |
| 4130 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | 4119 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 4131 std::unique_ptr<chromeos::SessionManagerClient>( | 4120 std::unique_ptr<chromeos::SessionManagerClient>( |
| 4132 fake_session_manager_client_)); | 4121 fake_session_manager_client_)); |
| 4133 | 4122 |
| 4134 fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance); | 4123 fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance); |
| 4135 arc::ArcServiceManager::SetArcBridgeServiceForTesting( | 4124 arc::ArcServiceManager::SetArcBridgeServiceForTesting( |
| 4136 base::WrapUnique(new arc::ArcBridgeServiceImpl( | 4125 base::MakeUnique<arc::ArcBridgeServiceImpl>(base::WrapUnique( |
| 4137 base::WrapUnique(new arc::FakeArcBridgeBootstrap( | 4126 new arc::FakeArcBridgeBootstrap(fake_arc_bridge_instance_.get())))); |
| 4138 fake_arc_bridge_instance_.get()))))); | |
| 4139 } | 4127 } |
| 4140 | 4128 |
| 4141 void SetUpCommandLine(base::CommandLine* command_line) override { | 4129 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 4142 // ArcAuthService functionality is available only when Arc is enabled. Use | 4130 // ArcAuthService functionality is available only when Arc is enabled. Use |
| 4143 // kEnableArc switch that activates it. | 4131 // kEnableArc switch that activates it. |
| 4144 command_line->AppendSwitch(chromeos::switches::kEnableArc); | 4132 command_line->AppendSwitch(chromeos::switches::kEnableArc); |
| 4145 } | 4133 } |
| 4146 | 4134 |
| 4147 private: | 4135 private: |
| 4148 chromeos::FakeSessionManagerClient *fake_session_manager_client_; | 4136 chromeos::FakeSessionManagerClient *fake_session_manager_client_; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4291 EXPECT_FALSE(local_state->IsManagedPreference( | 4279 EXPECT_FALSE(local_state->IsManagedPreference( |
| 4292 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4280 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4293 EXPECT_EQ(0, local_state->GetInteger( | 4281 EXPECT_EQ(0, local_state->GetInteger( |
| 4294 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4282 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4295 } | 4283 } |
| 4296 | 4284 |
| 4297 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { | 4285 void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) { |
| 4298 PolicyMap policies; | 4286 PolicyMap policies; |
| 4299 policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY, | 4287 policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY, |
| 4300 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 4288 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 4301 base::WrapUnique(new base::FundamentalValue(policy_value)), | 4289 base::MakeUnique<base::FundamentalValue>(policy_value), |
| 4302 nullptr); | 4290 nullptr); |
| 4303 UpdateProviderPolicy(policies); | 4291 UpdateProviderPolicy(policies); |
| 4304 | 4292 |
| 4305 PrefService* local_state = g_browser_process->local_state(); | 4293 PrefService* local_state = g_browser_process->local_state(); |
| 4306 | 4294 |
| 4307 EXPECT_TRUE(local_state->IsManagedPreference( | 4295 EXPECT_TRUE(local_state->IsManagedPreference( |
| 4308 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4296 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| 4309 EXPECT_EQ(policy_value, | 4297 EXPECT_EQ(policy_value, |
| 4310 local_state->GetInteger( | 4298 local_state->GetInteger( |
| 4311 prefs::kSystemTimezoneAutomaticDetectionPolicy)); | 4299 prefs::kSystemTimezoneAutomaticDetectionPolicy)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4386 | 4374 |
| 4387 SetEmptyPolicy(); | 4375 SetEmptyPolicy(); |
| 4388 // Policy not set. | 4376 // Policy not set. |
| 4389 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4377 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4390 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4378 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4391 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4379 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4392 } | 4380 } |
| 4393 #endif // defined(OS_CHROMEOS) | 4381 #endif // defined(OS_CHROMEOS) |
| 4394 | 4382 |
| 4395 } // namespace policy | 4383 } // namespace policy |
| OLD | NEW |