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

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

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed another test. Created 5 years, 3 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
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 "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #include "components/omnibox/browser/autocomplete_controller.h" 93 #include "components/omnibox/browser/autocomplete_controller.h"
94 #include "components/omnibox/browser/omnibox_edit_model.h" 94 #include "components/omnibox/browser/omnibox_edit_model.h"
95 #include "components/omnibox/browser/omnibox_view.h" 95 #include "components/omnibox/browser/omnibox_view.h"
96 #include "components/policy/core/browser/browser_policy_connector.h" 96 #include "components/policy/core/browser/browser_policy_connector.h"
97 #include "components/policy/core/common/external_data_fetcher.h" 97 #include "components/policy/core/common/external_data_fetcher.h"
98 #include "components/policy/core/common/mock_configuration_policy_provider.h" 98 #include "components/policy/core/common/mock_configuration_policy_provider.h"
99 #include "components/policy/core/common/policy_map.h" 99 #include "components/policy/core/common/policy_map.h"
100 #include "components/policy/core/common/policy_pref_names.h" 100 #include "components/policy/core/common/policy_pref_names.h"
101 #include "components/policy/core/common/policy_service.h" 101 #include "components/policy/core/common/policy_service.h"
102 #include "components/policy/core/common/policy_service_impl.h" 102 #include "components/policy/core/common/policy_service_impl.h"
103 #include "components/policy/core/common/policy_types.h"
103 #include "components/search/search.h" 104 #include "components/search/search.h"
104 #include "components/search_engines/template_url.h" 105 #include "components/search_engines/template_url.h"
105 #include "components/search_engines/template_url_service.h" 106 #include "components/search_engines/template_url_service.h"
106 #include "components/translate/core/browser/language_state.h" 107 #include "components/translate/core/browser/language_state.h"
107 #include "components/translate/core/browser/translate_infobar_delegate.h" 108 #include "components/translate/core/browser/translate_infobar_delegate.h"
108 #include "components/variations/service/variations_service.h" 109 #include "components/variations/service/variations_service.h"
109 #include "components/version_info/version_info.h" 110 #include "components/version_info/version_info.h"
110 #include "content/public/browser/browser_child_process_host_iterator.h" 111 #include "content/public/browser/browser_child_process_host_iterator.h"
111 #include "content/public/browser/browser_context.h" 112 #include "content/public/browser/browser_context.h"
112 #include "content/public/browser/browser_thread.h" 113 #include "content/public/browser/browser_thread.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 make_scoped_refptr(BrowserThread::GetBlockingPool())), 668 make_scoped_refptr(BrowserThread::GetBlockingPool())),
668 base::MessageLoop::current()->QuitWhenIdleClosure()); 669 base::MessageLoop::current()->QuitWhenIdleClosure());
669 content::RunMessageLoop(); 670 content::RunMessageLoop();
670 } 671 }
671 672
672 void SetScreenshotPolicy(bool enabled) { 673 void SetScreenshotPolicy(bool enabled) {
673 PolicyMap policies; 674 PolicyMap policies;
674 policies.Set(key::kDisableScreenshots, 675 policies.Set(key::kDisableScreenshots,
675 POLICY_LEVEL_MANDATORY, 676 POLICY_LEVEL_MANDATORY,
676 POLICY_SCOPE_USER, 677 POLICY_SCOPE_USER,
678 POLICY_SOURCE_CLOUD,
677 new base::FundamentalValue(!enabled), 679 new base::FundamentalValue(!enabled),
678 NULL); 680 NULL);
679 UpdateProviderPolicy(policies); 681 UpdateProviderPolicy(policies);
680 } 682 }
681 683
682 #if defined(OS_CHROMEOS) 684 #if defined(OS_CHROMEOS)
683 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { 685 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver {
684 public: 686 public:
685 void OnScreenshotCompleted( 687 void OnScreenshotCompleted(
686 ScreenshotGrabberObserver::Result screenshot_result, 688 ScreenshotGrabberObserver::Result screenshot_result,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); 817 contents->GetRenderViewHost()->ForwardMouseEvent(click_event);
816 click_event.type = blink::WebInputEvent::MouseUp; 818 click_event.type = blink::WebInputEvent::MouseUp;
817 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); 819 contents->GetRenderViewHost()->ForwardMouseEvent(click_event);
818 } 820 }
819 821
820 void SetPolicy(PolicyMap* policies, const char* key, base::Value* value) { 822 void SetPolicy(PolicyMap* policies, const char* key, base::Value* value) {
821 if (value) { 823 if (value) {
822 policies->Set(key, 824 policies->Set(key,
823 POLICY_LEVEL_MANDATORY, 825 POLICY_LEVEL_MANDATORY,
824 POLICY_SCOPE_USER, 826 POLICY_SCOPE_USER,
827 POLICY_SOURCE_CLOUD,
825 value, 828 value,
826 nullptr); 829 nullptr);
827 } else { 830 } else {
828 policies->Erase(key); 831 policies->Erase(key);
829 } 832 }
830 } 833 }
831 834
832 void ApplySafeSearchPolicy(base::FundamentalValue* legacy_safe_search, 835 void ApplySafeSearchPolicy(base::FundamentalValue* legacy_safe_search,
833 base::FundamentalValue* google_safe_search, 836 base::FundamentalValue* google_safe_search,
834 base::FundamentalValue* youtube_safety_mode) { 837 base::FundamentalValue* youtube_safety_mode) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 public: 876 public:
874 LocalePolicyTest() {} 877 LocalePolicyTest() {}
875 ~LocalePolicyTest() override {} 878 ~LocalePolicyTest() override {}
876 879
877 void SetUpInProcessBrowserTestFixture() override { 880 void SetUpInProcessBrowserTestFixture() override {
878 PolicyTest::SetUpInProcessBrowserTestFixture(); 881 PolicyTest::SetUpInProcessBrowserTestFixture();
879 PolicyMap policies; 882 PolicyMap policies;
880 policies.Set(key::kApplicationLocaleValue, 883 policies.Set(key::kApplicationLocaleValue,
881 POLICY_LEVEL_MANDATORY, 884 POLICY_LEVEL_MANDATORY,
882 POLICY_SCOPE_USER, 885 POLICY_SCOPE_USER,
886 POLICY_SOURCE_CLOUD,
883 new base::StringValue("fr"), 887 new base::StringValue("fr"),
884 NULL); 888 NULL);
885 provider_.UpdateChromePolicy(policies); 889 provider_.UpdateChromePolicy(policies);
886 // The "en-US" ResourceBundle is always loaded before this step for tests, 890 // The "en-US" ResourceBundle is always loaded before this step for tests,
887 // but in this test we want the browser to load the bundle as it 891 // but in this test we want the browser to load the bundle as it
888 // normally would. 892 // normally would.
889 ResourceBundle::CleanupSharedInstance(); 893 ResourceBundle::CleanupSharedInstance();
890 } 894 }
891 }; 895 };
892 896
(...skipping 28 matching lines...) Expand all
921 // Test starts in about:blank. 925 // Test starts in about:blank.
922 PrefService* prefs = browser()->profile()->GetPrefs(); 926 PrefService* prefs = browser()->profile()->GetPrefs();
923 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); 927 EXPECT_FALSE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar));
924 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); 928 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar));
925 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); 929 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state());
926 930
927 PolicyMap policies; 931 PolicyMap policies;
928 policies.Set(key::kBookmarkBarEnabled, 932 policies.Set(key::kBookmarkBarEnabled,
929 POLICY_LEVEL_MANDATORY, 933 POLICY_LEVEL_MANDATORY,
930 POLICY_SCOPE_USER, 934 POLICY_SCOPE_USER,
935 POLICY_SOURCE_CLOUD,
931 new base::FundamentalValue(true), 936 new base::FundamentalValue(true),
932 NULL); 937 NULL);
933 UpdateProviderPolicy(policies); 938 UpdateProviderPolicy(policies);
934 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); 939 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar));
935 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); 940 EXPECT_TRUE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar));
936 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 941 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
937 942
938 // The NTP has special handling of the bookmark bar. 943 // The NTP has special handling of the bookmark bar.
939 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 944 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
940 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 945 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
941 946
942 policies.Set(key::kBookmarkBarEnabled, 947 policies.Set(key::kBookmarkBarEnabled,
943 POLICY_LEVEL_MANDATORY, 948 POLICY_LEVEL_MANDATORY,
944 POLICY_SCOPE_USER, 949 POLICY_SCOPE_USER,
950 POLICY_SOURCE_CLOUD,
945 new base::FundamentalValue(false), 951 new base::FundamentalValue(false),
946 NULL); 952 NULL);
947 UpdateProviderPolicy(policies); 953 UpdateProviderPolicy(policies);
948 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar)); 954 EXPECT_TRUE(prefs->IsManagedPreference(bookmarks::prefs::kShowBookmarkBar));
949 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); 955 EXPECT_FALSE(prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar));
950 // The bookmark bar is hidden in the NTP when disabled by policy. 956 // The bookmark bar is hidden in the NTP when disabled by policy.
951 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); 957 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state());
952 958
953 policies.Clear(); 959 policies.Clear();
954 UpdateProviderPolicy(policies); 960 UpdateProviderPolicy(policies);
(...skipping 19 matching lines...) Expand all
974 } 980 }
975 981
976 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { 982 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) {
977 // Verify that the cookie persists across restarts. 983 // Verify that the cookie persists across restarts.
978 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); 984 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL)));
979 // Now set the policy and the cookie should be gone after another restart. 985 // Now set the policy and the cookie should be gone after another restart.
980 PolicyMap policies; 986 PolicyMap policies;
981 policies.Set(key::kDefaultCookiesSetting, 987 policies.Set(key::kDefaultCookiesSetting,
982 POLICY_LEVEL_MANDATORY, 988 POLICY_LEVEL_MANDATORY,
983 POLICY_SCOPE_USER, 989 POLICY_SCOPE_USER,
990 POLICY_SOURCE_CLOUD,
984 new base::FundamentalValue(4), 991 new base::FundamentalValue(4),
985 NULL); 992 NULL);
986 UpdateProviderPolicy(policies); 993 UpdateProviderPolicy(policies);
987 } 994 }
988 995
989 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { 996 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) {
990 // Verify that the cookie is gone. 997 // Verify that the cookie is gone.
991 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); 998 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty());
992 } 999 }
993 1000
(...skipping 28 matching lines...) Expand all
1022 kSearchTermsReplacementKey && 1029 kSearchTermsReplacementKey &&
1023 default_search->image_url() == kImageURL && 1030 default_search->image_url() == kImageURL &&
1024 default_search->image_url_post_params() == kImageURLPostParams && 1031 default_search->image_url_post_params() == kImageURLPostParams &&
1025 default_search->new_tab_url() == kNewTabURL); 1032 default_search->new_tab_url() == kNewTabURL);
1026 1033
1027 // Override the default search provider using policies. 1034 // Override the default search provider using policies.
1028 PolicyMap policies; 1035 PolicyMap policies;
1029 policies.Set(key::kDefaultSearchProviderEnabled, 1036 policies.Set(key::kDefaultSearchProviderEnabled,
1030 POLICY_LEVEL_MANDATORY, 1037 POLICY_LEVEL_MANDATORY,
1031 POLICY_SCOPE_USER, 1038 POLICY_SCOPE_USER,
1039 POLICY_SOURCE_CLOUD,
1032 new base::FundamentalValue(true), 1040 new base::FundamentalValue(true),
1033 NULL); 1041 NULL);
1034 policies.Set(key::kDefaultSearchProviderKeyword, 1042 policies.Set(key::kDefaultSearchProviderKeyword,
1035 POLICY_LEVEL_MANDATORY, 1043 POLICY_LEVEL_MANDATORY,
1036 POLICY_SCOPE_USER, 1044 POLICY_SCOPE_USER,
1045 POLICY_SOURCE_CLOUD,
1037 new base::StringValue(kKeyword), 1046 new base::StringValue(kKeyword),
1038 NULL); 1047 NULL);
1039 policies.Set(key::kDefaultSearchProviderSearchURL, 1048 policies.Set(key::kDefaultSearchProviderSearchURL,
1040 POLICY_LEVEL_MANDATORY, 1049 POLICY_LEVEL_MANDATORY,
1041 POLICY_SCOPE_USER, 1050 POLICY_SCOPE_USER,
1051 POLICY_SOURCE_CLOUD,
1042 new base::StringValue(kSearchURL), 1052 new base::StringValue(kSearchURL),
1043 NULL); 1053 NULL);
1044 base::ListValue* alternate_urls = new base::ListValue(); 1054 base::ListValue* alternate_urls = new base::ListValue();
1045 alternate_urls->AppendString(kAlternateURL0); 1055 alternate_urls->AppendString(kAlternateURL0);
1046 alternate_urls->AppendString(kAlternateURL1); 1056 alternate_urls->AppendString(kAlternateURL1);
1047 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, 1057 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
1048 POLICY_SCOPE_USER, alternate_urls, NULL); 1058 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, alternate_urls, nullptr);
1049 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, 1059 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
1050 POLICY_LEVEL_MANDATORY, 1060 POLICY_LEVEL_MANDATORY,
1051 POLICY_SCOPE_USER, 1061 POLICY_SCOPE_USER,
1062 POLICY_SOURCE_CLOUD,
1052 new base::StringValue(kSearchTermsReplacementKey), 1063 new base::StringValue(kSearchTermsReplacementKey),
1053 NULL); 1064 NULL);
1054 policies.Set(key::kDefaultSearchProviderImageURL, 1065 policies.Set(key::kDefaultSearchProviderImageURL,
1055 POLICY_LEVEL_MANDATORY, 1066 POLICY_LEVEL_MANDATORY,
1056 POLICY_SCOPE_USER, 1067 POLICY_SCOPE_USER,
1068 POLICY_SOURCE_CLOUD,
1057 new base::StringValue(kImageURL), 1069 new base::StringValue(kImageURL),
1058 NULL); 1070 NULL);
1059 policies.Set(key::kDefaultSearchProviderImageURLPostParams, 1071 policies.Set(key::kDefaultSearchProviderImageURLPostParams,
1060 POLICY_LEVEL_MANDATORY, 1072 POLICY_LEVEL_MANDATORY,
1061 POLICY_SCOPE_USER, 1073 POLICY_SCOPE_USER,
1074 POLICY_SOURCE_CLOUD,
1062 new base::StringValue(kImageURLPostParams), 1075 new base::StringValue(kImageURLPostParams),
1063 NULL); 1076 NULL);
1064 policies.Set(key::kDefaultSearchProviderNewTabURL, 1077 policies.Set(key::kDefaultSearchProviderNewTabURL,
1065 POLICY_LEVEL_MANDATORY, 1078 POLICY_LEVEL_MANDATORY,
1066 POLICY_SCOPE_USER, 1079 POLICY_SCOPE_USER,
1080 POLICY_SOURCE_CLOUD,
1067 new base::StringValue(kNewTabURL), 1081 new base::StringValue(kNewTabURL),
1068 NULL); 1082 NULL);
1069 UpdateProviderPolicy(policies); 1083 UpdateProviderPolicy(policies);
1070 default_search = service->GetDefaultSearchProvider(); 1084 default_search = service->GetDefaultSearchProvider();
1071 ASSERT_TRUE(default_search); 1085 ASSERT_TRUE(default_search);
1072 EXPECT_EQ(kKeyword, default_search->keyword()); 1086 EXPECT_EQ(kKeyword, default_search->keyword());
1073 EXPECT_EQ(kSearchURL, default_search->url()); 1087 EXPECT_EQ(kSearchURL, default_search->url());
1074 EXPECT_EQ(2U, default_search->alternate_urls().size()); 1088 EXPECT_EQ(2U, default_search->alternate_urls().size());
1075 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); 1089 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]);
1076 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); 1090 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]);
(...skipping 12 matching lines...) Expand all
1089 content::WebContents* web_contents = 1103 content::WebContents* web_contents =
1090 browser()->tab_strip_model()->GetActiveWebContents(); 1104 browser()->tab_strip_model()->GetActiveWebContents();
1091 GURL expected("http://search.example/search?q=stuff+to+search+for"); 1105 GURL expected("http://search.example/search?q=stuff+to+search+for");
1092 EXPECT_EQ(expected, web_contents->GetURL()); 1106 EXPECT_EQ(expected, web_contents->GetURL());
1093 1107
1094 // Verify that searching from the omnibox can be disabled. 1108 // Verify that searching from the omnibox can be disabled.
1095 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1109 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1096 policies.Set(key::kDefaultSearchProviderEnabled, 1110 policies.Set(key::kDefaultSearchProviderEnabled,
1097 POLICY_LEVEL_MANDATORY, 1111 POLICY_LEVEL_MANDATORY,
1098 POLICY_SCOPE_USER, 1112 POLICY_SCOPE_USER,
1113 POLICY_SOURCE_CLOUD,
1099 new base::FundamentalValue(false), 1114 new base::FundamentalValue(false),
1100 NULL); 1115 NULL);
1101 EXPECT_TRUE(service->GetDefaultSearchProvider()); 1116 EXPECT_TRUE(service->GetDefaultSearchProvider());
1102 UpdateProviderPolicy(policies); 1117 UpdateProviderPolicy(policies);
1103 EXPECT_FALSE(service->GetDefaultSearchProvider()); 1118 EXPECT_FALSE(service->GetDefaultSearchProvider());
1104 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); 1119 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work");
1105 // This means that submitting won't trigger any action. 1120 // This means that submitting won't trigger any action.
1106 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); 1121 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid());
1107 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL()); 1122 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL());
1108 } 1123 }
1109 1124
1110 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { 1125 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) {
1111 // Add an individual proxy policy value. 1126 // Add an individual proxy policy value.
1112 PolicyMap policies; 1127 PolicyMap policies;
1113 policies.Set(key::kProxyServerMode, 1128 policies.Set(key::kProxyServerMode,
1114 POLICY_LEVEL_MANDATORY, 1129 POLICY_LEVEL_MANDATORY,
1115 POLICY_SCOPE_USER, 1130 POLICY_SCOPE_USER,
1131 POLICY_SOURCE_CLOUD,
1116 new base::FundamentalValue(3), 1132 new base::FundamentalValue(3),
1117 NULL); 1133 NULL);
1118 UpdateProviderPolicy(policies); 1134 UpdateProviderPolicy(policies);
1119 1135
1120 // It should be removed and replaced with a dictionary. 1136 // It should be removed and replaced with a dictionary.
1121 PolicyMap expected; 1137 PolicyMap expected;
1122 scoped_ptr<base::DictionaryValue> expected_value(new base::DictionaryValue); 1138 scoped_ptr<base::DictionaryValue> expected_value(new base::DictionaryValue);
1123 expected_value->SetInteger(key::kProxyServerMode, 3); 1139 expected_value->SetInteger(key::kProxyServerMode, 3);
1124 expected.Set(key::kProxySettings, 1140 expected.Set(key::kProxySettings,
1125 POLICY_LEVEL_MANDATORY, 1141 POLICY_LEVEL_MANDATORY,
1126 POLICY_SCOPE_USER, 1142 POLICY_SCOPE_USER,
1143 POLICY_SOURCE_CLOUD,
1127 expected_value.release(), 1144 expected_value.release(),
1128 NULL); 1145 NULL);
1129 1146
1130 // Check both the browser and the profile. 1147 // Check both the browser and the profile.
1131 const PolicyMap& actual_from_browser = 1148 const PolicyMap& actual_from_browser =
1132 g_browser_process->browser_policy_connector() 1149 g_browser_process->browser_policy_connector()
1133 ->GetPolicyService() 1150 ->GetPolicyService()
1134 ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); 1151 ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
1135 EXPECT_TRUE(expected.Equals(actual_from_browser)); 1152 EXPECT_TRUE(expected.Equals(actual_from_browser));
1136 const PolicyMap& actual_from_profile = 1153 const PolicyMap& actual_from_profile =
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 EXPECT_FALSE( 1226 EXPECT_FALSE(
1210 default_search->alternate_urls().size() == 2 && 1227 default_search->alternate_urls().size() == 2 &&
1211 default_search->alternate_urls()[0] == kAlternateURL0 && 1228 default_search->alternate_urls()[0] == kAlternateURL0 &&
1212 default_search->alternate_urls()[1] == kAlternateURL1); 1229 default_search->alternate_urls()[1] == kAlternateURL1);
1213 1230
1214 // Override the default search provider using policies. 1231 // Override the default search provider using policies.
1215 PolicyMap policies; 1232 PolicyMap policies;
1216 policies.Set(key::kDefaultSearchProviderEnabled, 1233 policies.Set(key::kDefaultSearchProviderEnabled,
1217 POLICY_LEVEL_MANDATORY, 1234 POLICY_LEVEL_MANDATORY,
1218 POLICY_SCOPE_USER, 1235 POLICY_SCOPE_USER,
1236 POLICY_SOURCE_CLOUD,
1219 new base::FundamentalValue(true), 1237 new base::FundamentalValue(true),
1220 NULL); 1238 NULL);
1221 policies.Set(key::kDefaultSearchProviderKeyword, 1239 policies.Set(key::kDefaultSearchProviderKeyword,
1222 POLICY_LEVEL_MANDATORY, 1240 POLICY_LEVEL_MANDATORY,
1223 POLICY_SCOPE_USER, 1241 POLICY_SCOPE_USER,
1242 POLICY_SOURCE_CLOUD,
1224 new base::StringValue(kKeyword), 1243 new base::StringValue(kKeyword),
1225 NULL); 1244 NULL);
1226 policies.Set(key::kDefaultSearchProviderSearchURL, 1245 policies.Set(key::kDefaultSearchProviderSearchURL,
1227 POLICY_LEVEL_MANDATORY, 1246 POLICY_LEVEL_MANDATORY,
1228 POLICY_SCOPE_USER, 1247 POLICY_SCOPE_USER,
1248 POLICY_SOURCE_CLOUD,
1229 new base::StringValue(kSearchURL), 1249 new base::StringValue(kSearchURL),
1230 NULL); 1250 NULL);
1231 policies.Set(key::kDefaultSearchProviderInstantURL, 1251 policies.Set(key::kDefaultSearchProviderInstantURL,
1232 POLICY_LEVEL_MANDATORY, 1252 POLICY_LEVEL_MANDATORY,
1233 POLICY_SCOPE_USER, 1253 POLICY_SCOPE_USER,
1254 POLICY_SOURCE_CLOUD,
1234 new base::StringValue(kInstantURL), 1255 new base::StringValue(kInstantURL),
1235 NULL); 1256 NULL);
1236 base::ListValue* alternate_urls = new base::ListValue(); 1257 base::ListValue* alternate_urls = new base::ListValue();
1237 alternate_urls->AppendString(kAlternateURL0); 1258 alternate_urls->AppendString(kAlternateURL0);
1238 alternate_urls->AppendString(kAlternateURL1); 1259 alternate_urls->AppendString(kAlternateURL1);
1239 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, 1260 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
1240 POLICY_SCOPE_USER, alternate_urls, NULL); 1261 POLICY_SCOPE_USER,
1262 POLICY_SOURCE_CLOUD, alternate_urls, nullptr);
1241 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, 1263 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
1242 POLICY_LEVEL_MANDATORY, 1264 POLICY_LEVEL_MANDATORY,
1243 POLICY_SCOPE_USER, 1265 POLICY_SCOPE_USER,
1266 POLICY_SOURCE_CLOUD,
1244 new base::StringValue(kSearchTermsReplacementKey), 1267 new base::StringValue(kSearchTermsReplacementKey),
1245 NULL); 1268 NULL);
1246 UpdateProviderPolicy(policies); 1269 UpdateProviderPolicy(policies);
1247 default_search = service->GetDefaultSearchProvider(); 1270 default_search = service->GetDefaultSearchProvider();
1248 ASSERT_TRUE(default_search); 1271 ASSERT_TRUE(default_search);
1249 EXPECT_EQ(kKeyword, default_search->keyword()); 1272 EXPECT_EQ(kKeyword, default_search->keyword());
1250 EXPECT_EQ(kSearchURL, default_search->url()); 1273 EXPECT_EQ(kSearchURL, default_search->url());
1251 EXPECT_EQ(kInstantURL, default_search->instant_url()); 1274 EXPECT_EQ(kInstantURL, default_search->instant_url());
1252 EXPECT_EQ(2U, default_search->alternate_urls().size()); 1275 EXPECT_EQ(2U, default_search->alternate_urls().size());
1253 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); 1276 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1338 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1316 // WebGL is enabled by default. 1339 // WebGL is enabled by default.
1317 content::WebContents* contents = 1340 content::WebContents* contents =
1318 browser()->tab_strip_model()->GetActiveWebContents(); 1341 browser()->tab_strip_model()->GetActiveWebContents();
1319 EXPECT_TRUE(IsWebGLEnabled(contents)); 1342 EXPECT_TRUE(IsWebGLEnabled(contents));
1320 // Disable with a policy. 1343 // Disable with a policy.
1321 PolicyMap policies; 1344 PolicyMap policies;
1322 policies.Set(key::kDisable3DAPIs, 1345 policies.Set(key::kDisable3DAPIs,
1323 POLICY_LEVEL_MANDATORY, 1346 POLICY_LEVEL_MANDATORY,
1324 POLICY_SCOPE_USER, 1347 POLICY_SCOPE_USER,
1348 POLICY_SOURCE_CLOUD,
1325 new base::FundamentalValue(true), 1349 new base::FundamentalValue(true),
1326 NULL); 1350 NULL);
1327 UpdateProviderPolicy(policies); 1351 UpdateProviderPolicy(policies);
1328 // Crash and reload the tab to get a new renderer. 1352 // Crash and reload the tab to get a new renderer.
1329 content::CrashTab(contents); 1353 content::CrashTab(contents);
1330 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); 1354 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD));
1331 EXPECT_FALSE(IsWebGLEnabled(contents)); 1355 EXPECT_FALSE(IsWebGLEnabled(contents));
1332 // Enable with a policy. 1356 // Enable with a policy.
1333 policies.Set(key::kDisable3DAPIs, 1357 policies.Set(key::kDisable3DAPIs,
1334 POLICY_LEVEL_MANDATORY, 1358 POLICY_LEVEL_MANDATORY,
1335 POLICY_SCOPE_USER, 1359 POLICY_SCOPE_USER,
1360 POLICY_SOURCE_CLOUD,
1336 new base::FundamentalValue(false), 1361 new base::FundamentalValue(false),
1337 NULL); 1362 NULL);
1338 UpdateProviderPolicy(policies); 1363 UpdateProviderPolicy(policies);
1339 content::CrashTab(contents); 1364 content::CrashTab(contents);
1340 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); 1365 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD));
1341 EXPECT_TRUE(IsWebGLEnabled(contents)); 1366 EXPECT_TRUE(IsWebGLEnabled(contents));
1342 } 1367 }
1343 1368
1344 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) { 1369 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) {
1345 // Verifies that SPDY can be disable by policy. 1370 // Verifies that SPDY can be disable by policy.
1346 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); 1371 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled());
1347 PolicyMap policies; 1372 PolicyMap policies;
1348 policies.Set(key::kDisableSpdy, 1373 policies.Set(key::kDisableSpdy,
1349 POLICY_LEVEL_MANDATORY, 1374 POLICY_LEVEL_MANDATORY,
1350 POLICY_SCOPE_USER, 1375 POLICY_SCOPE_USER,
1376 POLICY_SOURCE_CLOUD,
1351 new base::FundamentalValue(true), 1377 new base::FundamentalValue(true),
1352 NULL); 1378 NULL);
1353 UpdateProviderPolicy(policies); 1379 UpdateProviderPolicy(policies);
1354 content::RunAllPendingInMessageLoop(); 1380 content::RunAllPendingInMessageLoop();
1355 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); 1381 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled());
1356 // Verify that it can be force-enabled too. 1382 // Verify that it can be force-enabled too.
1357 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); 1383 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true);
1358 policies.Set(key::kDisableSpdy, 1384 policies.Set(key::kDisableSpdy,
1359 POLICY_LEVEL_MANDATORY, 1385 POLICY_LEVEL_MANDATORY,
1360 POLICY_SCOPE_USER, 1386 POLICY_SCOPE_USER,
1387 POLICY_SOURCE_CLOUD,
1361 new base::FundamentalValue(false), 1388 new base::FundamentalValue(false),
1362 NULL); 1389 NULL);
1363 UpdateProviderPolicy(policies); 1390 UpdateProviderPolicy(policies);
1364 content::RunAllPendingInMessageLoop(); 1391 content::RunAllPendingInMessageLoop();
1365 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); 1392 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled());
1366 } 1393 }
1367 1394
1368 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { 1395 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) {
1369 // Verifies that plugins can be forced to be disabled by policy. 1396 // Verifies that plugins can be forced to be disabled by policy.
1370 1397
1371 // Verify that the Flash plugin exists and that it can be enabled and disabled 1398 // Verify that the Flash plugin exists and that it can be enabled and disabled
1372 // by the user. 1399 // by the user.
1373 std::vector<content::WebPluginInfo> plugins; 1400 std::vector<content::WebPluginInfo> plugins;
1374 GetPluginList(&plugins); 1401 GetPluginList(&plugins);
1375 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); 1402 const content::WebPluginInfo* flash = GetFlashPlugin(plugins);
1376 if (!flash) 1403 if (!flash)
1377 return; 1404 return;
1378 PluginPrefs* plugin_prefs = 1405 PluginPrefs* plugin_prefs =
1379 PluginPrefs::GetForProfile(browser()->profile()).get(); 1406 PluginPrefs::GetForProfile(browser()->profile()).get();
1380 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1407 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1381 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 1408 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
1382 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1409 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1383 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); 1410 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true));
1384 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1411 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1385 1412
1386 // Now disable it with a policy. 1413 // Now disable it with a policy.
1387 base::ListValue disabled_plugins; 1414 base::ListValue disabled_plugins;
1388 disabled_plugins.Append(new base::StringValue("*Flash*")); 1415 disabled_plugins.Append(new base::StringValue("*Flash*"));
1389 PolicyMap policies; 1416 PolicyMap policies;
1390 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, 1417 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
1391 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); 1418 POLICY_SOURCE_CLOUD, disabled_plugins.DeepCopy(), nullptr);
1392 UpdateProviderPolicy(policies); 1419 UpdateProviderPolicy(policies);
1393 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1420 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1394 // The user shouldn't be able to enable it. 1421 // The user shouldn't be able to enable it.
1395 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); 1422 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true));
1396 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1423 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1397 } 1424 }
1398 1425
1399 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { 1426 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) {
1400 // Verifies that plugins with an exception in the blacklist can be enabled. 1427 // Verifies that plugins with an exception in the blacklist can be enabled.
1401 1428
1402 // Verify that the Flash plugin exists and that it can be enabled and disabled 1429 // Verify that the Flash plugin exists and that it can be enabled and disabled
1403 // by the user. 1430 // by the user.
1404 std::vector<content::WebPluginInfo> plugins; 1431 std::vector<content::WebPluginInfo> plugins;
1405 GetPluginList(&plugins); 1432 GetPluginList(&plugins);
1406 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); 1433 const content::WebPluginInfo* flash = GetFlashPlugin(plugins);
1407 if (!flash) 1434 if (!flash)
1408 return; 1435 return;
1409 PluginPrefs* plugin_prefs = 1436 PluginPrefs* plugin_prefs =
1410 PluginPrefs::GetForProfile(browser()->profile()).get(); 1437 PluginPrefs::GetForProfile(browser()->profile()).get();
1411 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1438 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1412 1439
1413 // Disable all plugins. 1440 // Disable all plugins.
1414 base::ListValue disabled_plugins; 1441 base::ListValue disabled_plugins;
1415 disabled_plugins.Append(new base::StringValue("*")); 1442 disabled_plugins.Append(new base::StringValue("*"));
1416 PolicyMap policies; 1443 PolicyMap policies;
1417 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, 1444 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
1418 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); 1445 POLICY_SOURCE_CLOUD, disabled_plugins.DeepCopy(), nullptr);
1419 UpdateProviderPolicy(policies); 1446 UpdateProviderPolicy(policies);
1420 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1447 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1421 // The user shouldn't be able to enable it. 1448 // The user shouldn't be able to enable it.
1422 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); 1449 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true));
1423 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1450 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1424 1451
1425 // Now open an exception for flash. 1452 // Now open an exception for flash.
1426 base::ListValue disabled_plugins_exceptions; 1453 base::ListValue disabled_plugins_exceptions;
1427 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*")); 1454 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*"));
1428 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, 1455 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY,
1429 POLICY_SCOPE_USER, disabled_plugins_exceptions.DeepCopy(), NULL); 1456 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
1457 disabled_plugins_exceptions.DeepCopy(), nullptr);
1430 UpdateProviderPolicy(policies); 1458 UpdateProviderPolicy(policies);
1431 // It should revert to the user's preference automatically. 1459 // It should revert to the user's preference automatically.
1432 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1460 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1433 // And the user should be able to disable and enable again. 1461 // And the user should be able to disable and enable again.
1434 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 1462 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
1435 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1463 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1436 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); 1464 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true));
1437 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1465 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1438 } 1466 }
1439 1467
1440 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { 1468 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) {
1441 // Verifies that a plugin can be force-installed with a policy. 1469 // Verifies that a plugin can be force-installed with a policy.
1442 std::vector<content::WebPluginInfo> plugins; 1470 std::vector<content::WebPluginInfo> plugins;
1443 GetPluginList(&plugins); 1471 GetPluginList(&plugins);
1444 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); 1472 const content::WebPluginInfo* flash = GetFlashPlugin(plugins);
1445 if (!flash) 1473 if (!flash)
1446 return; 1474 return;
1447 PluginPrefs* plugin_prefs = 1475 PluginPrefs* plugin_prefs =
1448 PluginPrefs::GetForProfile(browser()->profile()).get(); 1476 PluginPrefs::GetForProfile(browser()->profile()).get();
1449 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1477 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1450 1478
1451 // The user disables it and then a policy forces it to be enabled. 1479 // The user disables it and then a policy forces it to be enabled.
1452 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 1480 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
1453 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1481 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1454 base::ListValue plugin_list; 1482 base::ListValue plugin_list;
1455 plugin_list.Append(new base::StringValue(content::kFlashPluginName)); 1483 plugin_list.Append(new base::StringValue(content::kFlashPluginName));
1456 PolicyMap policies; 1484 PolicyMap policies;
1457 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, 1485 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY,
1458 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL); 1486 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, plugin_list.DeepCopy(),
1487 nullptr);
1459 UpdateProviderPolicy(policies); 1488 UpdateProviderPolicy(policies);
1460 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1489 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1461 // The user can't disable it anymore. 1490 // The user can't disable it anymore.
1462 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); 1491 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false));
1463 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1492 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1464 1493
1465 // When a plugin is both enabled and disabled, the whitelist takes precedence. 1494 // When a plugin is both enabled and disabled, the whitelist takes precedence.
1466 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, 1495 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY,
1467 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL); 1496 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, plugin_list.DeepCopy(),
1497 nullptr);
1468 UpdateProviderPolicy(policies); 1498 UpdateProviderPolicy(policies);
1469 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1499 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1470 } 1500 }
1471 1501
1472 IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { 1502 IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) {
1473 // Verifies that dangerous plugins can be always authorized to run with 1503 // Verifies that dangerous plugins can be always authorized to run with
1474 // a policy. 1504 // a policy.
1475 1505
1476 // Verify that the test page exists. It is only present in checkouts with 1506 // Verify that the test page exists. It is only present in checkouts with
1477 // src-internal. 1507 // src-internal.
(...skipping 24 matching lines...) Expand all
1502 EXPECT_TRUE( 1532 EXPECT_TRUE(
1503 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); 1533 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate());
1504 // And the plugin isn't running. 1534 // And the plugin isn't running.
1505 EXPECT_EQ(0, CountPlugins()); 1535 EXPECT_EQ(0, CountPlugins());
1506 1536
1507 // Now set a policy to always authorize this. 1537 // Now set a policy to always authorize this.
1508 PolicyMap policies; 1538 PolicyMap policies;
1509 policies.Set(key::kAlwaysAuthorizePlugins, 1539 policies.Set(key::kAlwaysAuthorizePlugins,
1510 POLICY_LEVEL_MANDATORY, 1540 POLICY_LEVEL_MANDATORY,
1511 POLICY_SCOPE_USER, 1541 POLICY_SCOPE_USER,
1542 POLICY_SOURCE_CLOUD,
1512 new base::FundamentalValue(true), 1543 new base::FundamentalValue(true),
1513 NULL); 1544 NULL);
1514 UpdateProviderPolicy(policies); 1545 UpdateProviderPolicy(policies);
1515 // Reloading the page shouldn't trigger the infobar this time. 1546 // Reloading the page shouldn't trigger the infobar this time.
1516 ui_test_utils::NavigateToURL(browser(), url); 1547 ui_test_utils::NavigateToURL(browser(), url);
1517 EXPECT_EQ(0u, infobar_service->infobar_count()); 1548 EXPECT_EQ(0u, infobar_service->infobar_count());
1518 // And the plugin started automatically. 1549 // And the plugin started automatically.
1519 EXPECT_EQ(1, CountPlugins()); 1550 EXPECT_EQ(1, CountPlugins());
1520 } 1551 }
1521 1552
1522 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { 1553 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) {
1523 // Verifies that access to the developer tools can be disabled. 1554 // Verifies that access to the developer tools can be disabled.
1524 1555
1525 // Open devtools. 1556 // Open devtools.
1526 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); 1557 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS));
1527 content::WebContents* contents = 1558 content::WebContents* contents =
1528 browser()->tab_strip_model()->GetActiveWebContents(); 1559 browser()->tab_strip_model()->GetActiveWebContents();
1529 DevToolsWindow* devtools_window = 1560 DevToolsWindow* devtools_window =
1530 DevToolsWindow::GetInstanceForInspectedWebContents(contents); 1561 DevToolsWindow::GetInstanceForInspectedWebContents(contents);
1531 EXPECT_TRUE(devtools_window); 1562 EXPECT_TRUE(devtools_window);
1532 1563
1533 // Disable devtools via policy. 1564 // Disable devtools via policy.
1534 PolicyMap policies; 1565 PolicyMap policies;
1535 policies.Set(key::kDeveloperToolsDisabled, 1566 policies.Set(key::kDeveloperToolsDisabled,
1536 POLICY_LEVEL_MANDATORY, 1567 POLICY_LEVEL_MANDATORY,
1537 POLICY_SCOPE_USER, 1568 POLICY_SCOPE_USER,
1569 POLICY_SOURCE_CLOUD,
1538 new base::FundamentalValue(true), 1570 new base::FundamentalValue(true),
1539 NULL); 1571 NULL);
1540 content::WindowedNotificationObserver close_observer( 1572 content::WindowedNotificationObserver close_observer(
1541 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 1573 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
1542 content::Source<content::WebContents>( 1574 content::Source<content::WebContents>(
1543 DevToolsWindowTesting::Get(devtools_window)->main_web_contents())); 1575 DevToolsWindowTesting::Get(devtools_window)->main_web_contents()));
1544 UpdateProviderPolicy(policies); 1576 UpdateProviderPolicy(policies);
1545 // wait for devtools close 1577 // wait for devtools close
1546 close_observer.Wait(); 1578 close_observer.Wait();
1547 // The existing devtools window should have closed. 1579 // The existing devtools window should have closed.
(...skipping 27 matching lines...) Expand all
1575 1607
1576 // The next NTP has no footer. 1608 // The next NTP has no footer.
1577 if (ContainsVisibleElement(contents, "footer")) 1609 if (ContainsVisibleElement(contents, "footer"))
1578 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link")); 1610 EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1579 1611
1580 // Turn off the web store icons. 1612 // Turn off the web store icons.
1581 PolicyMap policies; 1613 PolicyMap policies;
1582 policies.Set(key::kHideWebStoreIcon, 1614 policies.Set(key::kHideWebStoreIcon,
1583 POLICY_LEVEL_MANDATORY, 1615 POLICY_LEVEL_MANDATORY,
1584 POLICY_SCOPE_USER, 1616 POLICY_SCOPE_USER,
1617 POLICY_SOURCE_CLOUD,
1585 new base::FundamentalValue(true), 1618 new base::FundamentalValue(true),
1586 NULL); 1619 NULL);
1587 UpdateProviderPolicy(policies); 1620 UpdateProviderPolicy(policies);
1588 1621
1589 // The web store icons should now be hidden. 1622 // The web store icons should now be hidden.
1590 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 1623 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1591 EXPECT_FALSE(ContainsVisibleElement(contents, 1624 EXPECT_FALSE(ContainsVisibleElement(contents,
1592 "ahfgeienlihckogmohjhadlkjgocpleb")); 1625 "ahfgeienlihckogmohjhadlkjgocpleb"));
1593 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link")); 1626 EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link"));
1594 } 1627 }
(...skipping 15 matching lines...) Expand all
1610 DownloadAndVerifyFile(browser(), initial_dir.path(), file); 1643 DownloadAndVerifyFile(browser(), initial_dir.path(), file);
1611 base::DieFileDie(initial_dir.path().Append(file), false); 1644 base::DieFileDie(initial_dir.path().Append(file), false);
1612 1645
1613 // Override the download directory with the policy and verify a download. 1646 // Override the download directory with the policy and verify a download.
1614 base::ScopedTempDir forced_dir; 1647 base::ScopedTempDir forced_dir;
1615 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); 1648 ASSERT_TRUE(forced_dir.CreateUniqueTempDir());
1616 PolicyMap policies; 1649 PolicyMap policies;
1617 policies.Set(key::kDownloadDirectory, 1650 policies.Set(key::kDownloadDirectory,
1618 POLICY_LEVEL_MANDATORY, 1651 POLICY_LEVEL_MANDATORY,
1619 POLICY_SCOPE_USER, 1652 POLICY_SCOPE_USER,
1653 POLICY_SOURCE_CLOUD,
1620 new base::StringValue(forced_dir.path().value()), 1654 new base::StringValue(forced_dir.path().value()),
1621 NULL); 1655 NULL);
1622 UpdateProviderPolicy(policies); 1656 UpdateProviderPolicy(policies);
1623 DownloadAndVerifyFile(browser(), forced_dir.path(), file); 1657 DownloadAndVerifyFile(browser(), forced_dir.path(), file);
1624 // Verify that the first download location wasn't affected. 1658 // Verify that the first download location wasn't affected.
1625 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); 1659 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file)));
1626 } 1660 }
1627 1661
1628 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) { 1662 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) {
1629 // Verifies that blacklisted extensions can't be installed. 1663 // Verifies that blacklisted extensions can't be installed.
1630 ExtensionService* service = extension_service(); 1664 ExtensionService* service = extension_service();
1631 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1665 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1632 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1666 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1633 base::ListValue blacklist; 1667 base::ListValue blacklist;
1634 blacklist.Append(new base::StringValue(kGoodCrxId)); 1668 blacklist.Append(new base::StringValue(kGoodCrxId));
1635 PolicyMap policies; 1669 PolicyMap policies;
1636 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, 1670 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
1637 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 1671 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
1672 nullptr);
1638 UpdateProviderPolicy(policies); 1673 UpdateProviderPolicy(policies);
1639 1674
1640 // "good.crx" is blacklisted. 1675 // "good.crx" is blacklisted.
1641 EXPECT_FALSE(InstallExtension(kGoodCrxName)); 1676 EXPECT_FALSE(InstallExtension(kGoodCrxName));
1642 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1677 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1643 1678
1644 // "adblock.crx" is not. 1679 // "adblock.crx" is not.
1645 const extensions::Extension* adblock = InstallExtension(kAdBlockCrxName); 1680 const extensions::Extension* adblock = InstallExtension(kAdBlockCrxName);
1646 ASSERT_TRUE(adblock); 1681 ASSERT_TRUE(adblock);
1647 EXPECT_EQ(kAdBlockCrxId, adblock->id()); 1682 EXPECT_EQ(kAdBlockCrxId, adblock->id());
(...skipping 10 matching lines...) Expand all
1658 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { 1693 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) {
1659 // Verify that a wildcard blacklist takes effect. 1694 // Verify that a wildcard blacklist takes effect.
1660 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); 1695 EXPECT_TRUE(InstallExtension(kAdBlockCrxName));
1661 ExtensionService* service = extension_service(); 1696 ExtensionService* service = extension_service();
1662 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1697 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1663 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); 1698 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true));
1664 base::ListValue blacklist; 1699 base::ListValue blacklist;
1665 blacklist.Append(new base::StringValue("*")); 1700 blacklist.Append(new base::StringValue("*"));
1666 PolicyMap policies; 1701 PolicyMap policies;
1667 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, 1702 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
1668 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 1703 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
1704 nullptr);
1669 UpdateProviderPolicy(policies); 1705 UpdateProviderPolicy(policies);
1670 1706
1671 // AdBlock was automatically removed. 1707 // AdBlock was automatically removed.
1672 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1708 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1673 1709
1674 // And can't be installed again, nor can good.crx. 1710 // And can't be installed again, nor can good.crx.
1675 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); 1711 EXPECT_FALSE(InstallExtension(kAdBlockCrxName));
1676 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1712 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1677 EXPECT_FALSE(InstallExtension(kGoodCrxName)); 1713 EXPECT_FALSE(InstallExtension(kGoodCrxName));
1678 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1714 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
(...skipping 26 matching lines...) Expand all
1705 1741
1706 // Blacklist "*" but force-install the importer extension. The shared module 1742 // Blacklist "*" but force-install the importer extension. The shared module
1707 // should be automatically installed too. 1743 // should be automatically installed too.
1708 base::ListValue blacklist; 1744 base::ListValue blacklist;
1709 blacklist.AppendString("*"); 1745 blacklist.AppendString("*");
1710 base::ListValue forcelist; 1746 base::ListValue forcelist;
1711 forcelist.AppendString( 1747 forcelist.AppendString(
1712 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str())); 1748 base::StringPrintf("%s;%s", kImporterId, update_xml_url.spec().c_str()));
1713 PolicyMap policies; 1749 PolicyMap policies;
1714 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, 1750 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
1715 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 1751 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
1752 nullptr);
1716 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, 1753 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY,
1717 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); 1754 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, forcelist.DeepCopy(),
1755 nullptr);
1718 1756
1719 extensions::ExtensionRegistry* registry = 1757 extensions::ExtensionRegistry* registry =
1720 extensions::ExtensionRegistry::Get(browser()->profile()); 1758 extensions::ExtensionRegistry::Get(browser()->profile());
1721 extensions::TestExtensionRegistryObserver observe_importer( 1759 extensions::TestExtensionRegistryObserver observe_importer(
1722 registry, kImporterId); 1760 registry, kImporterId);
1723 extensions::TestExtensionRegistryObserver observe_shared_module( 1761 extensions::TestExtensionRegistryObserver observe_shared_module(
1724 registry, kSharedModuleId); 1762 registry, kSharedModuleId);
1725 UpdateProviderPolicy(policies); 1763 UpdateProviderPolicy(policies);
1726 observe_importer.WaitForExtensionLoaded(); 1764 observe_importer.WaitForExtensionLoaded();
1727 observe_shared_module.WaitForExtensionLoaded(); 1765 observe_shared_module.WaitForExtensionLoaded();
(...skipping 26 matching lines...) Expand all
1754 // Verifies that the whitelist can open exceptions to the blacklist. 1792 // Verifies that the whitelist can open exceptions to the blacklist.
1755 ExtensionService* service = extension_service(); 1793 ExtensionService* service = extension_service();
1756 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1794 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1757 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1795 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1758 base::ListValue blacklist; 1796 base::ListValue blacklist;
1759 blacklist.Append(new base::StringValue("*")); 1797 blacklist.Append(new base::StringValue("*"));
1760 base::ListValue whitelist; 1798 base::ListValue whitelist;
1761 whitelist.Append(new base::StringValue(kGoodCrxId)); 1799 whitelist.Append(new base::StringValue(kGoodCrxId));
1762 PolicyMap policies; 1800 PolicyMap policies;
1763 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, 1801 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
1764 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 1802 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
1803 nullptr);
1765 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, 1804 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY,
1766 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 1805 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(),
1806 nullptr);
1767 UpdateProviderPolicy(policies); 1807 UpdateProviderPolicy(policies);
1768 // "adblock.crx" is blacklisted. 1808 // "adblock.crx" is blacklisted.
1769 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); 1809 EXPECT_FALSE(InstallExtension(kAdBlockCrxName));
1770 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1810 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1771 // "good.crx" has a whitelist exception. 1811 // "good.crx" has a whitelist exception.
1772 const extensions::Extension* good = InstallExtension(kGoodCrxName); 1812 const extensions::Extension* good = InstallExtension(kGoodCrxName);
1773 ASSERT_TRUE(good); 1813 ASSERT_TRUE(good);
1774 EXPECT_EQ(kGoodCrxId, good->id()); 1814 EXPECT_EQ(kGoodCrxId, good->id());
1775 EXPECT_EQ(good, service->GetExtensionById(kGoodCrxId, true)); 1815 EXPECT_EQ(good, service->GetExtensionById(kGoodCrxId, true));
1776 // The user can also remove this extension. 1816 // The user can also remove this extension.
(...skipping 12 matching lines...) Expand all
1789 base::FilePath path = 1829 base::FilePath path =
1790 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); 1830 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName);
1791 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); 1831 GURL url(URLRequestMockHTTPJob::GetMockUrl(path));
1792 1832
1793 // Setting the forcelist extension should install "good_v1.crx". 1833 // Setting the forcelist extension should install "good_v1.crx".
1794 base::ListValue forcelist; 1834 base::ListValue forcelist;
1795 forcelist.Append(new base::StringValue( 1835 forcelist.Append(new base::StringValue(
1796 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str()))); 1836 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str())));
1797 PolicyMap policies; 1837 PolicyMap policies;
1798 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, 1838 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY,
1799 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); 1839 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, forcelist.DeepCopy(),
1840 nullptr);
1800 content::WindowedNotificationObserver observer( 1841 content::WindowedNotificationObserver observer(
1801 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, 1842 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
1802 content::NotificationService::AllSources()); 1843 content::NotificationService::AllSources());
1803 UpdateProviderPolicy(policies); 1844 UpdateProviderPolicy(policies);
1804 observer.Wait(); 1845 observer.Wait();
1805 // Note: Cannot check that the notification details match the expected 1846 // Note: Cannot check that the notification details match the expected
1806 // exception, since the details object has already been freed prior to 1847 // exception, since the details object has already been freed prior to
1807 // the completion of observer.Wait(). 1848 // the completion of observer.Wait().
1808 1849
1809 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); 1850 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 dict_value.SetString(std::string(kGoodCrxId) + "." + 1949 dict_value.SetString(std::string(kGoodCrxId) + "." +
1909 extensions::schema_constants::kInstallationMode, 1950 extensions::schema_constants::kInstallationMode,
1910 extensions::schema_constants::kNormalInstalled); 1951 extensions::schema_constants::kNormalInstalled);
1911 dict_value.SetString( 1952 dict_value.SetString(
1912 std::string(kGoodCrxId) + "." + extensions::schema_constants::kUpdateUrl, 1953 std::string(kGoodCrxId) + "." + extensions::schema_constants::kUpdateUrl,
1913 url.spec()); 1954 url.spec());
1914 PolicyMap policies; 1955 PolicyMap policies;
1915 policies.Set(key::kExtensionSettings, 1956 policies.Set(key::kExtensionSettings,
1916 POLICY_LEVEL_MANDATORY, 1957 POLICY_LEVEL_MANDATORY,
1917 POLICY_SCOPE_USER, 1958 POLICY_SCOPE_USER,
1959 POLICY_SOURCE_CLOUD,
1918 dict_value.DeepCopy(), 1960 dict_value.DeepCopy(),
1919 NULL); 1961 NULL);
1920 content::WindowedNotificationObserver observer( 1962 content::WindowedNotificationObserver observer(
1921 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, 1963 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
1922 content::NotificationService::AllSources()); 1964 content::NotificationService::AllSources());
1923 UpdateProviderPolicy(policies); 1965 UpdateProviderPolicy(policies);
1924 observer.Wait(); 1966 observer.Wait();
1925 1967
1926 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true)); 1968 EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true));
1927 1969
(...skipping 13 matching lines...) Expand all
1941 // Verifies that extensions are blocked if policy specifies an allowed types 1983 // Verifies that extensions are blocked if policy specifies an allowed types
1942 // list and the extension's type is not on that list. 1984 // list and the extension's type is not on that list.
1943 ExtensionService* service = extension_service(); 1985 ExtensionService* service = extension_service();
1944 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1986 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1945 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true)); 1987 ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true));
1946 1988
1947 base::ListValue allowed_types; 1989 base::ListValue allowed_types;
1948 allowed_types.AppendString("hosted_app"); 1990 allowed_types.AppendString("hosted_app");
1949 PolicyMap policies; 1991 PolicyMap policies;
1950 policies.Set(key::kExtensionAllowedTypes, POLICY_LEVEL_MANDATORY, 1992 policies.Set(key::kExtensionAllowedTypes, POLICY_LEVEL_MANDATORY,
1951 POLICY_SCOPE_USER, allowed_types.DeepCopy(), NULL); 1993 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, allowed_types.DeepCopy(),
1994 nullptr);
1952 UpdateProviderPolicy(policies); 1995 UpdateProviderPolicy(policies);
1953 1996
1954 // "good.crx" is blocked. 1997 // "good.crx" is blocked.
1955 EXPECT_FALSE(InstallExtension(kGoodCrxName)); 1998 EXPECT_FALSE(InstallExtension(kGoodCrxName));
1956 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1999 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1957 2000
1958 // "hosted_app.crx" is of a whitelisted type. 2001 // "hosted_app.crx" is of a whitelisted type.
1959 const extensions::Extension* hosted_app = InstallExtension(kHostedAppCrxName); 2002 const extensions::Extension* hosted_app = InstallExtension(kHostedAppCrxName);
1960 ASSERT_TRUE(hosted_app); 2003 ASSERT_TRUE(hosted_app);
1961 EXPECT_EQ(kHostedAppCrxId, hosted_app->id()); 2004 EXPECT_EQ(kHostedAppCrxId, hosted_app->id());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY); 2042 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY);
2000 PerformClick(0, 0); 2043 PerformClick(0, 0);
2001 download_observer.WaitForFinished(); 2044 download_observer.WaitForFinished();
2002 2045
2003 // Install the policy and trigger another download. 2046 // Install the policy and trigger another download.
2004 base::ListValue install_sources; 2047 base::ListValue install_sources;
2005 install_sources.AppendString(install_source_url.spec()); 2048 install_sources.AppendString(install_source_url.spec());
2006 install_sources.AppendString(referrer_url.spec()); 2049 install_sources.AppendString(referrer_url.spec());
2007 PolicyMap policies; 2050 PolicyMap policies;
2008 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY, 2051 policies.Set(key::kExtensionInstallSources, POLICY_LEVEL_MANDATORY,
2009 POLICY_SCOPE_USER, install_sources.DeepCopy(), NULL); 2052 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
2053 install_sources.DeepCopy(), nullptr);
2010 UpdateProviderPolicy(policies); 2054 UpdateProviderPolicy(policies);
2011 2055
2012 content::WindowedNotificationObserver observer( 2056 content::WindowedNotificationObserver observer(
2013 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, 2057 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
2014 content::NotificationService::AllSources()); 2058 content::NotificationService::AllSources());
2015 PerformClick(1, 0); 2059 PerformClick(1, 0);
2016 observer.Wait(); 2060 observer.Wait();
2017 // Note: Cannot check that the notification details match the expected 2061 // Note: Cannot check that the notification details match the expected
2018 // exception, since the details object has already been freed prior to 2062 // exception, since the details object has already been freed prior to
2019 // the completion of observer.Wait(). 2063 // the completion of observer.Wait().
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 browser()->tab_strip_model()->GetActiveWebContents(); 2273 browser()->tab_strip_model()->GetActiveWebContents();
2230 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); 2274 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL());
2231 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 2275 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
2232 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); 2276 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL());
2233 2277
2234 // Now override with policy. 2278 // Now override with policy.
2235 PolicyMap policies; 2279 PolicyMap policies;
2236 policies.Set(key::kHomepageLocation, 2280 policies.Set(key::kHomepageLocation,
2237 POLICY_LEVEL_MANDATORY, 2281 POLICY_LEVEL_MANDATORY,
2238 POLICY_SCOPE_USER, 2282 POLICY_SCOPE_USER,
2283 POLICY_SOURCE_CLOUD,
2239 new base::StringValue(chrome::kChromeUICreditsURL), 2284 new base::StringValue(chrome::kChromeUICreditsURL),
2240 NULL); 2285 NULL);
2241 UpdateProviderPolicy(policies); 2286 UpdateProviderPolicy(policies);
2242 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 2287 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
2243 content::WaitForLoadStop(contents); 2288 content::WaitForLoadStop(contents);
2244 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); 2289 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL());
2245 2290
2246 policies.Set(key::kHomepageIsNewTabPage, 2291 policies.Set(key::kHomepageIsNewTabPage,
2247 POLICY_LEVEL_MANDATORY, 2292 POLICY_LEVEL_MANDATORY,
2248 POLICY_SCOPE_USER, 2293 POLICY_SCOPE_USER,
2294 POLICY_SOURCE_CLOUD,
2249 new base::FundamentalValue(true), 2295 new base::FundamentalValue(true),
2250 NULL); 2296 NULL);
2251 UpdateProviderPolicy(policies); 2297 UpdateProviderPolicy(policies);
2252 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 2298 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
2253 content::WaitForLoadStop(contents); 2299 content::WaitForLoadStop(contents);
2254 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); 2300 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL());
2255 } 2301 }
2256 2302
2257 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { 2303 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) {
2258 // Verifies that incognito windows can't be opened when disabled by policy. 2304 // Verifies that incognito windows can't be opened when disabled by policy.
2259 2305
2260 const BrowserList* active_browser_list = 2306 const BrowserList* active_browser_list =
2261 BrowserList::GetInstance(chrome::GetActiveDesktop()); 2307 BrowserList::GetInstance(chrome::GetActiveDesktop());
2262 2308
2263 // Disable incognito via policy and verify that incognito windows can't be 2309 // Disable incognito via policy and verify that incognito windows can't be
2264 // opened. 2310 // opened.
2265 EXPECT_EQ(1u, active_browser_list->size()); 2311 EXPECT_EQ(1u, active_browser_list->size());
2266 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); 2312 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive());
2267 PolicyMap policies; 2313 PolicyMap policies;
2268 policies.Set(key::kIncognitoEnabled, 2314 policies.Set(key::kIncognitoEnabled,
2269 POLICY_LEVEL_MANDATORY, 2315 POLICY_LEVEL_MANDATORY,
2270 POLICY_SCOPE_USER, 2316 POLICY_SCOPE_USER,
2317 POLICY_SOURCE_CLOUD,
2271 new base::FundamentalValue(false), 2318 new base::FundamentalValue(false),
2272 NULL); 2319 NULL);
2273 UpdateProviderPolicy(policies); 2320 UpdateProviderPolicy(policies);
2274 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); 2321 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW));
2275 EXPECT_EQ(1u, active_browser_list->size()); 2322 EXPECT_EQ(1u, active_browser_list->size());
2276 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); 2323 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive());
2277 2324
2278 // Enable via policy and verify that incognito windows can be opened. 2325 // Enable via policy and verify that incognito windows can be opened.
2279 policies.Set(key::kIncognitoEnabled, 2326 policies.Set(key::kIncognitoEnabled,
2280 POLICY_LEVEL_MANDATORY, 2327 POLICY_LEVEL_MANDATORY,
2281 POLICY_SCOPE_USER, 2328 POLICY_SCOPE_USER,
2329 POLICY_SOURCE_CLOUD,
2282 new base::FundamentalValue(true), 2330 new base::FundamentalValue(true),
2283 NULL); 2331 NULL);
2284 UpdateProviderPolicy(policies); 2332 UpdateProviderPolicy(policies);
2285 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); 2333 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW));
2286 EXPECT_EQ(2u, active_browser_list->size()); 2334 EXPECT_EQ(2u, active_browser_list->size());
2287 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); 2335 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive());
2288 } 2336 }
2289 2337
2290 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { 2338 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) {
2291 // Verifies that Javascript can be disabled. 2339 // Verifies that Javascript can be disabled.
2292 content::WebContents* contents = 2340 content::WebContents* contents =
2293 browser()->tab_strip_model()->GetActiveWebContents(); 2341 browser()->tab_strip_model()->GetActiveWebContents();
2294 EXPECT_TRUE(IsJavascriptEnabled(contents)); 2342 EXPECT_TRUE(IsJavascriptEnabled(contents));
2295 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); 2343 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS));
2296 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); 2344 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE));
2297 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); 2345 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES));
2298 2346
2299 // Disable Javascript via policy. 2347 // Disable Javascript via policy.
2300 PolicyMap policies; 2348 PolicyMap policies;
2301 policies.Set(key::kJavascriptEnabled, 2349 policies.Set(key::kJavascriptEnabled,
2302 POLICY_LEVEL_MANDATORY, 2350 POLICY_LEVEL_MANDATORY,
2303 POLICY_SCOPE_USER, 2351 POLICY_SCOPE_USER,
2352 POLICY_SOURCE_CLOUD,
2304 new base::FundamentalValue(false), 2353 new base::FundamentalValue(false),
2305 NULL); 2354 NULL);
2306 UpdateProviderPolicy(policies); 2355 UpdateProviderPolicy(policies);
2307 // Reload the page. 2356 // Reload the page.
2308 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 2357 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
2309 EXPECT_FALSE(IsJavascriptEnabled(contents)); 2358 EXPECT_FALSE(IsJavascriptEnabled(contents));
2310 // Developer tools still work when javascript is disabled. 2359 // Developer tools still work when javascript is disabled.
2311 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); 2360 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS));
2312 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); 2361 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE));
2313 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); 2362 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES));
2314 // Javascript is always enabled for the internal pages. 2363 // Javascript is always enabled for the internal pages.
2315 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 2364 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
2316 EXPECT_TRUE(IsJavascriptEnabled(contents)); 2365 EXPECT_TRUE(IsJavascriptEnabled(contents));
2317 2366
2318 // The javascript content setting policy overrides the javascript policy. 2367 // The javascript content setting policy overrides the javascript policy.
2319 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 2368 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
2320 EXPECT_FALSE(IsJavascriptEnabled(contents)); 2369 EXPECT_FALSE(IsJavascriptEnabled(contents));
2321 policies.Set(key::kDefaultJavaScriptSetting, 2370 policies.Set(key::kDefaultJavaScriptSetting,
2322 POLICY_LEVEL_MANDATORY, 2371 POLICY_LEVEL_MANDATORY,
2323 POLICY_SCOPE_USER, 2372 POLICY_SCOPE_USER,
2373 POLICY_SOURCE_CLOUD,
2324 new base::FundamentalValue(CONTENT_SETTING_ALLOW), 2374 new base::FundamentalValue(CONTENT_SETTING_ALLOW),
2325 NULL); 2375 NULL);
2326 UpdateProviderPolicy(policies); 2376 UpdateProviderPolicy(policies);
2327 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 2377 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
2328 EXPECT_TRUE(IsJavascriptEnabled(contents)); 2378 EXPECT_TRUE(IsJavascriptEnabled(contents));
2329 } 2379 }
2330 2380
2331 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { 2381 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) {
2332 PrefService* prefs = browser()->profile()->GetPrefs(); 2382 PrefService* prefs = browser()->profile()->GetPrefs();
2333 2383
2334 // Enabled by default. 2384 // Enabled by default.
2335 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); 2385 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs));
2336 2386
2337 // Disable by old, deprecated policy. 2387 // Disable by old, deprecated policy.
2338 PolicyMap policies; 2388 PolicyMap policies;
2339 policies.Set(key::kDnsPrefetchingEnabled, 2389 policies.Set(key::kDnsPrefetchingEnabled,
2340 POLICY_LEVEL_MANDATORY, 2390 POLICY_LEVEL_MANDATORY,
2341 POLICY_SCOPE_USER, 2391 POLICY_SCOPE_USER,
2392 POLICY_SOURCE_CLOUD,
2342 new base::FundamentalValue(false), 2393 new base::FundamentalValue(false),
2343 NULL); 2394 NULL);
2344 UpdateProviderPolicy(policies); 2395 UpdateProviderPolicy(policies);
2345 2396
2346 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); 2397 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs));
2347 2398
2348 // Enabled by new policy, this should override old one. 2399 // Enabled by new policy, this should override old one.
2349 policies.Set( 2400 policies.Set(
2350 key::kNetworkPredictionOptions, 2401 key::kNetworkPredictionOptions,
2351 POLICY_LEVEL_MANDATORY, 2402 POLICY_LEVEL_MANDATORY,
2352 POLICY_SCOPE_USER, 2403 POLICY_SCOPE_USER,
2404 POLICY_SOURCE_CLOUD,
2353 new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS), 2405 new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS),
2354 NULL); 2406 NULL);
2355 UpdateProviderPolicy(policies); 2407 UpdateProviderPolicy(policies);
2356 2408
2357 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); 2409 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs));
2358 } 2410 }
2359 2411
2360 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { 2412 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) {
2361 // Verifies that browsing history is not saved. 2413 // Verifies that browsing history is not saved.
2362 PolicyMap policies; 2414 PolicyMap policies;
2363 policies.Set(key::kSavingBrowserHistoryDisabled, 2415 policies.Set(key::kSavingBrowserHistoryDisabled,
2364 POLICY_LEVEL_MANDATORY, 2416 POLICY_LEVEL_MANDATORY,
2365 POLICY_SCOPE_USER, 2417 POLICY_SCOPE_USER,
2418 POLICY_SOURCE_CLOUD,
2366 new base::FundamentalValue(true), 2419 new base::FundamentalValue(true),
2367 NULL); 2420 NULL);
2368 UpdateProviderPolicy(policies); 2421 UpdateProviderPolicy(policies);
2369 GURL url = ui_test_utils::GetTestUrl( 2422 GURL url = ui_test_utils::GetTestUrl(
2370 base::FilePath(base::FilePath::kCurrentDirectory), 2423 base::FilePath(base::FilePath::kCurrentDirectory),
2371 base::FilePath(FILE_PATH_LITERAL("empty.html"))); 2424 base::FilePath(FILE_PATH_LITERAL("empty.html")));
2372 ui_test_utils::NavigateToURL(browser(), url); 2425 ui_test_utils::NavigateToURL(browser(), url);
2373 // Verify that the navigation wasn't saved in the history. 2426 // Verify that the navigation wasn't saved in the history.
2374 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile()); 2427 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile());
2375 EXPECT_EQ(0u, enumerator1.urls().size()); 2428 EXPECT_EQ(0u, enumerator1.urls().size());
2376 2429
2377 // Now flip the policy and try again. 2430 // Now flip the policy and try again.
2378 policies.Set(key::kSavingBrowserHistoryDisabled, 2431 policies.Set(key::kSavingBrowserHistoryDisabled,
2379 POLICY_LEVEL_MANDATORY, 2432 POLICY_LEVEL_MANDATORY,
2380 POLICY_SCOPE_USER, 2433 POLICY_SCOPE_USER,
2434 POLICY_SOURCE_CLOUD,
2381 new base::FundamentalValue(false), 2435 new base::FundamentalValue(false),
2382 NULL); 2436 NULL);
2383 UpdateProviderPolicy(policies); 2437 UpdateProviderPolicy(policies);
2384 ui_test_utils::NavigateToURL(browser(), url); 2438 ui_test_utils::NavigateToURL(browser(), url);
2385 // Verify that the navigation was saved in the history. 2439 // Verify that the navigation was saved in the history.
2386 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); 2440 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile());
2387 ASSERT_EQ(1u, enumerator2.urls().size()); 2441 ASSERT_EQ(1u, enumerator2.urls().size());
2388 EXPECT_EQ(url, enumerator2.urls()[0]); 2442 EXPECT_EQ(url, enumerator2.urls()[0]);
2389 } 2443 }
2390 2444
(...skipping 15 matching lines...) Expand all
2406 ASSERT_TRUE(contents); 2460 ASSERT_TRUE(contents);
2407 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); 2461 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
2408 ASSERT_TRUE(infobar_service); 2462 ASSERT_TRUE(infobar_service);
2409 EXPECT_EQ(0u, infobar_service->infobar_count()); 2463 EXPECT_EQ(0u, infobar_service->infobar_count());
2410 2464
2411 // Force enable the translate feature. 2465 // Force enable the translate feature.
2412 PolicyMap policies; 2466 PolicyMap policies;
2413 policies.Set(key::kTranslateEnabled, 2467 policies.Set(key::kTranslateEnabled,
2414 POLICY_LEVEL_MANDATORY, 2468 POLICY_LEVEL_MANDATORY,
2415 POLICY_SCOPE_USER, 2469 POLICY_SCOPE_USER,
2470 POLICY_SOURCE_CLOUD,
2416 new base::FundamentalValue(true), 2471 new base::FundamentalValue(true),
2417 NULL); 2472 NULL);
2418 UpdateProviderPolicy(policies); 2473 UpdateProviderPolicy(policies);
2419 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test 2474 // Instead of waiting for NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, this test
2420 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the 2475 // waits for NOTIFICATION_TAB_LANGUAGE_DETERMINED because that's what the
2421 // TranslateManager observes. This allows checking that an infobar is NOT 2476 // TranslateManager observes. This allows checking that an infobar is NOT
2422 // shown below, without polling for infobars for some indeterminate amount 2477 // shown below, without polling for infobars for some indeterminate amount
2423 // of time. 2478 // of time.
2424 GURL url = ui_test_utils::GetTestUrl( 2479 GURL url = ui_test_utils::GetTestUrl(
2425 base::FilePath(), 2480 base::FilePath(),
(...skipping 25 matching lines...) Expand all
2451 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, 2506 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE,
2452 translate_infobar_delegate->translate_step()); 2507 translate_infobar_delegate->translate_step());
2453 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); 2508 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code());
2454 2509
2455 // Now force disable translate. 2510 // Now force disable translate.
2456 infobar_service->RemoveInfoBar(infobar); 2511 infobar_service->RemoveInfoBar(infobar);
2457 EXPECT_EQ(0u, infobar_service->infobar_count()); 2512 EXPECT_EQ(0u, infobar_service->infobar_count());
2458 policies.Set(key::kTranslateEnabled, 2513 policies.Set(key::kTranslateEnabled,
2459 POLICY_LEVEL_MANDATORY, 2514 POLICY_LEVEL_MANDATORY,
2460 POLICY_SCOPE_USER, 2515 POLICY_SCOPE_USER,
2516 POLICY_SOURCE_CLOUD,
2461 new base::FundamentalValue(false), 2517 new base::FundamentalValue(false),
2462 NULL); 2518 NULL);
2463 UpdateProviderPolicy(policies); 2519 UpdateProviderPolicy(policies);
2464 // Navigating to the same URL now doesn't trigger an infobar. 2520 // Navigating to the same URL now doesn't trigger an infobar.
2465 content::WindowedNotificationObserver language_observer2( 2521 content::WindowedNotificationObserver language_observer2(
2466 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 2522 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
2467 content::NotificationService::AllSources()); 2523 content::NotificationService::AllSources());
2468 ui_test_utils::NavigateToURL(browser(), url); 2524 ui_test_utils::NavigateToURL(browser(), url);
2469 language_observer2.Wait(); 2525 language_observer2.Wait();
2470 EXPECT_EQ(0u, infobar_service->infobar_count()); 2526 EXPECT_EQ(0u, infobar_service->infobar_count());
(...skipping 22 matching lines...) Expand all
2493 } 2549 }
2494 2550
2495 // Verify that "bbb.com" opens before applying the blacklist. 2551 // Verify that "bbb.com" opens before applying the blacklist.
2496 CheckCanOpenURL(browser(), kURLS[1]); 2552 CheckCanOpenURL(browser(), kURLS[1]);
2497 2553
2498 // Set a blacklist. 2554 // Set a blacklist.
2499 base::ListValue blacklist; 2555 base::ListValue blacklist;
2500 blacklist.Append(new base::StringValue("bbb.com")); 2556 blacklist.Append(new base::StringValue("bbb.com"));
2501 PolicyMap policies; 2557 PolicyMap policies;
2502 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2558 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2503 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2559 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
2560 nullptr);
2504 UpdateProviderPolicy(policies); 2561 UpdateProviderPolicy(policies);
2505 FlushBlacklistPolicy(); 2562 FlushBlacklistPolicy();
2506 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. 2563 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked.
2507 CheckCanOpenURL(browser(), kURLS[0]); 2564 CheckCanOpenURL(browser(), kURLS[0]);
2508 for (size_t i = 1; i < arraysize(kURLS); ++i) 2565 for (size_t i = 1; i < arraysize(kURLS); ++i)
2509 CheckURLIsBlocked(browser(), kURLS[i]); 2566 CheckURLIsBlocked(browser(), kURLS[i]);
2510 2567
2511 // Whitelist some sites of bbb.com. 2568 // Whitelist some sites of bbb.com.
2512 base::ListValue whitelist; 2569 base::ListValue whitelist;
2513 whitelist.Append(new base::StringValue("sub.bbb.com")); 2570 whitelist.Append(new base::StringValue("sub.bbb.com"));
2514 whitelist.Append(new base::StringValue("bbb.com/policy")); 2571 whitelist.Append(new base::StringValue("bbb.com/policy"));
2515 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, 2572 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY,
2516 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 2573 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(),
2574 nullptr);
2517 UpdateProviderPolicy(policies); 2575 UpdateProviderPolicy(policies);
2518 FlushBlacklistPolicy(); 2576 FlushBlacklistPolicy();
2519 CheckURLIsBlocked(browser(), kURLS[1]); 2577 CheckURLIsBlocked(browser(), kURLS[1]);
2520 CheckCanOpenURL(browser(), kURLS[2]); 2578 CheckCanOpenURL(browser(), kURLS[2]);
2521 CheckCanOpenURL(browser(), kURLS[3]); 2579 CheckCanOpenURL(browser(), kURLS[3]);
2522 CheckCanOpenURL(browser(), kURLS[4]); 2580 CheckCanOpenURL(browser(), kURLS[4]);
2523 2581
2524 { 2582 {
2525 base::RunLoop loop; 2583 base::RunLoop loop;
2526 BrowserThread::PostTaskAndReply( 2584 BrowserThread::PostTaskAndReply(
(...skipping 15 matching lines...) Expand all
2542 GURL subframe_url = URLRequestMockHTTPJob::GetMockUrl( 2600 GURL subframe_url = URLRequestMockHTTPJob::GetMockUrl(
2543 base::FilePath(FILE_PATH_LITERAL("policy/blank.html"))); 2601 base::FilePath(FILE_PATH_LITERAL("policy/blank.html")));
2544 2602
2545 // Set a blacklist containing the image and the iframe which are used by the 2603 // Set a blacklist containing the image and the iframe which are used by the
2546 // main document. 2604 // main document.
2547 base::ListValue blacklist; 2605 base::ListValue blacklist;
2548 blacklist.Append(new base::StringValue(image_url.spec().c_str())); 2606 blacklist.Append(new base::StringValue(image_url.spec().c_str()));
2549 blacklist.Append(new base::StringValue(subframe_url.spec().c_str())); 2607 blacklist.Append(new base::StringValue(subframe_url.spec().c_str()));
2550 PolicyMap policies; 2608 PolicyMap policies;
2551 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2609 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2552 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2610 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
2611 nullptr);
2553 UpdateProviderPolicy(policies); 2612 UpdateProviderPolicy(policies);
2554 FlushBlacklistPolicy(); 2613 FlushBlacklistPolicy();
2555 2614
2556 std::string blacklisted_image_load_result; 2615 std::string blacklisted_image_load_result;
2557 ui_test_utils::NavigateToURL(browser(), main_url); 2616 ui_test_utils::NavigateToURL(browser(), main_url);
2558 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 2617 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
2559 browser()->tab_strip_model()->GetActiveWebContents(), 2618 browser()->tab_strip_model()->GetActiveWebContents(),
2560 "window.domAutomationController.send(imageLoadResult)", 2619 "window.domAutomationController.send(imageLoadResult)",
2561 &blacklisted_image_load_result)); 2620 &blacklisted_image_load_result));
2562 EXPECT_EQ("success", blacklisted_image_load_result); 2621 EXPECT_EQ("success", blacklisted_image_load_result);
(...skipping 25 matching lines...) Expand all
2588 const std::string file_path2 = folder_path + "basic.html"; 2647 const std::string file_path2 = folder_path + "basic.html";
2589 2648
2590 CheckCanOpenURL(browser(), file_path1.c_str()); 2649 CheckCanOpenURL(browser(), file_path1.c_str());
2591 CheckCanOpenURL(browser(), file_path2.c_str()); 2650 CheckCanOpenURL(browser(), file_path2.c_str());
2592 2651
2593 // Set a blacklist for all the files. 2652 // Set a blacklist for all the files.
2594 base::ListValue blacklist; 2653 base::ListValue blacklist;
2595 blacklist.Append(new base::StringValue("file://*")); 2654 blacklist.Append(new base::StringValue("file://*"));
2596 PolicyMap policies; 2655 PolicyMap policies;
2597 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2656 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2598 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2657 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
2658 nullptr);
2599 UpdateProviderPolicy(policies); 2659 UpdateProviderPolicy(policies);
2600 FlushBlacklistPolicy(); 2660 FlushBlacklistPolicy();
2601 2661
2602 CheckURLIsBlocked(browser(), file_path1.c_str()); 2662 CheckURLIsBlocked(browser(), file_path1.c_str());
2603 CheckURLIsBlocked(browser(), file_path2.c_str()); 2663 CheckURLIsBlocked(browser(), file_path2.c_str());
2604 2664
2605 // Replace the URLblacklist with disabling the file scheme. 2665 // Replace the URLblacklist with disabling the file scheme.
2606 blacklist.Remove(base::StringValue("file://*"), NULL); 2666 blacklist.Remove(base::StringValue("file://*"), NULL);
2607 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2667 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2608 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2668 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
2669 nullptr);
2609 UpdateProviderPolicy(policies); 2670 UpdateProviderPolicy(policies);
2610 FlushBlacklistPolicy(); 2671 FlushBlacklistPolicy();
2611 2672
2612 PrefService* prefs = browser()->profile()->GetPrefs(); 2673 PrefService* prefs = browser()->profile()->GetPrefs();
2613 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); 2674 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist);
2614 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), 2675 EXPECT_EQ(list_url->Find(base::StringValue("file://*")),
2615 list_url->end()); 2676 list_url->end());
2616 2677
2617 base::ListValue disabledscheme; 2678 base::ListValue disabledscheme;
2618 disabledscheme.Append(new base::StringValue("file")); 2679 disabledscheme.Append(new base::StringValue("file"));
2619 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, 2680 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY,
2620 POLICY_SCOPE_USER, disabledscheme.DeepCopy(), NULL); 2681 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
2682 disabledscheme.DeepCopy(), nullptr);
2621 UpdateProviderPolicy(policies); 2683 UpdateProviderPolicy(policies);
2622 FlushBlacklistPolicy(); 2684 FlushBlacklistPolicy();
2623 2685
2624 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); 2686 list_url = prefs->GetList(policy_prefs::kUrlBlacklist);
2625 EXPECT_NE(list_url->Find(base::StringValue("file://*")), 2687 EXPECT_NE(list_url->Find(base::StringValue("file://*")),
2626 list_url->end()); 2688 list_url->end());
2627 2689
2628 // Whitelist one folder and blacklist an another just inside. 2690 // Whitelist one folder and blacklist an another just inside.
2629 base::ListValue whitelist; 2691 base::ListValue whitelist;
2630 whitelist.Append(new base::StringValue(base_path)); 2692 whitelist.Append(new base::StringValue(base_path));
2631 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, 2693 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY,
2632 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 2694 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(),
2695 nullptr);
2633 blacklist.Append(new base::StringValue(folder_path)); 2696 blacklist.Append(new base::StringValue(folder_path));
2634 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2697 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2635 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2698 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
2699 nullptr);
2636 UpdateProviderPolicy(policies); 2700 UpdateProviderPolicy(policies);
2637 FlushBlacklistPolicy(); 2701 FlushBlacklistPolicy();
2638 2702
2639 CheckCanOpenURL(browser(), file_path1.c_str()); 2703 CheckCanOpenURL(browser(), file_path1.c_str());
2640 CheckURLIsBlocked(browser(), file_path2.c_str()); 2704 CheckURLIsBlocked(browser(), file_path2.c_str());
2641 } 2705 }
2642 2706
2643 namespace { 2707 namespace {
2644 2708
2645 void GetSSLVersionFallbackMinOnIOThread( 2709 void GetSSLVersionFallbackMinOnIOThread(
(...skipping 28 matching lines...) Expand all
2674 prefs->GetString(prefs::kSSLVersionFallbackMin)); 2738 prefs->GetString(prefs::kSSLVersionFallbackMin));
2675 2739
2676 EXPECT_NE(default_value, new_value); 2740 EXPECT_NE(default_value, new_value);
2677 EXPECT_NE(net::SSL_PROTOCOL_VERSION_TLS1_2, 2741 EXPECT_NE(net::SSL_PROTOCOL_VERSION_TLS1_2,
2678 GetSSLVersionFallbackMin(browser()->profile())); 2742 GetSSLVersionFallbackMin(browser()->profile()));
2679 2743
2680 PolicyMap policies; 2744 PolicyMap policies;
2681 policies.Set(key::kSSLVersionFallbackMin, 2745 policies.Set(key::kSSLVersionFallbackMin,
2682 POLICY_LEVEL_MANDATORY, 2746 POLICY_LEVEL_MANDATORY,
2683 POLICY_SCOPE_USER, 2747 POLICY_SCOPE_USER,
2748 POLICY_SOURCE_CLOUD,
2684 new base::StringValue(new_value), 2749 new base::StringValue(new_value),
2685 NULL); 2750 NULL);
2686 UpdateProviderPolicy(policies); 2751 UpdateProviderPolicy(policies);
2687 2752
2688 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_2, 2753 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_2,
2689 GetSSLVersionFallbackMin(browser()->profile())); 2754 GetSSLVersionFallbackMin(browser()->profile()));
2690 } 2755 }
2691 2756
2692 #if !defined(OS_MACOSX) 2757 #if !defined(OS_MACOSX)
2693 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) { 2758 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedBrowser) {
2694 PolicyMap policies; 2759 PolicyMap policies;
2695 policies.Set(key::kFullscreenAllowed, 2760 policies.Set(key::kFullscreenAllowed,
2696 POLICY_LEVEL_MANDATORY, 2761 POLICY_LEVEL_MANDATORY,
2697 POLICY_SCOPE_USER, 2762 POLICY_SCOPE_USER,
2763 POLICY_SOURCE_CLOUD,
2698 new base::FundamentalValue(false), 2764 new base::FundamentalValue(false),
2699 NULL); 2765 NULL);
2700 UpdateProviderPolicy(policies); 2766 UpdateProviderPolicy(policies);
2701 2767
2702 BrowserWindow* browser_window = browser()->window(); 2768 BrowserWindow* browser_window = browser()->window();
2703 ASSERT_TRUE(browser_window); 2769 ASSERT_TRUE(browser_window);
2704 2770
2705 EXPECT_FALSE(browser_window->IsFullscreen()); 2771 EXPECT_FALSE(browser_window->IsFullscreen());
2706 chrome::ToggleFullscreenMode(browser()); 2772 chrome::ToggleFullscreenMode(browser());
2707 EXPECT_FALSE(browser_window->IsFullscreen()); 2773 EXPECT_FALSE(browser_window->IsFullscreen());
2708 } 2774 }
2709 2775
2710 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) { 2776 IN_PROC_BROWSER_TEST_F(PolicyTest, FullscreenAllowedApp) {
2711 PolicyMap policies; 2777 PolicyMap policies;
2712 policies.Set(key::kFullscreenAllowed, 2778 policies.Set(key::kFullscreenAllowed,
2713 POLICY_LEVEL_MANDATORY, 2779 POLICY_LEVEL_MANDATORY,
2714 POLICY_SCOPE_USER, 2780 POLICY_SCOPE_USER,
2781 POLICY_SOURCE_CLOUD,
2715 new base::FundamentalValue(false), 2782 new base::FundamentalValue(false),
2716 NULL); 2783 NULL);
2717 UpdateProviderPolicy(policies); 2784 UpdateProviderPolicy(policies);
2718 2785
2719 const extensions::Extension* extension = 2786 const extensions::Extension* extension =
2720 LoadUnpackedExtension(kUnpackedFullscreenAppName, true); 2787 LoadUnpackedExtension(kUnpackedFullscreenAppName, true);
2721 ASSERT_TRUE(extension); 2788 ASSERT_TRUE(extension);
2722 2789
2723 // Launch an app that tries to open a fullscreen window. 2790 // Launch an app that tries to open a fullscreen window.
2724 TestAddAppWindowObserver add_window_observer( 2791 TestAddAppWindowObserver add_window_observer(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 bool prior_state = audio_handler->IsOutputMuted(); 2843 bool prior_state = audio_handler->IsOutputMuted();
2777 // Make sure the audio is not muted and then toggle the policy and observe 2844 // Make sure the audio is not muted and then toggle the policy and observe
2778 // if the output mute changed event is fired. 2845 // if the output mute changed event is fired.
2779 audio_handler->SetOutputMute(false); 2846 audio_handler->SetOutputMute(false);
2780 EXPECT_FALSE(audio_handler->IsOutputMuted()); 2847 EXPECT_FALSE(audio_handler->IsOutputMuted());
2781 EXPECT_EQ(1, test_observer->output_mute_changed_count()); 2848 EXPECT_EQ(1, test_observer->output_mute_changed_count());
2782 PolicyMap policies; 2849 PolicyMap policies;
2783 policies.Set(key::kAudioOutputAllowed, 2850 policies.Set(key::kAudioOutputAllowed,
2784 POLICY_LEVEL_MANDATORY, 2851 POLICY_LEVEL_MANDATORY,
2785 POLICY_SCOPE_USER, 2852 POLICY_SCOPE_USER,
2853 POLICY_SOURCE_CLOUD,
2786 new base::FundamentalValue(false), 2854 new base::FundamentalValue(false),
2787 NULL); 2855 NULL);
2788 UpdateProviderPolicy(policies); 2856 UpdateProviderPolicy(policies);
2789 EXPECT_TRUE(audio_handler->IsOutputMuted()); 2857 EXPECT_TRUE(audio_handler->IsOutputMuted());
2790 // This should not change the state now and should not trigger output mute 2858 // This should not change the state now and should not trigger output mute
2791 // changed event. 2859 // changed event.
2792 audio_handler->SetOutputMute(false); 2860 audio_handler->SetOutputMute(false);
2793 EXPECT_TRUE(audio_handler->IsOutputMuted()); 2861 EXPECT_TRUE(audio_handler->IsOutputMuted());
2794 EXPECT_EQ(1, test_observer->output_mute_changed_count()); 2862 EXPECT_EQ(1, test_observer->output_mute_changed_count());
2795 2863
2796 // Toggle back and observe if the output mute changed event is fired. 2864 // Toggle back and observe if the output mute changed event is fired.
2797 policies.Set(key::kAudioOutputAllowed, 2865 policies.Set(key::kAudioOutputAllowed,
2798 POLICY_LEVEL_MANDATORY, 2866 POLICY_LEVEL_MANDATORY,
2799 POLICY_SCOPE_USER, 2867 POLICY_SCOPE_USER,
2868 POLICY_SOURCE_CLOUD,
2800 new base::FundamentalValue(true), 2869 new base::FundamentalValue(true),
2801 NULL); 2870 NULL);
2802 UpdateProviderPolicy(policies); 2871 UpdateProviderPolicy(policies);
2803 EXPECT_FALSE(audio_handler->IsOutputMuted()); 2872 EXPECT_FALSE(audio_handler->IsOutputMuted());
2804 EXPECT_EQ(1, test_observer->output_mute_changed_count()); 2873 EXPECT_EQ(1, test_observer->output_mute_changed_count());
2805 audio_handler->SetOutputMute(true); 2874 audio_handler->SetOutputMute(true);
2806 EXPECT_TRUE(audio_handler->IsOutputMuted()); 2875 EXPECT_TRUE(audio_handler->IsOutputMuted());
2807 EXPECT_EQ(2, test_observer->output_mute_changed_count()); 2876 EXPECT_EQ(2, test_observer->output_mute_changed_count());
2808 // Revert the prior state. 2877 // Revert the prior state.
2809 audio_handler->SetOutputMute(prior_state); 2878 audio_handler->SetOutputMute(prior_state);
(...skipping 19 matching lines...) Expand all
2829 content::NotificationService::AllSources()); 2898 content::NotificationService::AllSources());
2830 2899
2831 // Set the session length limit to 3 hours. Verify that the session is not 2900 // Set the session length limit to 3 hours. Verify that the session is not
2832 // terminated. 2901 // terminated.
2833 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) 2902 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _))
2834 .Times(0); 2903 .Times(0);
2835 PolicyMap policies; 2904 PolicyMap policies;
2836 policies.Set(key::kSessionLengthLimit, 2905 policies.Set(key::kSessionLengthLimit,
2837 POLICY_LEVEL_MANDATORY, 2906 POLICY_LEVEL_MANDATORY,
2838 POLICY_SCOPE_USER, 2907 POLICY_SCOPE_USER,
2908 POLICY_SOURCE_CLOUD,
2839 new base::FundamentalValue(kThreeHoursInMs), 2909 new base::FundamentalValue(kThreeHoursInMs),
2840 NULL); 2910 NULL);
2841 UpdateProviderPolicy(policies); 2911 UpdateProviderPolicy(policies);
2842 base::RunLoop().RunUntilIdle(); 2912 base::RunLoop().RunUntilIdle();
2843 Mock::VerifyAndClearExpectations(&observer); 2913 Mock::VerifyAndClearExpectations(&observer);
2844 2914
2845 // Decrease the session length limit to 1 hour. Verify that the session is 2915 // Decrease the session length limit to 1 hour. Verify that the session is
2846 // terminated immediately. 2916 // terminated immediately.
2847 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); 2917 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _));
2848 policies.Set(key::kSessionLengthLimit, 2918 policies.Set(key::kSessionLengthLimit,
2849 POLICY_LEVEL_MANDATORY, 2919 POLICY_LEVEL_MANDATORY,
2850 POLICY_SCOPE_USER, 2920 POLICY_SCOPE_USER,
2921 POLICY_SOURCE_CLOUD,
2851 new base::FundamentalValue(kOneHourInMs), 2922 new base::FundamentalValue(kOneHourInMs),
2852 NULL); 2923 NULL);
2853 UpdateProviderPolicy(policies); 2924 UpdateProviderPolicy(policies);
2854 base::RunLoop().RunUntilIdle(); 2925 base::RunLoop().RunUntilIdle();
2855 Mock::VerifyAndClearExpectations(&observer); 2926 Mock::VerifyAndClearExpectations(&observer);
2856 } 2927 }
2857 2928
2858 // Disabled, see http://crbug.com/315308. 2929 // Disabled, see http://crbug.com/315308.
2859 IN_PROC_BROWSER_TEST_F(PolicyTest, 2930 IN_PROC_BROWSER_TEST_F(PolicyTest,
2860 DISABLED_PRE_WaitForInitialUserActivityUsatisfied) { 2931 DISABLED_PRE_WaitForInitialUserActivityUsatisfied) {
(...skipping 11 matching lines...) Expand all
2872 content::MockNotificationObserver observer; 2943 content::MockNotificationObserver observer;
2873 content::NotificationRegistrar registrar; 2944 content::NotificationRegistrar registrar;
2874 registrar.Add(&observer, 2945 registrar.Add(&observer,
2875 chrome::NOTIFICATION_APP_TERMINATING, 2946 chrome::NOTIFICATION_APP_TERMINATING,
2876 content::NotificationService::AllSources()); 2947 content::NotificationService::AllSources());
2877 2948
2878 // Require initial user activity. 2949 // Require initial user activity.
2879 PolicyMap policies; 2950 PolicyMap policies;
2880 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, 2951 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY,
2881 POLICY_SCOPE_USER, 2952 POLICY_SCOPE_USER,
2953 POLICY_SOURCE_CLOUD,
2882 new base::FundamentalValue(true), 2954 new base::FundamentalValue(true),
2883 NULL); 2955 NULL);
2884 UpdateProviderPolicy(policies); 2956 UpdateProviderPolicy(policies);
2885 base::RunLoop().RunUntilIdle(); 2957 base::RunLoop().RunUntilIdle();
2886 2958
2887 // Set the session length limit to 1 hour. Verify that the session is not 2959 // Set the session length limit to 1 hour. Verify that the session is not
2888 // terminated. 2960 // terminated.
2889 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) 2961 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _))
2890 .Times(0); 2962 .Times(0);
2891 policies.Set(key::kSessionLengthLimit, 2963 policies.Set(key::kSessionLengthLimit,
2892 POLICY_LEVEL_MANDATORY, 2964 POLICY_LEVEL_MANDATORY,
2893 POLICY_SCOPE_USER, 2965 POLICY_SCOPE_USER,
2966 POLICY_SOURCE_CLOUD,
2894 new base::FundamentalValue(kOneHourInMs), 2967 new base::FundamentalValue(kOneHourInMs),
2895 NULL); 2968 NULL);
2896 UpdateProviderPolicy(policies); 2969 UpdateProviderPolicy(policies);
2897 base::RunLoop().RunUntilIdle(); 2970 base::RunLoop().RunUntilIdle();
2898 Mock::VerifyAndClearExpectations(&observer); 2971 Mock::VerifyAndClearExpectations(&observer);
2899 } 2972 }
2900 2973
2901 // Disabled, see http://crbug.com/315308. 2974 // Disabled, see http://crbug.com/315308.
2902 IN_PROC_BROWSER_TEST_F(PolicyTest, 2975 IN_PROC_BROWSER_TEST_F(PolicyTest,
2903 DISABLED_PRE_WaitForInitialUserActivitySatisfied) { 2976 DISABLED_PRE_WaitForInitialUserActivitySatisfied) {
(...skipping 16 matching lines...) Expand all
2920 chrome::NOTIFICATION_APP_TERMINATING, 2993 chrome::NOTIFICATION_APP_TERMINATING,
2921 content::NotificationService::AllSources()); 2994 content::NotificationService::AllSources());
2922 2995
2923 // Require initial user activity and set the session length limit to 3 hours. 2996 // Require initial user activity and set the session length limit to 3 hours.
2924 // Verify that the session is not terminated. 2997 // Verify that the session is not terminated.
2925 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)) 2998 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _))
2926 .Times(0); 2999 .Times(0);
2927 PolicyMap policies; 3000 PolicyMap policies;
2928 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY, 3001 policies.Set(key::kWaitForInitialUserActivity, POLICY_LEVEL_MANDATORY,
2929 POLICY_SCOPE_USER, 3002 POLICY_SCOPE_USER,
3003 POLICY_SOURCE_CLOUD,
2930 new base::FundamentalValue(true), 3004 new base::FundamentalValue(true),
2931 NULL); 3005 NULL);
2932 policies.Set(key::kSessionLengthLimit, 3006 policies.Set(key::kSessionLengthLimit,
2933 POLICY_LEVEL_MANDATORY, 3007 POLICY_LEVEL_MANDATORY,
2934 POLICY_SCOPE_USER, 3008 POLICY_SCOPE_USER,
3009 POLICY_SOURCE_CLOUD,
2935 new base::FundamentalValue(kThreeHoursInMs), 3010 new base::FundamentalValue(kThreeHoursInMs),
2936 NULL); 3011 NULL);
2937 UpdateProviderPolicy(policies); 3012 UpdateProviderPolicy(policies);
2938 base::RunLoop().RunUntilIdle(); 3013 base::RunLoop().RunUntilIdle();
2939 Mock::VerifyAndClearExpectations(&observer); 3014 Mock::VerifyAndClearExpectations(&observer);
2940 3015
2941 // Decrease the session length limit to 1 hour. Verify that the session is 3016 // Decrease the session length limit to 1 hour. Verify that the session is
2942 // terminated immediately. 3017 // terminated immediately.
2943 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _)); 3018 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_APP_TERMINATING, _, _));
2944 policies.Set(key::kSessionLengthLimit, 3019 policies.Set(key::kSessionLengthLimit,
2945 POLICY_LEVEL_MANDATORY, 3020 POLICY_LEVEL_MANDATORY,
2946 POLICY_SCOPE_USER, 3021 POLICY_SCOPE_USER,
3022 POLICY_SOURCE_CLOUD,
2947 new base::FundamentalValue(kOneHourInMs), 3023 new base::FundamentalValue(kOneHourInMs),
2948 NULL); 3024 NULL);
2949 UpdateProviderPolicy(policies); 3025 UpdateProviderPolicy(policies);
2950 base::RunLoop().RunUntilIdle(); 3026 base::RunLoop().RunUntilIdle();
2951 Mock::VerifyAndClearExpectations(&observer); 3027 Mock::VerifyAndClearExpectations(&observer);
2952 } 3028 }
2953 3029
2954 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) { 3030 IN_PROC_BROWSER_TEST_F(PolicyTest, LargeCursorEnabled) {
2955 // Verifies that the large cursor accessibility feature can be controlled 3031 // Verifies that the large cursor accessibility feature can be controlled
2956 // through policy. 3032 // through policy.
2957 chromeos::AccessibilityManager* accessibility_manager = 3033 chromeos::AccessibilityManager* accessibility_manager =
2958 chromeos::AccessibilityManager::Get(); 3034 chromeos::AccessibilityManager::Get();
2959 3035
2960 // Manually enable the large cursor. 3036 // Manually enable the large cursor.
2961 accessibility_manager->EnableLargeCursor(true); 3037 accessibility_manager->EnableLargeCursor(true);
2962 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); 3038 EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled());
2963 3039
2964 // Verify that policy overrides the manual setting. 3040 // Verify that policy overrides the manual setting.
2965 PolicyMap policies; 3041 PolicyMap policies;
2966 policies.Set(key::kLargeCursorEnabled, 3042 policies.Set(key::kLargeCursorEnabled,
2967 POLICY_LEVEL_MANDATORY, 3043 POLICY_LEVEL_MANDATORY,
2968 POLICY_SCOPE_USER, 3044 POLICY_SCOPE_USER,
3045 POLICY_SOURCE_CLOUD,
2969 new base::FundamentalValue(false), 3046 new base::FundamentalValue(false),
2970 NULL); 3047 NULL);
2971 UpdateProviderPolicy(policies); 3048 UpdateProviderPolicy(policies);
2972 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); 3049 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled());
2973 3050
2974 // Verify that the large cursor cannot be enabled manually anymore. 3051 // Verify that the large cursor cannot be enabled manually anymore.
2975 accessibility_manager->EnableLargeCursor(true); 3052 accessibility_manager->EnableLargeCursor(true);
2976 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); 3053 EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled());
2977 } 3054 }
2978 3055
2979 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) { 3056 IN_PROC_BROWSER_TEST_F(PolicyTest, SpokenFeedbackEnabled) {
2980 // Verifies that the spoken feedback accessibility feature can be controlled 3057 // Verifies that the spoken feedback accessibility feature can be controlled
2981 // through policy. 3058 // through policy.
2982 chromeos::AccessibilityManager* accessibility_manager = 3059 chromeos::AccessibilityManager* accessibility_manager =
2983 chromeos::AccessibilityManager::Get(); 3060 chromeos::AccessibilityManager::Get();
2984 3061
2985 // Manually enable spoken feedback. 3062 // Manually enable spoken feedback.
2986 accessibility_manager->EnableSpokenFeedback( 3063 accessibility_manager->EnableSpokenFeedback(
2987 true, ui::A11Y_NOTIFICATION_NONE); 3064 true, ui::A11Y_NOTIFICATION_NONE);
2988 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); 3065 EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled());
2989 3066
2990 // Verify that policy overrides the manual setting. 3067 // Verify that policy overrides the manual setting.
2991 PolicyMap policies; 3068 PolicyMap policies;
2992 policies.Set(key::kSpokenFeedbackEnabled, 3069 policies.Set(key::kSpokenFeedbackEnabled,
2993 POLICY_LEVEL_MANDATORY, 3070 POLICY_LEVEL_MANDATORY,
2994 POLICY_SCOPE_USER, 3071 POLICY_SCOPE_USER,
3072 POLICY_SOURCE_CLOUD,
2995 new base::FundamentalValue(false), 3073 new base::FundamentalValue(false),
2996 NULL); 3074 NULL);
2997 UpdateProviderPolicy(policies); 3075 UpdateProviderPolicy(policies);
2998 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); 3076 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled());
2999 3077
3000 // Verify that spoken feedback cannot be enabled manually anymore. 3078 // Verify that spoken feedback cannot be enabled manually anymore.
3001 accessibility_manager->EnableSpokenFeedback( 3079 accessibility_manager->EnableSpokenFeedback(
3002 true, ui::A11Y_NOTIFICATION_NONE); 3080 true, ui::A11Y_NOTIFICATION_NONE);
3003 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); 3081 EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled());
3004 } 3082 }
3005 3083
3006 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) { 3084 IN_PROC_BROWSER_TEST_F(PolicyTest, HighContrastEnabled) {
3007 // Verifies that the high contrast mode accessibility feature can be 3085 // Verifies that the high contrast mode accessibility feature can be
3008 // controlled through policy. 3086 // controlled through policy.
3009 chromeos::AccessibilityManager* accessibility_manager = 3087 chromeos::AccessibilityManager* accessibility_manager =
3010 chromeos::AccessibilityManager::Get(); 3088 chromeos::AccessibilityManager::Get();
3011 3089
3012 // Manually enable high contrast mode. 3090 // Manually enable high contrast mode.
3013 accessibility_manager->EnableHighContrast(true); 3091 accessibility_manager->EnableHighContrast(true);
3014 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); 3092 EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled());
3015 3093
3016 // Verify that policy overrides the manual setting. 3094 // Verify that policy overrides the manual setting.
3017 PolicyMap policies; 3095 PolicyMap policies;
3018 policies.Set(key::kHighContrastEnabled, 3096 policies.Set(key::kHighContrastEnabled,
3019 POLICY_LEVEL_MANDATORY, 3097 POLICY_LEVEL_MANDATORY,
3020 POLICY_SCOPE_USER, 3098 POLICY_SCOPE_USER,
3099 POLICY_SOURCE_CLOUD,
3021 new base::FundamentalValue(false), 3100 new base::FundamentalValue(false),
3022 NULL); 3101 NULL);
3023 UpdateProviderPolicy(policies); 3102 UpdateProviderPolicy(policies);
3024 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); 3103 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled());
3025 3104
3026 // Verify that high contrast mode cannot be enabled manually anymore. 3105 // Verify that high contrast mode cannot be enabled manually anymore.
3027 accessibility_manager->EnableHighContrast(true); 3106 accessibility_manager->EnableHighContrast(true);
3028 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); 3107 EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled());
3029 } 3108 }
3030 3109
3031 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) { 3110 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) {
3032 // Verifies that the screen magnifier can be disabled through policy. 3111 // Verifies that the screen magnifier can be disabled through policy.
3033 chromeos::MagnificationManager* magnification_manager = 3112 chromeos::MagnificationManager* magnification_manager =
3034 chromeos::MagnificationManager::Get(); 3113 chromeos::MagnificationManager::Get();
3035 3114
3036 // Manually enable the full-screen magnifier. 3115 // Manually enable the full-screen magnifier.
3037 magnification_manager->SetMagnifierType(ui::MAGNIFIER_FULL); 3116 magnification_manager->SetMagnifierType(ui::MAGNIFIER_FULL);
3038 magnification_manager->SetMagnifierEnabled(true); 3117 magnification_manager->SetMagnifierEnabled(true);
3039 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); 3118 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType());
3040 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); 3119 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
3041 3120
3042 // Verify that policy overrides the manual setting. 3121 // Verify that policy overrides the manual setting.
3043 PolicyMap policies; 3122 PolicyMap policies;
3044 policies.Set(key::kScreenMagnifierType, 3123 policies.Set(key::kScreenMagnifierType,
3045 POLICY_LEVEL_MANDATORY, 3124 POLICY_LEVEL_MANDATORY,
3046 POLICY_SCOPE_USER, 3125 POLICY_SCOPE_USER,
3126 POLICY_SOURCE_CLOUD,
3047 new base::FundamentalValue(0), 3127 new base::FundamentalValue(0),
3048 NULL); 3128 NULL);
3049 UpdateProviderPolicy(policies); 3129 UpdateProviderPolicy(policies);
3050 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); 3130 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled());
3051 3131
3052 // Verify that the screen magnifier cannot be enabled manually anymore. 3132 // Verify that the screen magnifier cannot be enabled manually anymore.
3053 magnification_manager->SetMagnifierEnabled(true); 3133 magnification_manager->SetMagnifierEnabled(true);
3054 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); 3134 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled());
3055 } 3135 }
3056 3136
3057 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) { 3137 IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) {
3058 // Verifies that the full-screen magnifier can be enabled through policy. 3138 // Verifies that the full-screen magnifier can be enabled through policy.
3059 chromeos::MagnificationManager* magnification_manager = 3139 chromeos::MagnificationManager* magnification_manager =
3060 chromeos::MagnificationManager::Get(); 3140 chromeos::MagnificationManager::Get();
3061 3141
3062 // Verify that the screen magnifier is initially disabled. 3142 // Verify that the screen magnifier is initially disabled.
3063 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); 3143 EXPECT_FALSE(magnification_manager->IsMagnifierEnabled());
3064 3144
3065 // Verify that policy can enable the full-screen magnifier. 3145 // Verify that policy can enable the full-screen magnifier.
3066 PolicyMap policies; 3146 PolicyMap policies;
3067 policies.Set(key::kScreenMagnifierType, 3147 policies.Set(key::kScreenMagnifierType,
3068 POLICY_LEVEL_MANDATORY, 3148 POLICY_LEVEL_MANDATORY,
3069 POLICY_SCOPE_USER, 3149 POLICY_SCOPE_USER,
3150 POLICY_SOURCE_CLOUD,
3070 new base::FundamentalValue(ui::MAGNIFIER_FULL), 3151 new base::FundamentalValue(ui::MAGNIFIER_FULL),
3071 NULL); 3152 NULL);
3072 UpdateProviderPolicy(policies); 3153 UpdateProviderPolicy(policies);
3073 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); 3154 EXPECT_EQ(ui::MAGNIFIER_FULL, magnification_manager->GetMagnifierType());
3074 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); 3155 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
3075 3156
3076 // Verify that the screen magnifier cannot be disabled manually anymore. 3157 // Verify that the screen magnifier cannot be disabled manually anymore.
3077 magnification_manager->SetMagnifierEnabled(false); 3158 magnification_manager->SetMagnifierEnabled(false);
3078 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); 3159 EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
3079 } 3160 }
3080 3161
3081 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) { 3162 IN_PROC_BROWSER_TEST_F(PolicyTest, AccessibilityVirtualKeyboardEnabled) {
3082 // Verifies that the on-screen keyboard accessibility feature can be 3163 // Verifies that the on-screen keyboard accessibility feature can be
3083 // controlled through policy. 3164 // controlled through policy.
3084 chromeos::AccessibilityManager* accessibility_manager = 3165 chromeos::AccessibilityManager* accessibility_manager =
3085 chromeos::AccessibilityManager::Get(); 3166 chromeos::AccessibilityManager::Get();
3086 3167
3087 // Manually enable the on-screen keyboard. 3168 // Manually enable the on-screen keyboard.
3088 accessibility_manager->EnableVirtualKeyboard(true); 3169 accessibility_manager->EnableVirtualKeyboard(true);
3089 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled()); 3170 EXPECT_TRUE(accessibility_manager->IsVirtualKeyboardEnabled());
3090 3171
3091 // Verify that policy overrides the manual setting. 3172 // Verify that policy overrides the manual setting.
3092 PolicyMap policies; 3173 PolicyMap policies;
3093 policies.Set(key::kVirtualKeyboardEnabled, 3174 policies.Set(key::kVirtualKeyboardEnabled,
3094 POLICY_LEVEL_MANDATORY, 3175 POLICY_LEVEL_MANDATORY,
3095 POLICY_SCOPE_USER, 3176 POLICY_SCOPE_USER,
3177 POLICY_SOURCE_CLOUD,
3096 new base::FundamentalValue(false), 3178 new base::FundamentalValue(false),
3097 NULL); 3179 NULL);
3098 UpdateProviderPolicy(policies); 3180 UpdateProviderPolicy(policies);
3099 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); 3181 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled());
3100 3182
3101 // Verify that the on-screen keyboard cannot be enabled manually anymore. 3183 // Verify that the on-screen keyboard cannot be enabled manually anymore.
3102 accessibility_manager->EnableVirtualKeyboard(true); 3184 accessibility_manager->EnableVirtualKeyboard(true);
3103 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled()); 3185 EXPECT_FALSE(accessibility_manager->IsVirtualKeyboardEnabled());
3104 } 3186 }
3105 3187
3106 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) { 3188 IN_PROC_BROWSER_TEST_F(PolicyTest, VirtualKeyboardEnabled) {
3107 // Verify keyboard disabled by default. 3189 // Verify keyboard disabled by default.
3108 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 3190 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
3109 // Verify keyboard can be toggled by default. 3191 // Verify keyboard can be toggled by default.
3110 keyboard::SetTouchKeyboardEnabled(true); 3192 keyboard::SetTouchKeyboardEnabled(true);
3111 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 3193 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
3112 keyboard::SetTouchKeyboardEnabled(false); 3194 keyboard::SetTouchKeyboardEnabled(false);
3113 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 3195 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
3114 3196
3115 // Verify enabling the policy takes effect immediately and that that user 3197 // Verify enabling the policy takes effect immediately and that that user
3116 // cannot disable the keyboard.. 3198 // cannot disable the keyboard..
3117 PolicyMap policies; 3199 PolicyMap policies;
3118 policies.Set(key::kTouchVirtualKeyboardEnabled, 3200 policies.Set(key::kTouchVirtualKeyboardEnabled,
3119 POLICY_LEVEL_MANDATORY, 3201 POLICY_LEVEL_MANDATORY,
3120 POLICY_SCOPE_USER, 3202 POLICY_SCOPE_USER,
3203 POLICY_SOURCE_CLOUD,
3121 new base::FundamentalValue(true), 3204 new base::FundamentalValue(true),
3122 NULL); 3205 NULL);
3123 UpdateProviderPolicy(policies); 3206 UpdateProviderPolicy(policies);
3124 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 3207 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
3125 keyboard::SetTouchKeyboardEnabled(false); 3208 keyboard::SetTouchKeyboardEnabled(false);
3126 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); 3209 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
3127 3210
3128 // Verify that disabling the policy takes effect immediately and that the user 3211 // Verify that disabling the policy takes effect immediately and that the user
3129 // cannot enable the keyboard. 3212 // cannot enable the keyboard.
3130 policies.Set(key::kTouchVirtualKeyboardEnabled, 3213 policies.Set(key::kTouchVirtualKeyboardEnabled,
3131 POLICY_LEVEL_MANDATORY, 3214 POLICY_LEVEL_MANDATORY,
3132 POLICY_SCOPE_USER, 3215 POLICY_SCOPE_USER,
3216 POLICY_SOURCE_CLOUD,
3133 new base::FundamentalValue(false), 3217 new base::FundamentalValue(false),
3134 NULL); 3218 NULL);
3135 UpdateProviderPolicy(policies); 3219 UpdateProviderPolicy(policies);
3136 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 3220 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
3137 keyboard::SetTouchKeyboardEnabled(true); 3221 keyboard::SetTouchKeyboardEnabled(true);
3138 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 3222 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
3139 } 3223 }
3140 3224
3141 #endif 3225 #endif
3142 3226
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 } 3281 }
3198 3282
3199 void HomepageIsNotNTP() { 3283 void HomepageIsNotNTP() {
3200 // Verifies that policy can set the startup pages to the homepage, when 3284 // Verifies that policy can set the startup pages to the homepage, when
3201 // the homepage is not the NTP. 3285 // the homepage is not the NTP.
3202 PolicyMap policies; 3286 PolicyMap policies;
3203 policies.Set( 3287 policies.Set(
3204 key::kRestoreOnStartup, 3288 key::kRestoreOnStartup,
3205 POLICY_LEVEL_MANDATORY, 3289 POLICY_LEVEL_MANDATORY,
3206 POLICY_SCOPE_USER, 3290 POLICY_SCOPE_USER,
3291 POLICY_SOURCE_CLOUD,
3207 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), 3292 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage),
3208 NULL); 3293 NULL);
3209 policies.Set(key::kHomepageIsNewTabPage, 3294 policies.Set(key::kHomepageIsNewTabPage,
3210 POLICY_LEVEL_MANDATORY, 3295 POLICY_LEVEL_MANDATORY,
3211 POLICY_SCOPE_USER, 3296 POLICY_SCOPE_USER,
3297 POLICY_SOURCE_CLOUD,
3212 new base::FundamentalValue(false), 3298 new base::FundamentalValue(false),
3213 NULL); 3299 NULL);
3214 policies.Set(key::kHomepageLocation, 3300 policies.Set(key::kHomepageLocation,
3215 POLICY_LEVEL_MANDATORY, 3301 POLICY_LEVEL_MANDATORY,
3216 POLICY_SCOPE_USER, 3302 POLICY_SCOPE_USER,
3303 POLICY_SOURCE_CLOUD,
3217 new base::StringValue(kRestoredURLs[1]), 3304 new base::StringValue(kRestoredURLs[1]),
3218 NULL); 3305 NULL);
3219 provider_.UpdateChromePolicy(policies); 3306 provider_.UpdateChromePolicy(policies);
3220 3307
3221 expected_urls_.push_back(GURL(kRestoredURLs[1])); 3308 expected_urls_.push_back(GURL(kRestoredURLs[1]));
3222 } 3309 }
3223 3310
3224 void HomepageIsNTP() { 3311 void HomepageIsNTP() {
3225 // Verifies that policy can set the startup pages to the homepage, when 3312 // Verifies that policy can set the startup pages to the homepage, when
3226 // the homepage is the NTP. 3313 // the homepage is the NTP.
3227 PolicyMap policies; 3314 PolicyMap policies;
3228 policies.Set( 3315 policies.Set(
3229 key::kRestoreOnStartup, 3316 key::kRestoreOnStartup,
3230 POLICY_LEVEL_MANDATORY, 3317 POLICY_LEVEL_MANDATORY,
3231 POLICY_SCOPE_USER, 3318 POLICY_SCOPE_USER,
3319 POLICY_SOURCE_CLOUD,
3232 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), 3320 new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage),
3233 NULL); 3321 NULL);
3234 policies.Set(key::kHomepageIsNewTabPage, 3322 policies.Set(key::kHomepageIsNewTabPage,
3235 POLICY_LEVEL_MANDATORY, 3323 POLICY_LEVEL_MANDATORY,
3236 POLICY_SCOPE_USER, 3324 POLICY_SCOPE_USER,
3325 POLICY_SOURCE_CLOUD,
3237 new base::FundamentalValue(true), 3326 new base::FundamentalValue(true),
3238 NULL); 3327 NULL);
3239 provider_.UpdateChromePolicy(policies); 3328 provider_.UpdateChromePolicy(policies);
3240 3329
3241 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); 3330 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL));
3242 } 3331 }
3243 3332
3244 void ListOfURLs() { 3333 void ListOfURLs() {
3245 // Verifies that policy can set the startup pages to a list of URLs. 3334 // Verifies that policy can set the startup pages to a list of URLs.
3246 base::ListValue urls; 3335 base::ListValue urls;
3247 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { 3336 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) {
3248 urls.Append(new base::StringValue(kRestoredURLs[i])); 3337 urls.Append(new base::StringValue(kRestoredURLs[i]));
3249 expected_urls_.push_back(GURL(kRestoredURLs[i])); 3338 expected_urls_.push_back(GURL(kRestoredURLs[i]));
3250 } 3339 }
3251 PolicyMap policies; 3340 PolicyMap policies;
3252 policies.Set(key::kRestoreOnStartup, 3341 policies.Set(key::kRestoreOnStartup,
3253 POLICY_LEVEL_MANDATORY, 3342 POLICY_LEVEL_MANDATORY,
3254 POLICY_SCOPE_USER, 3343 POLICY_SCOPE_USER,
3344 POLICY_SOURCE_CLOUD,
3255 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), 3345 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs),
3256 NULL); 3346 NULL);
3257 policies.Set( 3347 policies.Set(
3258 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 3348 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
3259 urls.DeepCopy(), NULL); 3349 POLICY_SOURCE_CLOUD, urls.DeepCopy(), nullptr);
3260 provider_.UpdateChromePolicy(policies); 3350 provider_.UpdateChromePolicy(policies);
3261 } 3351 }
3262 3352
3263 void NTP() { 3353 void NTP() {
3264 // Verifies that policy can set the startup page to the NTP. 3354 // Verifies that policy can set the startup page to the NTP.
3265 PolicyMap policies; 3355 PolicyMap policies;
3266 policies.Set( 3356 policies.Set(
3267 key::kRestoreOnStartup, 3357 key::kRestoreOnStartup,
3268 POLICY_LEVEL_MANDATORY, 3358 POLICY_LEVEL_MANDATORY,
3269 POLICY_SCOPE_USER, 3359 POLICY_SCOPE_USER,
3360 POLICY_SOURCE_CLOUD,
3270 new base::FundamentalValue(SessionStartupPref::kPrefValueNewTab), 3361 new base::FundamentalValue(SessionStartupPref::kPrefValueNewTab),
3271 NULL); 3362 NULL);
3272 provider_.UpdateChromePolicy(policies); 3363 provider_.UpdateChromePolicy(policies);
3273 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); 3364 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL));
3274 } 3365 }
3275 3366
3276 void Last() { 3367 void Last() {
3277 // Verifies that policy can set the startup pages to the last session. 3368 // Verifies that policy can set the startup pages to the last session.
3278 PolicyMap policies; 3369 PolicyMap policies;
3279 policies.Set(key::kRestoreOnStartup, 3370 policies.Set(key::kRestoreOnStartup,
3280 POLICY_LEVEL_MANDATORY, 3371 POLICY_LEVEL_MANDATORY,
3281 POLICY_SCOPE_USER, 3372 POLICY_SCOPE_USER,
3373 POLICY_SOURCE_CLOUD,
3282 new base::FundamentalValue(SessionStartupPref::kPrefValueLast), 3374 new base::FundamentalValue(SessionStartupPref::kPrefValueLast),
3283 NULL); 3375 NULL);
3284 provider_.UpdateChromePolicy(policies); 3376 provider_.UpdateChromePolicy(policies);
3285 // This should restore the tabs opened at PRE_RunTest below. 3377 // This should restore the tabs opened at PRE_RunTest below.
3286 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) 3378 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i)
3287 expected_urls_.push_back(GURL(kRestoredURLs[i])); 3379 expected_urls_.push_back(GURL(kRestoredURLs[i]));
3288 } 3380 }
3289 3381
3290 std::vector<GURL> expected_urls_; 3382 std::vector<GURL> expected_urls_;
3291 }; 3383 };
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 public: 3428 public:
3337 PolicyStatisticsCollectorTest() {} 3429 PolicyStatisticsCollectorTest() {}
3338 ~PolicyStatisticsCollectorTest() override {} 3430 ~PolicyStatisticsCollectorTest() override {}
3339 3431
3340 void SetUpInProcessBrowserTestFixture() override { 3432 void SetUpInProcessBrowserTestFixture() override {
3341 PolicyTest::SetUpInProcessBrowserTestFixture(); 3433 PolicyTest::SetUpInProcessBrowserTestFixture();
3342 PolicyMap policies; 3434 PolicyMap policies;
3343 policies.Set(key::kShowHomeButton, 3435 policies.Set(key::kShowHomeButton,
3344 POLICY_LEVEL_MANDATORY, 3436 POLICY_LEVEL_MANDATORY,
3345 POLICY_SCOPE_USER, 3437 POLICY_SCOPE_USER,
3438 POLICY_SOURCE_CLOUD,
3346 new base::FundamentalValue(true), 3439 new base::FundamentalValue(true),
3347 NULL); 3440 NULL);
3348 policies.Set(key::kBookmarkBarEnabled, 3441 policies.Set(key::kBookmarkBarEnabled,
3349 POLICY_LEVEL_MANDATORY, 3442 POLICY_LEVEL_MANDATORY,
3350 POLICY_SCOPE_USER, 3443 POLICY_SCOPE_USER,
3444 POLICY_SOURCE_CLOUD,
3351 new base::FundamentalValue(false), 3445 new base::FundamentalValue(false),
3352 NULL); 3446 NULL);
3353 policies.Set(key::kHomepageLocation, 3447 policies.Set(key::kHomepageLocation,
3354 POLICY_LEVEL_MANDATORY, 3448 POLICY_LEVEL_MANDATORY,
3355 POLICY_SCOPE_USER, 3449 POLICY_SCOPE_USER,
3450 POLICY_SOURCE_CLOUD,
3356 new base::StringValue("http://chromium.org"), 3451 new base::StringValue("http://chromium.org"),
3357 NULL); 3452 NULL);
3358 provider_.UpdateChromePolicy(policies); 3453 provider_.UpdateChromePolicy(policies);
3359 } 3454 }
3360 }; 3455 };
3361 3456
3362 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { 3457 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) {
3363 // Verifies that policy usage histograms are collected at startup. 3458 // Verifies that policy usage histograms are collected at startup.
3364 3459
3365 // BrowserPolicyConnector::Init() has already been called. Make sure the 3460 // BrowserPolicyConnector::Init() has already been called. Make sure the
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 // audio or video capture allow policy and must never be NULL. 3508 // audio or video capture allow policy and must never be NULL.
3414 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist 3509 // |whitelist_policy| and |allow_rule| are optional. If NULL, no whitelist
3415 // policy is set. If non-NULL, the whitelist policy is set to contain either 3510 // policy is set. If non-NULL, the whitelist policy is set to contain either
3416 // the |allow_rule| (if non-NULL) or an "allow all" wildcard. 3511 // the |allow_rule| (if non-NULL) or an "allow all" wildcard.
3417 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name, 3512 void ConfigurePolicyMap(PolicyMap* policies, const char* policy_name,
3418 const char* whitelist_policy, 3513 const char* whitelist_policy,
3419 const char* allow_rule) { 3514 const char* allow_rule) {
3420 policies->Set(policy_name, 3515 policies->Set(policy_name,
3421 POLICY_LEVEL_MANDATORY, 3516 POLICY_LEVEL_MANDATORY,
3422 POLICY_SCOPE_USER, 3517 POLICY_SCOPE_USER,
3518 POLICY_SOURCE_CLOUD,
3423 new base::FundamentalValue(policy_value_), 3519 new base::FundamentalValue(policy_value_),
3424 NULL); 3520 NULL);
3425 3521
3426 if (whitelist_policy) { 3522 if (whitelist_policy) {
3427 // Add an entry to the whitelist that allows the specified URL regardless 3523 // Add an entry to the whitelist that allows the specified URL regardless
3428 // of the setting of kAudioCapturedAllowed. 3524 // of the setting of kAudioCapturedAllowed.
3429 base::ListValue* list = new base::ListValue(); 3525 base::ListValue* list = new base::ListValue();
3430 if (allow_rule) { 3526 if (allow_rule) {
3431 list->AppendString(allow_rule); 3527 list->AppendString(allow_rule);
3432 request_url_allowed_via_whitelist_ = true; 3528 request_url_allowed_via_whitelist_ = true;
3433 } else { 3529 } else {
3434 list->AppendString(ContentSettingsPattern::Wildcard().ToString()); 3530 list->AppendString(ContentSettingsPattern::Wildcard().ToString());
3435 // We should ignore all wildcard entries in the whitelist, so even 3531 // We should ignore all wildcard entries in the whitelist, so even
3436 // though we've added an entry, it should be ignored and our expectation 3532 // though we've added an entry, it should be ignored and our expectation
3437 // is that the request has not been allowed via the whitelist. 3533 // is that the request has not been allowed via the whitelist.
3438 request_url_allowed_via_whitelist_ = false; 3534 request_url_allowed_via_whitelist_ = false;
3439 } 3535 }
3440 policies->Set(whitelist_policy, POLICY_LEVEL_MANDATORY, 3536 policies->Set(whitelist_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
3441 POLICY_SCOPE_USER, list, NULL); 3537 POLICY_SOURCE_CLOUD, list, nullptr);
3442 } 3538 }
3443 } 3539 }
3444 3540
3445 void Accept(const content::MediaStreamDevices& devices, 3541 void Accept(const content::MediaStreamDevices& devices,
3446 content::MediaStreamRequestResult result, 3542 content::MediaStreamRequestResult result,
3447 scoped_ptr<content::MediaStreamUI> ui) { 3543 scoped_ptr<content::MediaStreamUI> ui) {
3448 if (policy_value_ || request_url_allowed_via_whitelist_) { 3544 if (policy_value_ || request_url_allowed_via_whitelist_) {
3449 ASSERT_EQ(1U, devices.size()); 3545 ASSERT_EQ(1U, devices.size());
3450 ASSERT_EQ("fake_dev", devices[0].id); 3546 ASSERT_EQ("fake_dev", devices[0].id);
3451 } else { 3547 } else {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3626 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), 3722 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED),
3627 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 3723 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
3628 ASSERT_TRUE(https_server_expired.Start()); 3724 ASSERT_TRUE(https_server_expired.Start());
3629 3725
3630 // Set the enterprise policy to disallow opt-in. 3726 // Set the enterprise policy to disallow opt-in.
3631 const PrefService* const prefs = browser()->profile()->GetPrefs(); 3727 const PrefService* const prefs = browser()->profile()->GetPrefs();
3632 EXPECT_TRUE( 3728 EXPECT_TRUE(
3633 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); 3729 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed));
3634 PolicyMap policies; 3730 PolicyMap policies;
3635 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed, 3731 policies.Set(key::kSafeBrowsingExtendedReportingOptInAllowed,
3636 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 3732 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3637 new base::FundamentalValue(false), NULL); 3733 new base::FundamentalValue(false), nullptr);
3638 UpdateProviderPolicy(policies); 3734 UpdateProviderPolicy(policies);
3639 EXPECT_FALSE( 3735 EXPECT_FALSE(
3640 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed)); 3736 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed));
3641 3737
3642 // Navigate to an SSL error page. 3738 // Navigate to an SSL error page.
3643 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); 3739 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/"));
3644 3740
3645 const content::InterstitialPage* const interstitial = 3741 const content::InterstitialPage* const interstitial =
3646 content::InterstitialPage::GetInterstitialPage( 3742 content::InterstitialPage::GetInterstitialPage(
3647 browser()->tab_strip_model()->GetActiveWebContents()); 3743 browser()->tab_strip_model()->GetActiveWebContents());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3710 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), 3806 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED),
3711 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 3807 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
3712 ASSERT_TRUE(https_server_expired.Start()); 3808 ASSERT_TRUE(https_server_expired.Start());
3713 3809
3714 const PrefService* const prefs = browser()->profile()->GetPrefs(); 3810 const PrefService* const prefs = browser()->profile()->GetPrefs();
3715 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); 3811 EXPECT_TRUE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed));
3716 3812
3717 // Disallowing the proceed link by setting the policy to |false|. 3813 // Disallowing the proceed link by setting the policy to |false|.
3718 PolicyMap policies; 3814 PolicyMap policies;
3719 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY, 3815 policies.Set(key::kSSLErrorOverrideAllowed, POLICY_LEVEL_MANDATORY,
3720 POLICY_SCOPE_USER, new base::FundamentalValue(false), NULL); 3816 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3817 new base::FundamentalValue(false), nullptr);
3721 UpdateProviderPolicy(policies); 3818 UpdateProviderPolicy(policies);
3722 3819
3723 // Policy should not allow overriding anymore. 3820 // Policy should not allow overriding anymore.
3724 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed)); 3821 EXPECT_FALSE(prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed));
3725 3822
3726 // Policy disallows overriding - navigate to an SSL error page and expect no 3823 // Policy disallows overriding - navigate to an SSL error page and expect no
3727 // proceed link. 3824 // proceed link.
3728 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/")); 3825 ui_test_utils::NavigateToURL(browser(), https_server_expired.GetURL("/"));
3729 const content::InterstitialPage* const interstitial = 3826 const content::InterstitialPage* const interstitial =
3730 content::InterstitialPage::GetInterstitialPage( 3827 content::InterstitialPage::GetInterstitialPage(
(...skipping 28 matching lines...) Expand all
3759 // Similar to PolicyTest but sets the proper policy before the browser is 3856 // Similar to PolicyTest but sets the proper policy before the browser is
3760 // started. 3857 // started.
3761 class PolicyVariationsServiceTest : public PolicyTest { 3858 class PolicyVariationsServiceTest : public PolicyTest {
3762 public: 3859 public:
3763 void SetUpInProcessBrowserTestFixture() override { 3860 void SetUpInProcessBrowserTestFixture() override {
3764 PolicyTest::SetUpInProcessBrowserTestFixture(); 3861 PolicyTest::SetUpInProcessBrowserTestFixture();
3765 PolicyMap policies; 3862 PolicyMap policies;
3766 policies.Set(key::kVariationsRestrictParameter, 3863 policies.Set(key::kVariationsRestrictParameter,
3767 POLICY_LEVEL_MANDATORY, 3864 POLICY_LEVEL_MANDATORY,
3768 POLICY_SCOPE_USER, 3865 POLICY_SCOPE_USER,
3866 POLICY_SOURCE_CLOUD,
3769 new base::StringValue("restricted"), 3867 new base::StringValue("restricted"),
3770 NULL); 3868 NULL);
3771 provider_.UpdateChromePolicy(policies); 3869 provider_.UpdateChromePolicy(policies);
3772 } 3870 }
3773 }; 3871 };
3774 3872
3775 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { 3873 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) {
3776 const std::string default_variations_url = 3874 const std::string default_variations_url =
3777 variations::VariationsService::GetDefaultVariationsServerURLForTesting(); 3875 variations::VariationsService::GetDefaultVariationsServerURLForTesting();
3778 3876
(...skipping 11 matching lines...) Expand all
3790 std::string value; 3888 std::string value;
3791 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); 3889 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
3792 EXPECT_EQ("restricted", value); 3890 EXPECT_EQ("restricted", value);
3793 } 3891 }
3794 3892
3795 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { 3893 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) {
3796 base::ListValue blacklist; 3894 base::ListValue blacklist;
3797 blacklist.Append(new base::StringValue("host.name")); 3895 blacklist.Append(new base::StringValue("host.name"));
3798 PolicyMap policies; 3896 PolicyMap policies;
3799 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, 3897 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
3800 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 3898 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
3899 nullptr);
3801 UpdateProviderPolicy(policies); 3900 UpdateProviderPolicy(policies);
3802 3901
3803 PrefService* prefs = browser()->profile()->GetPrefs(); 3902 PrefService* prefs = browser()->profile()->GetPrefs();
3804 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( 3903 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed(
3805 prefs, "host.name")); 3904 prefs, "host.name"));
3806 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( 3905 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed(
3807 prefs, "other.host.name")); 3906 prefs, "other.host.name"));
3808 } 3907 }
3809 3908
3810 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { 3909 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) {
3811 base::ListValue blacklist; 3910 base::ListValue blacklist;
3812 blacklist.Append(new base::StringValue("*")); 3911 blacklist.Append(new base::StringValue("*"));
3813 PolicyMap policies; 3912 PolicyMap policies;
3814 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, 3913 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
3815 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 3914 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
3915 nullptr);
3816 UpdateProviderPolicy(policies); 3916 UpdateProviderPolicy(policies);
3817 3917
3818 PrefService* prefs = browser()->profile()->GetPrefs(); 3918 PrefService* prefs = browser()->profile()->GetPrefs();
3819 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( 3919 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed(
3820 prefs, "host.name")); 3920 prefs, "host.name"));
3821 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( 3921 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed(
3822 prefs, "other.host.name")); 3922 prefs, "other.host.name"));
3823 } 3923 }
3824 3924
3825 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { 3925 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) {
3826 base::ListValue blacklist; 3926 base::ListValue blacklist;
3827 blacklist.Append(new base::StringValue("*")); 3927 blacklist.Append(new base::StringValue("*"));
3828 base::ListValue whitelist; 3928 base::ListValue whitelist;
3829 whitelist.Append(new base::StringValue("host.name")); 3929 whitelist.Append(new base::StringValue("host.name"));
3830 PolicyMap policies; 3930 PolicyMap policies;
3831 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, 3931 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
3832 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 3932 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, blacklist.DeepCopy(),
3933 nullptr);
3833 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, 3934 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY,
3834 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 3935 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, whitelist.DeepCopy(),
3936 nullptr);
3835 UpdateProviderPolicy(policies); 3937 UpdateProviderPolicy(policies);
3836 3938
3837 PrefService* prefs = browser()->profile()->GetPrefs(); 3939 PrefService* prefs = browser()->profile()->GetPrefs();
3838 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed( 3940 EXPECT_TRUE(extensions::MessageService::IsNativeMessagingHostAllowed(
3839 prefs, "host.name")); 3941 prefs, "host.name"));
3840 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed( 3942 EXPECT_FALSE(extensions::MessageService::IsNativeMessagingHostAllowed(
3841 prefs, "other.host.name")); 3943 prefs, "other.host.name"));
3842 } 3944 }
3843 3945
3844 #endif // !defined(CHROME_OS) 3946 #endif // !defined(CHROME_OS)
3845 3947
3846 3948
3847 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 3949 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
3848 // Sets the hardware acceleration mode policy before the browser is started. 3950 // Sets the hardware acceleration mode policy before the browser is started.
3849 class HardwareAccelerationModePolicyTest : public PolicyTest { 3951 class HardwareAccelerationModePolicyTest : public PolicyTest {
3850 public: 3952 public:
3851 HardwareAccelerationModePolicyTest() {} 3953 HardwareAccelerationModePolicyTest() {}
3852 3954
3853 void SetUpInProcessBrowserTestFixture() override { 3955 void SetUpInProcessBrowserTestFixture() override {
3854 PolicyTest::SetUpInProcessBrowserTestFixture(); 3956 PolicyTest::SetUpInProcessBrowserTestFixture();
3855 PolicyMap policies; 3957 PolicyMap policies;
3856 policies.Set(key::kHardwareAccelerationModeEnabled, 3958 policies.Set(key::kHardwareAccelerationModeEnabled,
3857 POLICY_LEVEL_MANDATORY, 3959 POLICY_LEVEL_MANDATORY,
3858 POLICY_SCOPE_USER, 3960 POLICY_SCOPE_USER,
3961 POLICY_SOURCE_CLOUD,
3859 new base::FundamentalValue(false), 3962 new base::FundamentalValue(false),
3860 NULL); 3963 NULL);
3861 provider_.UpdateChromePolicy(policies); 3964 provider_.UpdateChromePolicy(policies);
3862 } 3965 }
3863 }; 3966 };
3864 3967
3865 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest, 3968 IN_PROC_BROWSER_TEST_F(HardwareAccelerationModePolicyTest,
3866 HardwareAccelerationDisabled) { 3969 HardwareAccelerationDisabled) {
3867 // Verifies that hardware acceleration can be disabled with policy. 3970 // Verifies that hardware acceleration can be disabled with policy.
3868 EXPECT_FALSE( 3971 EXPECT_FALSE(
(...skipping 11 matching lines...) Expand all
3880 // The policy description promises that Unified Desktop is not available 3983 // The policy description promises that Unified Desktop is not available
3881 // unless the policy is set (or a command line or an extension is used). If 3984 // unless the policy is set (or a command line or an extension is used). If
3882 // this default behaviour changes, please change the description at 3985 // this default behaviour changes, please change the description at
3883 // components/policy/resources/policy_templates.json. 3986 // components/policy/resources/policy_templates.json.
3884 EXPECT_FALSE(display_manager->unified_desktop_enabled()); 3987 EXPECT_FALSE(display_manager->unified_desktop_enabled());
3885 // Now set the policy and check that unified desktop is turned on. 3988 // Now set the policy and check that unified desktop is turned on.
3886 PolicyMap policies; 3989 PolicyMap policies;
3887 policies.Set(key::kUnifiedDesktopEnabledByDefault, 3990 policies.Set(key::kUnifiedDesktopEnabledByDefault,
3888 POLICY_LEVEL_MANDATORY, 3991 POLICY_LEVEL_MANDATORY,
3889 POLICY_SCOPE_USER, 3992 POLICY_SCOPE_USER,
3993 POLICY_SOURCE_CLOUD,
3890 new base::FundamentalValue(true), 3994 new base::FundamentalValue(true),
3891 NULL); 3995 NULL);
3892 UpdateProviderPolicy(policies); 3996 UpdateProviderPolicy(policies);
3893 EXPECT_TRUE(display_manager->unified_desktop_enabled()); 3997 EXPECT_TRUE(display_manager->unified_desktop_enabled());
3894 policies.Set(key::kUnifiedDesktopEnabledByDefault, 3998 policies.Set(key::kUnifiedDesktopEnabledByDefault,
3895 POLICY_LEVEL_MANDATORY, 3999 POLICY_LEVEL_MANDATORY,
3896 POLICY_SCOPE_USER, 4000 POLICY_SCOPE_USER,
4001 POLICY_SOURCE_CLOUD,
3897 new base::FundamentalValue(false), 4002 new base::FundamentalValue(false),
3898 NULL); 4003 NULL);
3899 UpdateProviderPolicy(policies); 4004 UpdateProviderPolicy(policies);
3900 EXPECT_FALSE(display_manager->unified_desktop_enabled()); 4005 EXPECT_FALSE(display_manager->unified_desktop_enabled());
3901 } 4006 }
3902 #endif // defined(OS_CHROMEOS) 4007 #endif // defined(OS_CHROMEOS)
3903 4008
3904 } // namespace policy 4009 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698