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

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

Issue 2030193004: Add a policy for disabling the stripping of PAC URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add better documentatiob Created 4 years, 6 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/browser/extensions/extension_management_constants.h" 47 #include "chrome/browser/extensions/extension_management_constants.h"
48 #include "chrome/browser/extensions/extension_management_test_util.h" 48 #include "chrome/browser/extensions/extension_management_test_util.h"
49 #include "chrome/browser/extensions/extension_service.h" 49 #include "chrome/browser/extensions/extension_service.h"
50 #include "chrome/browser/extensions/shared_module_service.h" 50 #include "chrome/browser/extensions/shared_module_service.h"
51 #include "chrome/browser/extensions/unpacked_installer.h" 51 #include "chrome/browser/extensions/unpacked_installer.h"
52 #include "chrome/browser/extensions/updater/extension_cache_fake.h" 52 #include "chrome/browser/extensions/updater/extension_cache_fake.h"
53 #include "chrome/browser/extensions/updater/extension_updater.h" 53 #include "chrome/browser/extensions/updater/extension_updater.h"
54 #include "chrome/browser/infobars/infobar_service.h" 54 #include "chrome/browser/infobars/infobar_service.h"
55 #include "chrome/browser/interstitials/security_interstitial_page.h" 55 #include "chrome/browser/interstitials/security_interstitial_page.h"
56 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" 56 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
57 #include "chrome/browser/io_thread.h"
57 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 58 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
58 #include "chrome/browser/media/media_stream_devices_controller.h" 59 #include "chrome/browser/media/media_stream_devices_controller.h"
59 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h" 60 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
60 #include "chrome/browser/net/prediction_options.h" 61 #include "chrome/browser/net/prediction_options.h"
61 #include "chrome/browser/net/url_request_mock_util.h" 62 #include "chrome/browser/net/url_request_mock_util.h"
62 #include "chrome/browser/plugins/plugin_prefs.h" 63 #include "chrome/browser/plugins/plugin_prefs.h"
63 #include "chrome/browser/policy/cloud/test_request_interceptor.h" 64 #include "chrome/browser/policy/cloud/test_request_interceptor.h"
64 #include "chrome/browser/policy/profile_policy_connector.h" 65 #include "chrome/browser/policy/profile_policy_connector.h"
65 #include "chrome/browser/policy/profile_policy_connector_factory.h" 66 #include "chrome/browser/policy/profile_policy_connector_factory.h"
66 #include "chrome/browser/prefs/session_startup_pref.h" 67 #include "chrome/browser/prefs/session_startup_pref.h"
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 // Verify that it can be force-enabled too. 1346 // Verify that it can be force-enabled too.
1346 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); 1347 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true);
1347 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1348 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
1348 POLICY_SOURCE_CLOUD, 1349 POLICY_SOURCE_CLOUD,
1349 base::WrapUnique(new base::FundamentalValue(false)), nullptr); 1350 base::WrapUnique(new base::FundamentalValue(false)), nullptr);
1350 UpdateProviderPolicy(policies); 1351 UpdateProviderPolicy(policies);
1351 content::RunAllPendingInMessageLoop(); 1352 content::RunAllPendingInMessageLoop();
1352 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); 1353 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled());
1353 } 1354 }
1354 1355
1356 namespace {
1357
1358 // The following helpers retrieve whether https:// URL stripping is
1359 // enabled for PAC scripts. It needs to run on the IO thread.
1360 void GetPacHttpsUrlStrippingEnabledOnIOThread(IOThread* io_thread,
1361 bool* enabled) {
1362 *enabled = io_thread->PacHttpsUrlStrippingEnabled();
1363 }
1364
1365 bool GetPacHttpsUrlStrippingEnabled() {
1366 bool enabled;
1367 base::RunLoop loop;
1368 BrowserThread::PostTaskAndReply(
1369 BrowserThread::IO, FROM_HERE,
1370 base::Bind(&GetPacHttpsUrlStrippingEnabledOnIOThread,
1371 g_browser_process->io_thread(), base::Unretained(&enabled)),
1372 loop.QuitClosure());
1373 loop.Run();
1374 return enabled;
1375 }
1376
1377 } // namespace
1378
1379 // Verifies that stripping of https:// URLs before sending to PAC scripts can
1380 // be disabled via a policy. Also verifies that stripping is enabled by
1381 // default.
1382 IN_PROC_BROWSER_TEST_F(PolicyTest, DisablePacHttpsUrlStripping) {
1383 // Stripping is enabled by default.
1384 EXPECT_TRUE(GetPacHttpsUrlStrippingEnabled());
1385
1386 // Disable it via a policy.
1387 PolicyMap policies;
1388 policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY,
1389 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
1390 base::WrapUnique(new base::FundamentalValue(false)), nullptr);
1391 UpdateProviderPolicy(policies);
1392 content::RunAllPendingInMessageLoop();
1393
1394 // It should now reflect as disabled.
1395 EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled());
1396 }
1397
1355 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { 1398 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) {
1356 // Verifies that plugins can be forced to be disabled by policy. 1399 // Verifies that plugins can be forced to be disabled by policy.
1357 1400
1358 // Verify that the Flash plugin exists and that it can be enabled and disabled 1401 // Verify that the Flash plugin exists and that it can be enabled and disabled
1359 // by the user. 1402 // by the user.
1360 std::vector<content::WebPluginInfo> plugins; 1403 std::vector<content::WebPluginInfo> plugins;
1361 GetPluginList(&plugins); 1404 GetPluginList(&plugins);
1362 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); 1405 const content::WebPluginInfo* flash = GetFlashPlugin(plugins);
1363 if (!flash) 1406 if (!flash)
1364 return; 1407 return;
(...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after
4033 4076
4034 SetEmptyPolicy(); 4077 SetEmptyPolicy();
4035 // Policy not set. 4078 // Policy not set.
4036 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4079 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4037 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4080 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4038 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4081 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4039 } 4082 }
4040 #endif // defined(OS_CHROMEOS) 4083 #endif // defined(OS_CHROMEOS)
4041 4084
4042 } // namespace policy 4085 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_handler_list_factory.cc ('k') | chrome/browser/prefs/command_line_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698