Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 397793002: Eliminate CreateBooleanValue from test files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad merge Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 BrowserThread::PostTaskAndReply( 607 BrowserThread::PostTaskAndReply(
608 BrowserThread::IO, FROM_HERE, 608 BrowserThread::IO, FROM_HERE,
609 base::Bind(URLRequestMockHTTPJob::AddUrlHandler, root_http), 609 base::Bind(URLRequestMockHTTPJob::AddUrlHandler, root_http),
610 base::MessageLoop::current()->QuitWhenIdleClosure()); 610 base::MessageLoop::current()->QuitWhenIdleClosure());
611 content::RunMessageLoop(); 611 content::RunMessageLoop();
612 } 612 }
613 613
614 void SetScreenshotPolicy(bool enabled) { 614 void SetScreenshotPolicy(bool enabled) {
615 PolicyMap policies; 615 PolicyMap policies;
616 policies.Set(key::kDisableScreenshots, 616 policies.Set(key::kDisableScreenshots,
617 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 617 POLICY_LEVEL_MANDATORY,
618 base::Value::CreateBooleanValue(!enabled), NULL); 618 POLICY_SCOPE_USER,
619 new base::FundamentalValue(!enabled),
620 NULL);
619 UpdateProviderPolicy(policies); 621 UpdateProviderPolicy(policies);
620 } 622 }
621 623
622 #if defined(OS_CHROMEOS) 624 #if defined(OS_CHROMEOS)
623 class QuitMessageLoopAfterScreenshot : public ScreenshotTakerObserver { 625 class QuitMessageLoopAfterScreenshot : public ScreenshotTakerObserver {
624 public: 626 public:
625 virtual void OnScreenshotCompleted( 627 virtual void OnScreenshotCompleted(
626 ScreenshotTakerObserver::Result screenshot_result, 628 ScreenshotTakerObserver::Result screenshot_result,
627 const base::FilePath& screenshot_path) OVERRIDE { 629 const base::FilePath& screenshot_path) OVERRIDE {
628 BrowserThread::PostTaskAndReply(BrowserThread::IO, 630 BrowserThread::PostTaskAndReply(BrowserThread::IO,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 791
790 // Verifies that the bookmarks bar can be forced to always or never show up. 792 // Verifies that the bookmarks bar can be forced to always or never show up.
791 793
792 // Test starts in about:blank. 794 // Test starts in about:blank.
793 PrefService* prefs = browser()->profile()->GetPrefs(); 795 PrefService* prefs = browser()->profile()->GetPrefs();
794 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); 796 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kShowBookmarkBar));
795 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar)); 797 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar));
796 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); 798 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state());
797 799
798 PolicyMap policies; 800 PolicyMap policies;
799 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, 801 policies.Set(key::kBookmarkBarEnabled,
800 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 802 POLICY_LEVEL_MANDATORY,
803 POLICY_SCOPE_USER,
804 new base::FundamentalValue(true),
805 NULL);
801 UpdateProviderPolicy(policies); 806 UpdateProviderPolicy(policies);
802 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); 807 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar));
803 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowBookmarkBar)); 808 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowBookmarkBar));
804 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 809 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
805 810
806 // The NTP has special handling of the bookmark bar. 811 // The NTP has special handling of the bookmark bar.
807 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 812 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
808 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 813 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
809 814
810 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, 815 policies.Set(key::kBookmarkBarEnabled,
811 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 816 POLICY_LEVEL_MANDATORY,
817 POLICY_SCOPE_USER,
818 new base::FundamentalValue(false),
819 NULL);
812 UpdateProviderPolicy(policies); 820 UpdateProviderPolicy(policies);
813 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); 821 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar));
814 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar)); 822 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar));
815 // The bookmark bar is hidden in the NTP when disabled by policy. 823 // The bookmark bar is hidden in the NTP when disabled by policy.
816 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); 824 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state());
817 825
818 policies.Clear(); 826 policies.Clear();
819 UpdateProviderPolicy(policies); 827 UpdateProviderPolicy(policies);
820 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); 828 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kShowBookmarkBar));
821 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar)); 829 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 default_search->alternate_urls()[0] == kAlternateURL0 && 889 default_search->alternate_urls()[0] == kAlternateURL0 &&
882 default_search->alternate_urls()[1] == kAlternateURL1 && 890 default_search->alternate_urls()[1] == kAlternateURL1 &&
883 default_search->search_terms_replacement_key() == 891 default_search->search_terms_replacement_key() ==
884 kSearchTermsReplacementKey && 892 kSearchTermsReplacementKey &&
885 default_search->image_url() == kImageURL && 893 default_search->image_url() == kImageURL &&
886 default_search->image_url_post_params() == kImageURLPostParams && 894 default_search->image_url_post_params() == kImageURLPostParams &&
887 default_search->new_tab_url() == kNewTabURL); 895 default_search->new_tab_url() == kNewTabURL);
888 896
889 // Override the default search provider using policies. 897 // Override the default search provider using policies.
890 PolicyMap policies; 898 PolicyMap policies;
891 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 899 policies.Set(key::kDefaultSearchProviderEnabled,
892 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 900 POLICY_LEVEL_MANDATORY,
901 POLICY_SCOPE_USER,
902 new base::FundamentalValue(true),
903 NULL);
893 policies.Set(key::kDefaultSearchProviderKeyword, 904 policies.Set(key::kDefaultSearchProviderKeyword,
894 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 905 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
895 base::Value::CreateStringValue(kKeyword), NULL); 906 base::Value::CreateStringValue(kKeyword), NULL);
896 policies.Set(key::kDefaultSearchProviderSearchURL, 907 policies.Set(key::kDefaultSearchProviderSearchURL,
897 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 908 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
898 base::Value::CreateStringValue(kSearchURL), NULL); 909 base::Value::CreateStringValue(kSearchURL), NULL);
899 base::ListValue* alternate_urls = new base::ListValue(); 910 base::ListValue* alternate_urls = new base::ListValue();
900 alternate_urls->AppendString(kAlternateURL0); 911 alternate_urls->AppendString(kAlternateURL0);
901 alternate_urls->AppendString(kAlternateURL1); 912 alternate_urls->AppendString(kAlternateURL1);
902 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, 913 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "stuff to search for"); 948 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "stuff to search for");
938 OmniboxEditModel* model = location_bar->GetOmniboxView()->model(); 949 OmniboxEditModel* model = location_bar->GetOmniboxView()->model();
939 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); 950 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid());
940 content::WebContents* web_contents = 951 content::WebContents* web_contents =
941 browser()->tab_strip_model()->GetActiveWebContents(); 952 browser()->tab_strip_model()->GetActiveWebContents();
942 GURL expected("http://search.example/search?q=stuff+to+search+for"); 953 GURL expected("http://search.example/search?q=stuff+to+search+for");
943 EXPECT_EQ(expected, web_contents->GetURL()); 954 EXPECT_EQ(expected, web_contents->GetURL());
944 955
945 // Verify that searching from the omnibox can be disabled. 956 // Verify that searching from the omnibox can be disabled.
946 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 957 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
947 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 958 policies.Set(key::kDefaultSearchProviderEnabled,
948 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 959 POLICY_LEVEL_MANDATORY,
960 POLICY_SCOPE_USER,
961 new base::FundamentalValue(false),
962 NULL);
949 EXPECT_TRUE(service->GetDefaultSearchProvider()); 963 EXPECT_TRUE(service->GetDefaultSearchProvider());
950 UpdateProviderPolicy(policies); 964 UpdateProviderPolicy(policies);
951 EXPECT_FALSE(service->GetDefaultSearchProvider()); 965 EXPECT_FALSE(service->GetDefaultSearchProvider());
952 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); 966 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work");
953 // This means that submitting won't trigger any action. 967 // This means that submitting won't trigger any action.
954 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); 968 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid());
955 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); 969 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL());
956 } 970 }
957 971
958 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { 972 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 browser()->tab_strip_model()->GetActiveWebContents(); 1026 browser()->tab_strip_model()->GetActiveWebContents();
1013 GURL expected_without("http://google.com/"); 1027 GURL expected_without("http://google.com/");
1014 EXPECT_EQ(expected_without, web_contents->GetURL()); 1028 EXPECT_EQ(expected_without, web_contents->GetURL());
1015 1029
1016 PrefService* prefs = browser()->profile()->GetPrefs(); 1030 PrefService* prefs = browser()->profile()->GetPrefs();
1017 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kForceSafeSearch)); 1031 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kForceSafeSearch));
1018 EXPECT_FALSE(prefs->GetBoolean(prefs::kForceSafeSearch)); 1032 EXPECT_FALSE(prefs->GetBoolean(prefs::kForceSafeSearch));
1019 1033
1020 // Override the default SafeSearch setting using policies. 1034 // Override the default SafeSearch setting using policies.
1021 PolicyMap policies; 1035 PolicyMap policies;
1022 policies.Set(key::kForceSafeSearch, POLICY_LEVEL_MANDATORY, 1036 policies.Set(key::kForceSafeSearch,
1023 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1037 POLICY_LEVEL_MANDATORY,
1038 POLICY_SCOPE_USER,
1039 new base::FundamentalValue(true),
1040 NULL);
1024 UpdateProviderPolicy(policies); 1041 UpdateProviderPolicy(policies);
1025 1042
1026 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kForceSafeSearch)); 1043 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kForceSafeSearch));
1027 EXPECT_TRUE(prefs->GetBoolean(prefs::kForceSafeSearch)); 1044 EXPECT_TRUE(prefs->GetBoolean(prefs::kForceSafeSearch));
1028 1045
1029 content::TestNavigationObserver safesearch_observer( 1046 content::TestNavigationObserver safesearch_observer(
1030 browser()->tab_strip_model()->GetActiveWebContents()); 1047 browser()->tab_strip_model()->GetActiveWebContents());
1031 1048
1032 // Verify that searching from google.com works. 1049 // Verify that searching from google.com works.
1033 chrome::FocusLocationBar(browser()); 1050 chrome::FocusLocationBar(browser());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 EXPECT_NE(kKeyword, default_search->keyword()); 1083 EXPECT_NE(kKeyword, default_search->keyword());
1067 EXPECT_NE(kSearchURL, default_search->url()); 1084 EXPECT_NE(kSearchURL, default_search->url());
1068 EXPECT_NE(kInstantURL, default_search->instant_url()); 1085 EXPECT_NE(kInstantURL, default_search->instant_url());
1069 EXPECT_FALSE( 1086 EXPECT_FALSE(
1070 default_search->alternate_urls().size() == 2 && 1087 default_search->alternate_urls().size() == 2 &&
1071 default_search->alternate_urls()[0] == kAlternateURL0 && 1088 default_search->alternate_urls()[0] == kAlternateURL0 &&
1072 default_search->alternate_urls()[1] == kAlternateURL1); 1089 default_search->alternate_urls()[1] == kAlternateURL1);
1073 1090
1074 // Override the default search provider using policies. 1091 // Override the default search provider using policies.
1075 PolicyMap policies; 1092 PolicyMap policies;
1076 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 1093 policies.Set(key::kDefaultSearchProviderEnabled,
1077 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1094 POLICY_LEVEL_MANDATORY,
1095 POLICY_SCOPE_USER,
1096 new base::FundamentalValue(true),
1097 NULL);
1078 policies.Set(key::kDefaultSearchProviderKeyword, 1098 policies.Set(key::kDefaultSearchProviderKeyword,
1079 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1099 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
1080 base::Value::CreateStringValue(kKeyword), NULL); 1100 base::Value::CreateStringValue(kKeyword), NULL);
1081 policies.Set(key::kDefaultSearchProviderSearchURL, 1101 policies.Set(key::kDefaultSearchProviderSearchURL,
1082 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1102 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
1083 base::Value::CreateStringValue(kSearchURL), NULL); 1103 base::Value::CreateStringValue(kSearchURL), NULL);
1084 policies.Set(key::kDefaultSearchProviderInstantURL, 1104 policies.Set(key::kDefaultSearchProviderInstantURL,
1085 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1105 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
1086 base::Value::CreateStringValue(kInstantURL), NULL); 1106 base::Value::CreateStringValue(kInstantURL), NULL);
1087 base::ListValue* alternate_urls = new base::ListValue(); 1107 base::ListValue* alternate_urls = new base::ListValue();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) 1182 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL))
1163 return; 1183 return;
1164 1184
1165 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1185 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1166 // WebGL is enabled by default. 1186 // WebGL is enabled by default.
1167 content::WebContents* contents = 1187 content::WebContents* contents =
1168 browser()->tab_strip_model()->GetActiveWebContents(); 1188 browser()->tab_strip_model()->GetActiveWebContents();
1169 EXPECT_TRUE(IsWebGLEnabled(contents)); 1189 EXPECT_TRUE(IsWebGLEnabled(contents));
1170 // Disable with a policy. 1190 // Disable with a policy.
1171 PolicyMap policies; 1191 PolicyMap policies;
1172 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, 1192 policies.Set(key::kDisable3DAPIs,
1173 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1193 POLICY_LEVEL_MANDATORY,
1194 POLICY_SCOPE_USER,
1195 new base::FundamentalValue(true),
1196 NULL);
1174 UpdateProviderPolicy(policies); 1197 UpdateProviderPolicy(policies);
1175 // Crash and reload the tab to get a new renderer. 1198 // Crash and reload the tab to get a new renderer.
1176 content::CrashTab(contents); 1199 content::CrashTab(contents);
1177 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); 1200 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD));
1178 EXPECT_FALSE(IsWebGLEnabled(contents)); 1201 EXPECT_FALSE(IsWebGLEnabled(contents));
1179 // Enable with a policy. 1202 // Enable with a policy.
1180 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, 1203 policies.Set(key::kDisable3DAPIs,
1181 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1204 POLICY_LEVEL_MANDATORY,
1205 POLICY_SCOPE_USER,
1206 new base::FundamentalValue(false),
1207 NULL);
1182 UpdateProviderPolicy(policies); 1208 UpdateProviderPolicy(policies);
1183 content::CrashTab(contents); 1209 content::CrashTab(contents);
1184 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); 1210 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD));
1185 EXPECT_TRUE(IsWebGLEnabled(contents)); 1211 EXPECT_TRUE(IsWebGLEnabled(contents));
1186 } 1212 }
1187 1213
1188 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) { 1214 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) {
1189 // Verifies that SPDY can be disable by policy. 1215 // Verifies that SPDY can be disable by policy.
1190 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); 1216 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled());
1191 PolicyMap policies; 1217 PolicyMap policies;
1192 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, 1218 policies.Set(key::kDisableSpdy,
1193 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1219 POLICY_LEVEL_MANDATORY,
1220 POLICY_SCOPE_USER,
1221 new base::FundamentalValue(true),
1222 NULL);
1194 UpdateProviderPolicy(policies); 1223 UpdateProviderPolicy(policies);
1195 content::RunAllPendingInMessageLoop(); 1224 content::RunAllPendingInMessageLoop();
1196 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); 1225 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled());
1197 // Verify that it can be force-enabled too. 1226 // Verify that it can be force-enabled too.
1198 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); 1227 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true);
1199 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, 1228 policies.Set(key::kDisableSpdy,
1200 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1229 POLICY_LEVEL_MANDATORY,
1230 POLICY_SCOPE_USER,
1231 new base::FundamentalValue(false),
1232 NULL);
1201 UpdateProviderPolicy(policies); 1233 UpdateProviderPolicy(policies);
1202 content::RunAllPendingInMessageLoop(); 1234 content::RunAllPendingInMessageLoop();
1203 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); 1235 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled());
1204 } 1236 }
1205 1237
1206 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { 1238 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) {
1207 // Verifies that plugins can be forced to be disabled by policy. 1239 // Verifies that plugins can be forced to be disabled by policy.
1208 1240
1209 // Verify that the Flash plugin exists and that it can be enabled and disabled 1241 // Verify that the Flash plugin exists and that it can be enabled and disabled
1210 // by the user. 1242 // by the user.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 ui_test_utils::NavigateToURL(browser(), url); 1370 ui_test_utils::NavigateToURL(browser(), url);
1339 // This should have triggered the dangerous plugin infobar. 1371 // This should have triggered the dangerous plugin infobar.
1340 ASSERT_EQ(1u, infobar_service->infobar_count()); 1372 ASSERT_EQ(1u, infobar_service->infobar_count());
1341 EXPECT_TRUE( 1373 EXPECT_TRUE(
1342 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); 1374 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate());
1343 // And the plugin isn't running. 1375 // And the plugin isn't running.
1344 EXPECT_EQ(0, CountPlugins()); 1376 EXPECT_EQ(0, CountPlugins());
1345 1377
1346 // Now set a policy to always authorize this. 1378 // Now set a policy to always authorize this.
1347 PolicyMap policies; 1379 PolicyMap policies;
1348 policies.Set(key::kAlwaysAuthorizePlugins, POLICY_LEVEL_MANDATORY, 1380 policies.Set(key::kAlwaysAuthorizePlugins,
1349 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1381 POLICY_LEVEL_MANDATORY,
1382 POLICY_SCOPE_USER,
1383 new base::FundamentalValue(true),
1384 NULL);
1350 UpdateProviderPolicy(policies); 1385 UpdateProviderPolicy(policies);
1351 // Reloading the page shouldn't trigger the infobar this time. 1386 // Reloading the page shouldn't trigger the infobar this time.
1352 ui_test_utils::NavigateToURL(browser(), url); 1387 ui_test_utils::NavigateToURL(browser(), url);
1353 EXPECT_EQ(0u, infobar_service->infobar_count()); 1388 EXPECT_EQ(0u, infobar_service->infobar_count());
1354 // And the plugin started automatically. 1389 // And the plugin started automatically.
1355 EXPECT_EQ(1, CountPlugins()); 1390 EXPECT_EQ(1, CountPlugins());
1356 } 1391 }
1357 1392
1358 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { 1393 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) {
1359 // Verifies that access to the developer tools can be disabled. 1394 // Verifies that access to the developer tools can be disabled.
1360 1395
1361 // Open devtools. 1396 // Open devtools.
1362 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); 1397 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS));
1363 content::WebContents* contents = 1398 content::WebContents* contents =
1364 browser()->tab_strip_model()->GetActiveWebContents(); 1399 browser()->tab_strip_model()->GetActiveWebContents();
1365 DevToolsWindow *devtools_window = 1400 DevToolsWindow *devtools_window =
1366 DevToolsWindow::GetInstanceForInspectedWebContents(contents); 1401 DevToolsWindow::GetInstanceForInspectedWebContents(contents);
1367 EXPECT_TRUE(devtools_window); 1402 EXPECT_TRUE(devtools_window);
1368 1403
1369 // Disable devtools via policy. 1404 // Disable devtools via policy.
1370 PolicyMap policies; 1405 PolicyMap policies;
1371 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, 1406 policies.Set(key::kDeveloperToolsDisabled,
1372 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1407 POLICY_LEVEL_MANDATORY,
1408 POLICY_SCOPE_USER,
1409 new base::FundamentalValue(true),
1410 NULL);
1373 content::WindowedNotificationObserver close_observer( 1411 content::WindowedNotificationObserver close_observer(
1374 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 1412 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
1375 content::Source<content::WebContents>( 1413 content::Source<content::WebContents>(
1376 devtools_window->web_contents_for_test())); 1414 devtools_window->web_contents_for_test()));
1377 UpdateProviderPolicy(policies); 1415 UpdateProviderPolicy(policies);
1378 // wait for devtools close 1416 // wait for devtools close
1379 close_observer.Wait(); 1417 close_observer.Wait();
1380 // The existing devtools window should have closed. 1418 // The existing devtools window should have closed.
1381 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents)); 1419 EXPECT_FALSE(DevToolsWindow::GetInstanceForInspectedWebContents(contents));
1382 // And it's not possible to open it again. 1420 // And it's not possible to open it again.
(...skipping 21 matching lines...) Expand all
1404 EXPECT_TRUE(ContainsVisibleElement(contents, 1442 EXPECT_TRUE(ContainsVisibleElement(contents,
1405 "ahfgeienlihckogmohjhadlkjgocpleb")); 1443 "ahfgeienlihckogmohjhadlkjgocpleb"));
1406 #endif 1444 #endif
1407 1445
1408 // The next NTP has no footer. 1446 // The next NTP has no footer.
1409 if (ContainsVisibleElement(contents, "footer")) 1447 if (ContainsVisibleElement(contents, "footer"))
1410 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); 1448 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1411 1449
1412 // Turn off the web store icons. 1450 // Turn off the web store icons.
1413 PolicyMap policies; 1451 PolicyMap policies;
1414 policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY, 1452 policies.Set(key::kHideWebStoreIcon,
1415 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1453 POLICY_LEVEL_MANDATORY,
1454 POLICY_SCOPE_USER,
1455 new base::FundamentalValue(true),
1456 NULL);
1416 UpdateProviderPolicy(policies); 1457 UpdateProviderPolicy(policies);
1417 1458
1418 // The web store icons should now be hidden. 1459 // The web store icons should now be hidden.
1419 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 1460 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1420 EXPECT_FALSE(ContainsVisibleElement(contents, 1461 EXPECT_FALSE(ContainsVisibleElement(contents,
1421 "ahfgeienlihckogmohjhadlkjgocpleb")); 1462 "ahfgeienlihckogmohjhadlkjgocpleb"));
1422 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); 1463 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1423 } 1464 }
1424 1465
1425 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { 1466 IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 PolicyMap policies; 1802 PolicyMap policies;
1762 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, 1803 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY,
1763 POLICY_SCOPE_USER, 1804 POLICY_SCOPE_USER,
1764 base::Value::CreateStringValue(chrome::kChromeUICreditsURL), 1805 base::Value::CreateStringValue(chrome::kChromeUICreditsURL),
1765 NULL); 1806 NULL);
1766 UpdateProviderPolicy(policies); 1807 UpdateProviderPolicy(policies);
1767 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 1808 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
1768 content::WaitForLoadStop(contents); 1809 content::WaitForLoadStop(contents);
1769 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); 1810 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL());
1770 1811
1771 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, 1812 policies.Set(key::kHomepageIsNewTabPage,
1772 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1813 POLICY_LEVEL_MANDATORY,
1814 POLICY_SCOPE_USER,
1815 new base::FundamentalValue(true),
1816 NULL);
1773 UpdateProviderPolicy(policies); 1817 UpdateProviderPolicy(policies);
1774 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 1818 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
1775 content::WaitForLoadStop(contents); 1819 content::WaitForLoadStop(contents);
1776 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); 1820 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL());
1777 } 1821 }
1778 1822
1779 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { 1823 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) {
1780 // Verifies that incognito windows can't be opened when disabled by policy. 1824 // Verifies that incognito windows can't be opened when disabled by policy.
1781 1825
1782 const BrowserList* active_browser_list = 1826 const BrowserList* active_browser_list =
1783 BrowserList::GetInstance(chrome::GetActiveDesktop()); 1827 BrowserList::GetInstance(chrome::GetActiveDesktop());
1784 1828
1785 // Disable incognito via policy and verify that incognito windows can't be 1829 // Disable incognito via policy and verify that incognito windows can't be
1786 // opened. 1830 // opened.
1787 EXPECT_EQ(1u, active_browser_list->size()); 1831 EXPECT_EQ(1u, active_browser_list->size());
1788 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); 1832 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive());
1789 PolicyMap policies; 1833 PolicyMap policies;
1790 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, 1834 policies.Set(key::kIncognitoEnabled,
1791 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1835 POLICY_LEVEL_MANDATORY,
1836 POLICY_SCOPE_USER,
1837 new base::FundamentalValue(false),
1838 NULL);
1792 UpdateProviderPolicy(policies); 1839 UpdateProviderPolicy(policies);
1793 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); 1840 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW));
1794 EXPECT_EQ(1u, active_browser_list->size()); 1841 EXPECT_EQ(1u, active_browser_list->size());
1795 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); 1842 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive());
1796 1843
1797 // Enable via policy and verify that incognito windows can be opened. 1844 // Enable via policy and verify that incognito windows can be opened.
1798 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, 1845 policies.Set(key::kIncognitoEnabled,
1799 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1846 POLICY_LEVEL_MANDATORY,
1847 POLICY_SCOPE_USER,
1848 new base::FundamentalValue(true),
1849 NULL);
1800 UpdateProviderPolicy(policies); 1850 UpdateProviderPolicy(policies);
1801 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); 1851 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW));
1802 EXPECT_EQ(2u, active_browser_list->size()); 1852 EXPECT_EQ(2u, active_browser_list->size());
1803 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); 1853 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive());
1804 } 1854 }
1805 1855
1806 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { 1856 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) {
1807 // Verifies that Javascript can be disabled. 1857 // Verifies that Javascript can be disabled.
1808 content::WebContents* contents = 1858 content::WebContents* contents =
1809 browser()->tab_strip_model()->GetActiveWebContents(); 1859 browser()->tab_strip_model()->GetActiveWebContents();
1810 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1860 EXPECT_TRUE(IsJavascriptEnabled(contents));
1811 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); 1861 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS));
1812 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); 1862 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE));
1813 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); 1863 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES));
1814 1864
1815 // Disable Javascript via policy. 1865 // Disable Javascript via policy.
1816 PolicyMap policies; 1866 PolicyMap policies;
1817 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, 1867 policies.Set(key::kJavascriptEnabled,
1818 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1868 POLICY_LEVEL_MANDATORY,
1869 POLICY_SCOPE_USER,
1870 new base::FundamentalValue(false),
1871 NULL);
1819 UpdateProviderPolicy(policies); 1872 UpdateProviderPolicy(policies);
1820 // Reload the page. 1873 // Reload the page.
1821 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1874 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1822 EXPECT_FALSE(IsJavascriptEnabled(contents)); 1875 EXPECT_FALSE(IsJavascriptEnabled(contents));
1823 // Developer tools still work when javascript is disabled. 1876 // Developer tools still work when javascript is disabled.
1824 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); 1877 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS));
1825 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); 1878 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE));
1826 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); 1879 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES));
1827 // Javascript is always enabled for the internal pages. 1880 // Javascript is always enabled for the internal pages.
1828 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 1881 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
1829 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1882 EXPECT_TRUE(IsJavascriptEnabled(contents));
1830 1883
1831 // The javascript content setting policy overrides the javascript policy. 1884 // The javascript content setting policy overrides the javascript policy.
1832 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1885 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1833 EXPECT_FALSE(IsJavascriptEnabled(contents)); 1886 EXPECT_FALSE(IsJavascriptEnabled(contents));
1834 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, 1887 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY,
1835 POLICY_SCOPE_USER, 1888 POLICY_SCOPE_USER,
1836 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW), NULL); 1889 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW), NULL);
1837 UpdateProviderPolicy(policies); 1890 UpdateProviderPolicy(policies);
1838 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1891 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1839 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1892 EXPECT_TRUE(IsJavascriptEnabled(contents));
1840 } 1893 }
1841 1894
1842 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { 1895 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) {
1843 // Verifies that browsing history is not saved. 1896 // Verifies that browsing history is not saved.
1844 PolicyMap policies; 1897 PolicyMap policies;
1845 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, 1898 policies.Set(key::kSavingBrowserHistoryDisabled,
1846 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1899 POLICY_LEVEL_MANDATORY,
1900 POLICY_SCOPE_USER,
1901 new base::FundamentalValue(true),
1902 NULL);
1847 UpdateProviderPolicy(policies); 1903 UpdateProviderPolicy(policies);
1848 GURL url = ui_test_utils::GetTestUrl( 1904 GURL url = ui_test_utils::GetTestUrl(
1849 base::FilePath(base::FilePath::kCurrentDirectory), 1905 base::FilePath(base::FilePath::kCurrentDirectory),
1850 base::FilePath(FILE_PATH_LITERAL("empty.html"))); 1906 base::FilePath(FILE_PATH_LITERAL("empty.html")));
1851 ui_test_utils::NavigateToURL(browser(), url); 1907 ui_test_utils::NavigateToURL(browser(), url);
1852 // Verify that the navigation wasn't saved in the history. 1908 // Verify that the navigation wasn't saved in the history.
1853 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); 1909 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile());
1854 EXPECT_EQ(0u, enumerator1.urls().size()); 1910 EXPECT_EQ(0u, enumerator1.urls().size());
1855 1911
1856 // Now flip the policy and try again. 1912 // Now flip the policy and try again.
1857 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, 1913 policies.Set(key::kSavingBrowserHistoryDisabled,
1858 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1914 POLICY_LEVEL_MANDATORY,
1915 POLICY_SCOPE_USER,
1916 new base::FundamentalValue(false),
1917 NULL);
1859 UpdateProviderPolicy(policies); 1918 UpdateProviderPolicy(policies);
1860 ui_test_utils::NavigateToURL(browser(), url); 1919 ui_test_utils::NavigateToURL(browser(), url);
1861 // Verify that the navigation was saved in the history. 1920 // Verify that the navigation was saved in the history.
1862 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); 1921 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile());
1863 ASSERT_EQ(1u, enumerator2.urls().size()); 1922 ASSERT_EQ(1u, enumerator2.urls().size());
1864 EXPECT_EQ(url, enumerator2.urls()[0]); 1923 EXPECT_EQ(url, enumerator2.urls()[0]);
1865 } 1924 }
1866 1925
1867 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. 1926 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly.
1868 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { 1927 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) {
(...skipping 10 matching lines...) Expand all
1879 // Get the InfoBarService, and verify that there are no infobars on startup. 1938 // Get the InfoBarService, and verify that there are no infobars on startup.
1880 content::WebContents* contents = 1939 content::WebContents* contents =
1881 browser()->tab_strip_model()->GetActiveWebContents(); 1940 browser()->tab_strip_model()->GetActiveWebContents();
1882 ASSERT_TRUE(contents); 1941 ASSERT_TRUE(contents);
1883 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); 1942 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
1884 ASSERT_TRUE(infobar_service); 1943 ASSERT_TRUE(infobar_service);
1885 EXPECT_EQ(0u, infobar_service->infobar_count()); 1944 EXPECT_EQ(0u, infobar_service->infobar_count());
1886 1945
1887 // Force enable the translate feature. 1946 // Force enable the translate feature.
1888 PolicyMap policies; 1947 PolicyMap policies;
1889 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, 1948 policies.Set(key::kTranslateEnabled,
1890 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1949 POLICY_LEVEL_MANDATORY,
1950 POLICY_SCOPE_USER,
1951 new base::FundamentalValue(true),
1952 NULL);
1891 UpdateProviderPolicy(policies); 1953 UpdateProviderPolicy(policies);
1892 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test 1954 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test
1893 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the 1955 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the
1894 // TranslateManager observes. This allows checking that an infobar is NOT 1956 // TranslateManager observes. This allows checking that an infobar is NOT
1895 // shown below, without polling for infobars for some indeterminate amount 1957 // shown below, without polling for infobars for some indeterminate amount
1896 // of time. 1958 // of time.
1897 GURL url = ui_test_utils::GetTestUrl( 1959 GURL url = ui_test_utils::GetTestUrl(
1898 base::FilePath(), 1960 base::FilePath(),
1899 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html"))); 1961 base::FilePath(FILE_PATH_LITERAL("translate/fr_test.html")));
1900 content::WindowedNotificationObserver language_observer1( 1962 content::WindowedNotificationObserver language_observer1(
(...skipping 19 matching lines...) Expand all
1920 TranslateInfoBarDelegate* translate_infobar_delegate = 1982 TranslateInfoBarDelegate* translate_infobar_delegate =
1921 infobar->delegate()->AsTranslateInfoBarDelegate(); 1983 infobar->delegate()->AsTranslateInfoBarDelegate();
1922 ASSERT_TRUE(translate_infobar_delegate); 1984 ASSERT_TRUE(translate_infobar_delegate);
1923 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, 1985 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE,
1924 translate_infobar_delegate->translate_step()); 1986 translate_infobar_delegate->translate_step());
1925 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); 1987 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code());
1926 1988
1927 // Now force disable translate. 1989 // Now force disable translate.
1928 infobar_service->RemoveInfoBar(infobar); 1990 infobar_service->RemoveInfoBar(infobar);
1929 EXPECT_EQ(0u, infobar_service->infobar_count()); 1991 EXPECT_EQ(0u, infobar_service->infobar_count());
1930 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, 1992 policies.Set(key::kTranslateEnabled,
1931 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1993 POLICY_LEVEL_MANDATORY,
1994 POLICY_SCOPE_USER,
1995 new base::FundamentalValue(false),
1996 NULL);
1932 UpdateProviderPolicy(policies); 1997 UpdateProviderPolicy(policies);
1933 // Navigating to the same URL now doesn't trigger an infobar. 1998 // Navigating to the same URL now doesn't trigger an infobar.
1934 content::WindowedNotificationObserver language_observer2( 1999 content::WindowedNotificationObserver language_observer2(
1935 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 2000 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1936 content::NotificationService::AllSources()); 2001 content::NotificationService::AllSources());
1937 ui_test_utils::NavigateToURL(browser(), url); 2002 ui_test_utils::NavigateToURL(browser(), url);
1938 language_observer2.Wait(); 2003 language_observer2.Wait();
1939 EXPECT_EQ(0u, infobar_service->infobar_count()); 2004 EXPECT_EQ(0u, infobar_service->infobar_count());
1940 } 2005 }
1941 2006
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 FlushBlacklistPolicy(); 2125 FlushBlacklistPolicy();
2061 2126
2062 CheckCanOpenURL(browser(), file_path1.c_str()); 2127 CheckCanOpenURL(browser(), file_path1.c_str());
2063 CheckURLIsBlocked(browser(), file_path2.c_str()); 2128 CheckURLIsBlocked(browser(), file_path2.c_str());
2064 } 2129 }
2065 2130
2066 #if !defined(OS_MACOSX) 2131 #if !defined(OS_MACOSX)
2067 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { 2132 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) {
2068 PolicyMap policies; 2133 PolicyMap policies;
2069 policies.Set(key::kFullscreenAllowed, 2134 policies.Set(key::kFullscreenAllowed,
2070 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2135 POLICY_LEVEL_MANDATORY,
2071 base::Value::CreateBooleanValue(false), NULL); 2136 POLICY_SCOPE_USER,
2137 new base::FundamentalValue(false),
2138 NULL);
2072 UpdateProviderPolicy(policies); 2139 UpdateProviderPolicy(policies);
2073 2140
2074 BrowserWindow* browser_window = browser()->window(); 2141 BrowserWindow* browser_window = browser()->window();
2075 ASSERT_TRUE(browser_window); 2142 ASSERT_TRUE(browser_window);
2076 2143
2077 EXPECT_FALSE(browser_window->IsFullscreen()); 2144 EXPECT_FALSE(browser_window->IsFullscreen());
2078 chrome::ToggleFullscreenMode(browser()); 2145 chrome::ToggleFullscreenMode(browser());
2079 EXPECT_FALSE(browser_window->IsFullscreen()); 2146 EXPECT_FALSE(browser_window->IsFullscreen());
2080 } 2147 }
2081 2148
2082 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { 2149 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) {
2083 PolicyMap policies; 2150 PolicyMap policies;
2084 policies.Set(key::kFullscreenAllowed, 2151 policies.Set(key::kFullscreenAllowed,
2085 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2152 POLICY_LEVEL_MANDATORY,
2086 base::Value::CreateBooleanValue(false), NULL); 2153 POLICY_SCOPE_USER,
2154 new base::FundamentalValue(false),
2155 NULL);
2087 UpdateProviderPolicy(policies); 2156 UpdateProviderPolicy(policies);
2088 2157
2089 const extensions::Extension* extension = 2158 const extensions::Extension* extension =
2090 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); 2159 LoadUnpackedExtension(kUnpackedFullscreenAppName, true);
2091 ASSERT_TRUE(extension); 2160 ASSERT_TRUE(extension);
2092 2161
2093 // Launch an app that tries to open a fullscreen window. 2162 // Launch an app that tries to open a fullscreen window.
2094 TestAddAppWindowObserver add_window_observer( 2163 TestAddAppWindowObserver add_window_observer(
2095 apps::AppWindowRegistry::Get(browser()->profile())); 2164 apps::AppWindowRegistry::Get(browser()->profile()));
2096 OpenApplication(AppLaunchParams(browser()->profile(), 2165 OpenApplication(AppLaunchParams(browser()->profile(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 scoped_ptr<TestAudioObserver> test_observer(new TestAudioObserver); 2205 scoped_ptr<TestAudioObserver> test_observer(new TestAudioObserver);
2137 audio_handler->AddAudioObserver(test_observer.get()); 2206 audio_handler->AddAudioObserver(test_observer.get());
2138 2207
2139 bool prior_state = audio_handler->IsOutputMuted(); 2208 bool prior_state = audio_handler->IsOutputMuted();
2140 // Make sure the audio is not muted and then toggle the policy and observe 2209 // Make sure the audio is not muted and then toggle the policy and observe
2141 // if the output mute changed event is fired. 2210 // if the output mute changed event is fired.
2142 audio_handler->SetOutputMute(false); 2211 audio_handler->SetOutputMute(false);
2143 EXPECT_FALSE(audio_handler->IsOutputMuted()); 2212 EXPECT_FALSE(audio_handler->IsOutputMuted());
2144 EXPECT_EQ(1, test_observer->output_mute_changed_count()); 2213 EXPECT_EQ(1, test_observer->output_mute_changed_count());
2145 PolicyMap policies; 2214 PolicyMap policies;
2146 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, 2215 policies.Set(key::kAudioOutputAllowed,
2147 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 2216 POLICY_LEVEL_MANDATORY,
2217 POLICY_SCOPE_USER,
2218 new base::FundamentalValue(false),
2219 NULL);
2148 UpdateProviderPolicy(policies); 2220 UpdateProviderPolicy(policies);
2149 EXPECT_TRUE(audio_handler->IsOutputMuted()); 2221 EXPECT_TRUE(audio_handler->IsOutputMuted());
2150 // This should not change the state now and should not trigger output mute 2222 // This should not change the state now and should not trigger output mute
2151 // changed event. 2223 // changed event.
2152 audio_handler->SetOutputMute(false); 2224 audio_handler->SetOutputMute(false);
2153 EXPECT_TRUE(audio_handler->IsOutputMuted()); 2225 EXPECT_TRUE(audio_handler->IsOutputMuted());
2154 EXPECT_EQ(1, test_observer->output_mute_changed_count()); 2226 EXPECT_EQ(1, test_observer->output_mute_changed_count());
2155 2227
2156 // Toggle back and observe if the output mute changed event is fired. 2228 // Toggle back and observe if the output mute changed event is fired.
2157 policies.Set(key::kAudioOutputAllowed, POLICY_LEVEL_MANDATORY, 2229 policies.Set(key::kAudioOutputAllowed,
2158 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 2230 POLICY_LEVEL_MANDATORY,
2231 POLICY_SCOPE_USER,
2232 new base::FundamentalValue(true),
2233 NULL);
2159 UpdateProviderPolicy(policies); 2234 UpdateProviderPolicy(policies);
2160 EXPECT_FALSE(audio_handler->IsOutputMuted()); 2235 EXPECT_FALSE(audio_handler->IsOutputMuted());
2161 EXPECT_EQ(1, test_observer->output_mute_changed_count()); 2236 EXPECT_EQ(1, test_observer->output_mute_changed_count());
2162 audio_handler->SetOutputMute(true); 2237 audio_handler->SetOutputMute(true);
2163 EXPECT_TRUE(audio_handler->IsOutputMuted()); 2238 EXPECT_TRUE(audio_handler->IsOutputMuted());
2164 EXPECT_EQ(2, test_observer->output_mute_changed_count()); 2239 EXPECT_EQ(2, test_observer->output_mute_changed_count());
2165 // Revert the prior state. 2240 // Revert the prior state.
2166 audio_handler->SetOutputMute(prior_state); 2241 audio_handler->SetOutputMute(prior_state);
2167 audio_handler->RemoveAudioObserver(test_observer.get()); 2242 audio_handler->RemoveAudioObserver(test_observer.get());
2168 } 2243 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 // through policy. 2383 // through policy.
2309 chromeos::AccessibilityManager* accessibility_manager = 2384 chromeos::AccessibilityManager* accessibility_manager =
2310 chromeos::AccessibilityManager::Get(); 2385 chromeos::AccessibilityManager::Get();
2311 2386
2312 // Manually enable the large cursor. 2387 // Manually enable the large cursor.
2313 accessibility_manager->EnableLargeCursor(true); 2388 accessibility_manager->EnableLargeCursor(true);
2314 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); 2389 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled());
2315 2390
2316 // Verify that policy overrides the manual setting. 2391 // Verify that policy overrides the manual setting.
2317 PolicyMap policies; 2392 PolicyMap policies;
2318 policies.Set(key::kLargeCursorEnabled, POLICY_LEVEL_MANDATORY, 2393 policies.Set(key::kLargeCursorEnabled,
2394 POLICY_LEVEL_MANDATORY,
2319 POLICY_SCOPE_USER, 2395 POLICY_SCOPE_USER,
2320 base::Value::CreateBooleanValue(false), NULL); 2396 new base::FundamentalValue(false),
2397 NULL);
2321 UpdateProviderPolicy(policies); 2398 UpdateProviderPolicy(policies);
2322 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); 2399 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled());
2323 2400
2324 // Verify that the large cursor cannot be enabled manually anymore. 2401 // Verify that the large cursor cannot be enabled manually anymore.
2325 accessibility_manager->EnableLargeCursor(true); 2402 accessibility_manager->EnableLargeCursor(true);
2326 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); 2403 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled());
2327 } 2404 }
2328 2405
2329 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { 2406 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) {
2330 // Verifies that the spoken feedback accessibility feature can be controlled 2407 // Verifies that the spoken feedback accessibility feature can be controlled
2331 // through policy. 2408 // through policy.
2332 chromeos::AccessibilityManager* accessibility_manager = 2409 chromeos::AccessibilityManager* accessibility_manager =
2333 chromeos::AccessibilityManager::Get(); 2410 chromeos::AccessibilityManager::Get();
2334 2411
2335 // Manually enable spoken feedback. 2412 // Manually enable spoken feedback.
2336 accessibility_manager->EnableSpokenFeedback( 2413 accessibility_manager->EnableSpokenFeedback(
2337 true, ash::A11Y_NOTIFICATION_NONE); 2414 true, ash::A11Y_NOTIFICATION_NONE);
2338 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); 2415 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled());
2339 2416
2340 // Verify that policy overrides the manual setting. 2417 // Verify that policy overrides the manual setting.
2341 PolicyMap policies; 2418 PolicyMap policies;
2342 policies.Set(key::kSpokenFeedbackEnabled, POLICY_LEVEL_MANDATORY, 2419 policies.Set(key::kSpokenFeedbackEnabled,
2420 POLICY_LEVEL_MANDATORY,
2343 POLICY_SCOPE_USER, 2421 POLICY_SCOPE_USER,
2344 base::Value::CreateBooleanValue(false), NULL); 2422 new base::FundamentalValue(false),
2423 NULL);
2345 UpdateProviderPolicy(policies); 2424 UpdateProviderPolicy(policies);
2346 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); 2425 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled());
2347 2426
2348 // Verify that spoken feedback cannot be enabled manually anymore. 2427 // Verify that spoken feedback cannot be enabled manually anymore.
2349 accessibility_manager->EnableSpokenFeedback( 2428 accessibility_manager->EnableSpokenFeedback(
2350 true, ash::A11Y_NOTIFICATION_NONE); 2429 true, ash::A11Y_NOTIFICATION_NONE);
2351 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); 2430 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled());
2352 } 2431 }
2353 2432
2354 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { 2433 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) {
2355 // Verifies that the high contrast mode accessibility feature can be 2434 // Verifies that the high contrast mode accessibility feature can be
2356 // controlled through policy. 2435 // controlled through policy.
2357 chromeos::AccessibilityManager* accessibility_manager = 2436 chromeos::AccessibilityManager* accessibility_manager =
2358 chromeos::AccessibilityManager::Get(); 2437 chromeos::AccessibilityManager::Get();
2359 2438
2360 // Manually enable high contrast mode. 2439 // Manually enable high contrast mode.
2361 accessibility_manager->EnableHighContrast(true); 2440 accessibility_manager->EnableHighContrast(true);
2362 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); 2441 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled());
2363 2442
2364 // Verify that policy overrides the manual setting. 2443 // Verify that policy overrides the manual setting.
2365 PolicyMap policies; 2444 PolicyMap policies;
2366 policies.Set(key::kHighContrastEnabled, POLICY_LEVEL_MANDATORY, 2445 policies.Set(key::kHighContrastEnabled,
2446 POLICY_LEVEL_MANDATORY,
2367 POLICY_SCOPE_USER, 2447 POLICY_SCOPE_USER,
2368 base::Value::CreateBooleanValue(false), NULL); 2448 new base::FundamentalValue(false),
2449 NULL);
2369 UpdateProviderPolicy(policies); 2450 UpdateProviderPolicy(policies);
2370 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); 2451 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled());
2371 2452
2372 // Verify that high contrast mode cannot be enabled manually anymore. 2453 // Verify that high contrast mode cannot be enabled manually anymore.
2373 accessibility_manager->EnableHighContrast(true); 2454 accessibility_manager->EnableHighContrast(true);
2374 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); 2455 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled());
2375 } 2456 }
2376 2457
2377 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { 2458 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) {
2378 // Verifies that the screen magnifier can be disabled through policy. 2459 // Verifies that the screen magnifier can be disabled through policy.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 // controlled through policy. 2506 // controlled through policy.
2426 chromeos::AccessibilityManager* accessibility_manager = 2507 chromeos::AccessibilityManager* accessibility_manager =
2427 chromeos::AccessibilityManager::Get(); 2508 chromeos::AccessibilityManager::Get();
2428 2509
2429 // Manually enable the on-screen keyboard. 2510 // Manually enable the on-screen keyboard.
2430 accessibility_manager->EnableVirtualKeyboard(true); 2511 accessibility_manager->EnableVirtualKeyboard(true);
2431 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); 2512 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled());
2432 2513
2433 // Verify that policy overrides the manual setting. 2514 // Verify that policy overrides the manual setting.
2434 PolicyMap policies; 2515 PolicyMap policies;
2435 policies.Set(key::kVirtualKeyboardEnabled, POLICY_LEVEL_MANDATORY, 2516 policies.Set(key::kVirtualKeyboardEnabled,
2517 POLICY_LEVEL_MANDATORY,
2436 POLICY_SCOPE_USER, 2518 POLICY_SCOPE_USER,
2437 base::Value::CreateBooleanValue(false), NULL); 2519 new base::FundamentalValue(false),
2520 NULL);
2438 UpdateProviderPolicy(policies); 2521 UpdateProviderPolicy(policies);
2439 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); 2522 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled());
2440 2523
2441 // Verify that the on-screen keyboard cannot be enabled manually anymore. 2524 // Verify that the on-screen keyboard cannot be enabled manually anymore.
2442 accessibility_manager->EnableVirtualKeyboard(true); 2525 accessibility_manager->EnableVirtualKeyboard(true);
2443 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); 2526 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled());
2444 } 2527 }
2445 2528
2446 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { 2529 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) {
2447 // Verify keyboard disabled by default. 2530 // Verify keyboard disabled by default.
2448 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 2531 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
2449 // Verify keyboard can be toggled by default. 2532 // Verify keyboard can be toggled by default.
2450 keyboard::SetTouchKeyboardEnabled(true); 2533 keyboard::SetTouchKeyboardEnabled(true);
2451 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 2534 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
2452 keyboard::SetTouchKeyboardEnabled(false); 2535 keyboard::SetTouchKeyboardEnabled(false);
2453 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 2536 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
2454 2537
2455 // Verify enabling the policy takes effect immediately and that that user 2538 // Verify enabling the policy takes effect immediately and that that user
2456 // cannot disable the keyboard.. 2539 // cannot disable the keyboard..
2457 PolicyMap policies; 2540 PolicyMap policies;
2458 policies.Set(key::kTouchVirtualKeyboardEnabled, 2541 policies.Set(key::kTouchVirtualKeyboardEnabled,
2459 POLICY_LEVEL_MANDATORY, 2542 POLICY_LEVEL_MANDATORY,
2460 POLICY_SCOPE_USER, 2543 POLICY_SCOPE_USER,
2461 base::Value::CreateBooleanValue(true), 2544 new base::FundamentalValue(true),
2462 NULL); 2545 NULL);
2463 UpdateProviderPolicy(policies); 2546 UpdateProviderPolicy(policies);
2464 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 2547 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
2465 keyboard::SetTouchKeyboardEnabled(false); 2548 keyboard::SetTouchKeyboardEnabled(false);
2466 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 2549 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
2467 2550
2468 // Verify that disabling the policy takes effect immediately and that the user 2551 // Verify that disabling the policy takes effect immediately and that the user
2469 // cannot enable the keyboard. 2552 // cannot enable the keyboard.
2470 policies.Set(key::kTouchVirtualKeyboardEnabled, 2553 policies.Set(key::kTouchVirtualKeyboardEnabled,
2471 POLICY_LEVEL_MANDATORY, 2554 POLICY_LEVEL_MANDATORY,
2472 POLICY_SCOPE_USER, 2555 POLICY_SCOPE_USER,
2473 base::Value::CreateBooleanValue(false), 2556 new base::FundamentalValue(false),
2474 NULL); 2557 NULL);
2475 UpdateProviderPolicy(policies); 2558 UpdateProviderPolicy(policies);
2476 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 2559 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
2477 keyboard::SetTouchKeyboardEnabled(true); 2560 keyboard::SetTouchKeyboardEnabled(true);
2478 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 2561 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
2479 } 2562 }
2480 2563
2481 #endif 2564 #endif
2482 2565
2483 namespace { 2566 namespace {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2533 2616
2534 void HomepageIsNotNTP() { 2617 void HomepageIsNotNTP() {
2535 // Verifies that policy can set the startup pages to the homepage, when 2618 // Verifies that policy can set the startup pages to the homepage, when
2536 // the homepage is not the NTP. 2619 // the homepage is not the NTP.
2537 PolicyMap policies; 2620 PolicyMap policies;
2538 policies.Set( 2621 policies.Set(
2539 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2622 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2540 base::Value::CreateIntegerValue( 2623 base::Value::CreateIntegerValue(
2541 SessionStartupPref::kPrefValueHomePage), 2624 SessionStartupPref::kPrefValueHomePage),
2542 NULL); 2625 NULL);
2543 policies.Set( 2626 policies.Set(key::kHomepageIsNewTabPage,
2544 key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2627 POLICY_LEVEL_MANDATORY,
2545 base::Value::CreateBooleanValue(false), NULL); 2628 POLICY_SCOPE_USER,
2629 new base::FundamentalValue(false),
2630 NULL);
2546 policies.Set( 2631 policies.Set(
2547 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2632 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2548 base::Value::CreateStringValue(kRestoredURLs[1]), NULL); 2633 base::Value::CreateStringValue(kRestoredURLs[1]), NULL);
2549 provider_.UpdateChromePolicy(policies); 2634 provider_.UpdateChromePolicy(policies);
2550 2635
2551 expected_urls_.push_back(GURL(kRestoredURLs[1])); 2636 expected_urls_.push_back(GURL(kRestoredURLs[1]));
2552 } 2637 }
2553 2638
2554 void HomepageIsNTP() { 2639 void HomepageIsNTP() {
2555 // Verifies that policy can set the startup pages to the homepage, when 2640 // Verifies that policy can set the startup pages to the homepage, when
2556 // the homepage is the NTP. 2641 // the homepage is the NTP.
2557 PolicyMap policies; 2642 PolicyMap policies;
2558 policies.Set( 2643 policies.Set(
2559 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2644 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2560 base::Value::CreateIntegerValue( 2645 base::Value::CreateIntegerValue(
2561 SessionStartupPref::kPrefValueHomePage), 2646 SessionStartupPref::kPrefValueHomePage),
2562 NULL); 2647 NULL);
2563 policies.Set( 2648 policies.Set(key::kHomepageIsNewTabPage,
2564 key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2649 POLICY_LEVEL_MANDATORY,
2565 base::Value::CreateBooleanValue(true), NULL); 2650 POLICY_SCOPE_USER,
2651 new base::FundamentalValue(true),
2652 NULL);
2566 provider_.UpdateChromePolicy(policies); 2653 provider_.UpdateChromePolicy(policies);
2567 2654
2568 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); 2655 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL));
2569 } 2656 }
2570 2657
2571 void ListOfURLs() { 2658 void ListOfURLs() {
2572 // Verifies that policy can set the startup pages to a list of URLs. 2659 // Verifies that policy can set the startup pages to a list of URLs.
2573 base::ListValue urls; 2660 base::ListValue urls;
2574 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { 2661 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) {
2575 urls.Append(base::Value::CreateStringValue(kRestoredURLs[i])); 2662 urls.Append(base::Value::CreateStringValue(kRestoredURLs[i]));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 // Similar to PolicyTest but sets a couple of policies before the browser is 2742 // Similar to PolicyTest but sets a couple of policies before the browser is
2656 // started. 2743 // started.
2657 class PolicyStatisticsCollectorTest : public PolicyTest { 2744 class PolicyStatisticsCollectorTest : public PolicyTest {
2658 public: 2745 public:
2659 PolicyStatisticsCollectorTest() {} 2746 PolicyStatisticsCollectorTest() {}
2660 virtual ~PolicyStatisticsCollectorTest() {} 2747 virtual ~PolicyStatisticsCollectorTest() {}
2661 2748
2662 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 2749 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
2663 PolicyTest::SetUpInProcessBrowserTestFixture(); 2750 PolicyTest::SetUpInProcessBrowserTestFixture();
2664 PolicyMap policies; 2751 PolicyMap policies;
2665 policies.Set( 2752 policies.Set(key::kShowHomeButton,
2666 key::kShowHomeButton, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2753 POLICY_LEVEL_MANDATORY,
2667 base::Value::CreateBooleanValue(true), NULL); 2754 POLICY_SCOPE_USER,
2668 policies.Set( 2755 new base::FundamentalValue(true),
2669 key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2756 NULL);
2670 base::Value::CreateBooleanValue(false), NULL); 2757 policies.Set(key::kBookmarkBarEnabled,
2758 POLICY_LEVEL_MANDATORY,
2759 POLICY_SCOPE_USER,
2760 new base::FundamentalValue(false),
2761 NULL);
2671 policies.Set( 2762 policies.Set(
2672 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2763 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2673 base::Value::CreateStringValue("http://chromium.org"), NULL); 2764 base::Value::CreateStringValue("http://chromium.org"), NULL);
2674 provider_.UpdateChromePolicy(policies); 2765 provider_.UpdateChromePolicy(policies);
2675 } 2766 }
2676 }; 2767 };
2677 2768
2678 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { 2769 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) {
2679 // Verifies that policy usage histograms are collected at startup. 2770 // Verifies that policy usage histograms are collected at startup.
2680 2771
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 // Configure a given policy map. 2818 // Configure a given policy map.
2728 // The |policy_name| is the name of either the audio or video capture allow 2819 // The |policy_name| is the name of either the audio or video capture allow
2729 // policy and must never be NULL. 2820 // policy and must never be NULL.
2730 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist 2821 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist
2731 // policy is set. If non-NULL, the request_url_ will be set to be non empty 2822 // policy is set. If non-NULL, the request_url_ will be set to be non empty
2732 // and the whitelist policy is set to contain either the |allow_rule| (if 2823 // and the whitelist policy is set to contain either the |allow_rule| (if
2733 // non-NULL) or an "allow all" wildcard. 2824 // non-NULL) or an "allow all" wildcard.
2734 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, 2825 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name,
2735 const char* whitelist_policy, 2826 const char* whitelist_policy,
2736 const char* allow_rule) { 2827 const char* allow_rule) {
2737 policies->Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2828 policies->Set(policy_name,
2738 base::Value::CreateBooleanValue(policy_value_), NULL); 2829 POLICY_LEVEL_MANDATORY,
2830 POLICY_SCOPE_USER,
2831 new base::FundamentalValue(policy_value_),
2832 NULL);
2739 2833
2740 if (whitelist_policy) { 2834 if (whitelist_policy) {
2741 // TODO(tommi): Remove the kiosk mode flag when the whitelist is visible 2835 // TODO(tommi): Remove the kiosk mode flag when the whitelist is visible
2742 // in the media exceptions UI. 2836 // in the media exceptions UI.
2743 // See discussion here: https://codereview.chromium.org/15738004/ 2837 // See discussion here: https://codereview.chromium.org/15738004/
2744 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kKioskMode); 2838 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kKioskMode);
2745 2839
2746 // Add an entry to the whitelist that allows the specified URL regardless 2840 // Add an entry to the whitelist that allows the specified URL regardless
2747 // of the setting of kAudioCapturedAllowed. 2841 // of the setting of kAudioCapturedAllowed.
2748 request_url_ = GURL("http://www.example.com/foo"); 2842 request_url_ = GURL("http://www.example.com/foo");
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3131 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3038 browser2->tab_strip_model()->GetActiveWebContents(), 3132 browser2->tab_strip_model()->GetActiveWebContents(),
3039 "domAutomationController.send(window.showModalDialog !== undefined);", 3133 "domAutomationController.send(window.showModalDialog !== undefined);",
3040 &result)); 3134 &result));
3041 EXPECT_TRUE(result); 3135 EXPECT_TRUE(result);
3042 } 3136 }
3043 3137
3044 #endif // !defined(CHROME_OS) 3138 #endif // !defined(CHROME_OS)
3045 3139
3046 } // namespace policy 3140 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/javascript_policy_handler_unittest.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698