Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #include "chrome/browser/infobars/infobar_service.h" | 56 #include "chrome/browser/infobars/infobar_service.h" |
| 57 #include "chrome/browser/interstitials/security_interstitial_page.h" | 57 #include "chrome/browser/interstitials/security_interstitial_page.h" |
| 58 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" | 58 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" |
| 59 #include "chrome/browser/io_thread.h" | 59 #include "chrome/browser/io_thread.h" |
| 60 #include "chrome/browser/media/router/media_router_feature.h" | 60 #include "chrome/browser/media/router/media_router_feature.h" |
| 61 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 61 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| 62 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | 62 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| 63 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h" | 63 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h" |
| 64 #include "chrome/browser/net/prediction_options.h" | 64 #include "chrome/browser/net/prediction_options.h" |
| 65 #include "chrome/browser/net/url_request_mock_util.h" | 65 #include "chrome/browser/net/url_request_mock_util.h" |
| 66 #include "chrome/browser/plugins/plugin_prefs.h" | |
| 67 #include "chrome/browser/policy/cloud/test_request_interceptor.h" | 66 #include "chrome/browser/policy/cloud/test_request_interceptor.h" |
| 68 #include "chrome/browser/policy/profile_policy_connector.h" | 67 #include "chrome/browser/policy/profile_policy_connector.h" |
| 69 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 68 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 70 #include "chrome/browser/prefs/session_startup_pref.h" | 69 #include "chrome/browser/prefs/session_startup_pref.h" |
| 71 #include "chrome/browser/profiles/profile.h" | 70 #include "chrome/browser/profiles/profile.h" |
| 72 #include "chrome/browser/search/instant_service.h" | 71 #include "chrome/browser/search/instant_service.h" |
| 73 #include "chrome/browser/search/instant_service_factory.h" | 72 #include "chrome/browser/search/instant_service_factory.h" |
| 74 #include "chrome/browser/search/search.h" | 73 #include "chrome/browser/search/search.h" |
| 75 #include "chrome/browser/search_engines/template_url_service_factory.h" | 74 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 76 #include "chrome/browser/ssl/ssl_blocking_page.h" | 75 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 #include "components/search_engines/template_url.h" | 116 #include "components/search_engines/template_url.h" |
| 118 #include "components/search_engines/template_url_service.h" | 117 #include "components/search_engines/template_url_service.h" |
| 119 #include "components/security_interstitials/core/controller_client.h" | 118 #include "components/security_interstitials/core/controller_client.h" |
| 120 #include "components/strings/grit/components_strings.h" | 119 #include "components/strings/grit/components_strings.h" |
| 121 #include "components/translate/core/browser/language_state.h" | 120 #include "components/translate/core/browser/language_state.h" |
| 122 #include "components/translate/core/browser/translate_infobar_delegate.h" | 121 #include "components/translate/core/browser/translate_infobar_delegate.h" |
| 123 #include "components/update_client/url_request_post_interceptor.h" | 122 #include "components/update_client/url_request_post_interceptor.h" |
| 124 #include "components/user_prefs/user_prefs.h" | 123 #include "components/user_prefs/user_prefs.h" |
| 125 #include "components/variations/service/variations_service.h" | 124 #include "components/variations/service/variations_service.h" |
| 126 #include "components/version_info/version_info.h" | 125 #include "components/version_info/version_info.h" |
| 127 #include "content/public/browser/browser_child_process_host_iterator.h" | 126 #include "content/public/browser/browser_child_process_host_iterator.h" |
|
bartfab (slow)
2016/10/25 15:11:20
Nit: No longer used.
pastarmovj
2016/10/25 15:22:24
Done.
| |
| 128 #include "content/public/browser/browser_context.h" | 127 #include "content/public/browser/browser_context.h" |
| 129 #include "content/public/browser/browser_thread.h" | 128 #include "content/public/browser/browser_thread.h" |
| 130 #include "content/public/browser/child_process_data.h" | 129 #include "content/public/browser/child_process_data.h" |
| 131 #include "content/public/browser/download_item.h" | 130 #include "content/public/browser/download_item.h" |
| 132 #include "content/public/browser/download_manager.h" | 131 #include "content/public/browser/download_manager.h" |
| 133 #include "content/public/browser/gpu_data_manager.h" | 132 #include "content/public/browser/gpu_data_manager.h" |
| 134 #include "content/public/browser/interstitial_page.h" | 133 #include "content/public/browser/interstitial_page.h" |
| 135 #include "content/public/browser/notification_details.h" | 134 #include "content/public/browser/notification_details.h" |
| 136 #include "content/public/browser/notification_observer.h" | 135 #include "content/public/browser/notification_observer.h" |
| 137 #include "content/public/browser/notification_registrar.h" | 136 #include "content/public/browser/notification_registrar.h" |
| 138 #include "content/public/browser/notification_service.h" | 137 #include "content/public/browser/notification_service.h" |
| 139 #include "content/public/browser/notification_source.h" | 138 #include "content/public/browser/notification_source.h" |
| 140 #include "content/public/browser/notification_types.h" | 139 #include "content/public/browser/notification_types.h" |
| 141 #include "content/public/browser/plugin_service.h" | |
| 142 #include "content/public/browser/render_frame_host.h" | 140 #include "content/public/browser/render_frame_host.h" |
| 143 #include "content/public/browser/render_process_host.h" | 141 #include "content/public/browser/render_process_host.h" |
| 144 #include "content/public/browser/render_view_host.h" | 142 #include "content/public/browser/render_view_host.h" |
| 145 #include "content/public/browser/render_widget_host.h" | 143 #include "content/public/browser/render_widget_host.h" |
| 146 #include "content/public/browser/web_contents.h" | 144 #include "content/public/browser/web_contents.h" |
| 147 #include "content/public/common/content_constants.h" | 145 #include "content/public/common/content_constants.h" |
| 148 #include "content/public/common/content_paths.h" | 146 #include "content/public/common/content_paths.h" |
| 149 #include "content/public/common/content_switches.h" | 147 #include "content/public/common/content_switches.h" |
| 150 #include "content/public/common/process_type.h" | 148 #include "content/public/common/process_type.h" |
|
bartfab (slow)
2016/10/25 15:11:20
Nit: No longer used.
pastarmovj
2016/10/25 15:22:24
Done.
| |
| 151 #include "content/public/common/result_codes.h" | 149 #include "content/public/common/result_codes.h" |
| 152 #include "content/public/common/url_constants.h" | 150 #include "content/public/common/url_constants.h" |
| 153 #include "content/public/common/webplugininfo.h" | |
| 154 #include "content/public/test/browser_test_utils.h" | 151 #include "content/public/test/browser_test_utils.h" |
| 155 #include "content/public/test/download_test_observer.h" | 152 #include "content/public/test/download_test_observer.h" |
| 156 #include "content/public/test/mock_notification_observer.h" | 153 #include "content/public/test/mock_notification_observer.h" |
| 157 #include "content/public/test/test_navigation_observer.h" | 154 #include "content/public/test/test_navigation_observer.h" |
| 158 #include "content/public/test/test_utils.h" | 155 #include "content/public/test/test_utils.h" |
| 159 #include "device/bluetooth/bluetooth_adapter_factory.h" | 156 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 160 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 157 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| 161 #include "extensions/browser/extension_dialog_auto_confirm.h" | 158 #include "extensions/browser/extension_dialog_auto_confirm.h" |
| 162 #include "extensions/browser/extension_host.h" | 159 #include "extensions/browser/extension_host.h" |
| 163 #include "extensions/browser/extension_prefs.h" | 160 #include "extensions/browser/extension_prefs.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 if (!value->GetAsInteger(&result)) | 471 if (!value->GetAsInteger(&result)) |
| 475 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType()); | 472 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType()); |
| 476 return result == 123; | 473 return result == 123; |
| 477 } | 474 } |
| 478 | 475 |
| 479 bool IsNetworkPredictionEnabled(PrefService* prefs) { | 476 bool IsNetworkPredictionEnabled(PrefService* prefs) { |
| 480 return chrome_browser_net::CanPrefetchAndPrerenderUI(prefs) == | 477 return chrome_browser_net::CanPrefetchAndPrerenderUI(prefs) == |
| 481 chrome_browser_net::NetworkPredictionStatus::ENABLED; | 478 chrome_browser_net::NetworkPredictionStatus::ENABLED; |
| 482 } | 479 } |
| 483 | 480 |
| 484 void CopyPluginListAndQuit(std::vector<content::WebPluginInfo>* out, | |
| 485 const std::vector<content::WebPluginInfo>& in) { | |
| 486 *out = in; | |
| 487 base::MessageLoop::current()->QuitWhenIdle(); | |
| 488 } | |
| 489 | |
| 490 template<typename T> | |
| 491 void CopyValueAndQuit(T* out, T in) { | |
| 492 *out = in; | |
| 493 base::MessageLoop::current()->QuitWhenIdle(); | |
| 494 } | |
| 495 | |
| 496 void GetPluginList(std::vector<content::WebPluginInfo>* plugins) { | |
| 497 content::PluginService* service = content::PluginService::GetInstance(); | |
| 498 service->GetPlugins(base::Bind(CopyPluginListAndQuit, plugins)); | |
| 499 content::RunMessageLoop(); | |
| 500 } | |
| 501 | |
| 502 const content::WebPluginInfo* GetFlashPlugin( | |
| 503 const std::vector<content::WebPluginInfo>& plugins) { | |
| 504 const content::WebPluginInfo* flash = NULL; | |
| 505 for (size_t i = 0; i < plugins.size(); ++i) { | |
| 506 if (plugins[i].name == base::ASCIIToUTF16(content::kFlashPluginName)) { | |
| 507 flash = &plugins[i]; | |
| 508 break; | |
| 509 } | |
| 510 } | |
| 511 #if defined(OFFICIAL_BUILD) | |
| 512 // Official builds bundle Flash. | |
| 513 EXPECT_TRUE(flash); | |
| 514 #else | |
| 515 if (!flash) | |
| 516 LOG(INFO) << "Test skipped because the Flash plugin couldn't be found."; | |
| 517 #endif | |
| 518 return flash; | |
| 519 } | |
| 520 | |
| 521 bool SetPluginEnabled(PluginPrefs* plugin_prefs, | |
| 522 const content::WebPluginInfo* plugin, | |
| 523 bool enabled) { | |
| 524 bool ok = false; | |
| 525 plugin_prefs->EnablePlugin(enabled, plugin->path, | |
| 526 base::Bind(CopyValueAndQuit<bool>, &ok)); | |
| 527 content::RunMessageLoop(); | |
| 528 return ok; | |
| 529 } | |
| 530 | |
| 531 int CountPluginsOnIOThread() { | |
| 532 int count = 0; | |
| 533 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | |
| 534 if (iter.GetData().process_type == content::PROCESS_TYPE_PPAPI_PLUGIN) { | |
| 535 count++; | |
| 536 } | |
| 537 } | |
| 538 return count; | |
| 539 } | |
| 540 | |
| 541 int CountPlugins() { | |
| 542 int count = -1; | |
| 543 BrowserThread::PostTaskAndReplyWithResult( | |
| 544 BrowserThread::IO, FROM_HERE, | |
| 545 base::Bind(CountPluginsOnIOThread), | |
| 546 base::Bind(CopyValueAndQuit<int>, &count)); | |
| 547 content::RunMessageLoop(); | |
| 548 EXPECT_GE(count, 0); | |
| 549 return count; | |
| 550 } | |
| 551 | |
| 552 void FlushBlacklistPolicy() { | 481 void FlushBlacklistPolicy() { |
| 553 // Updates of the URLBlacklist are done on IO, after building the blacklist | 482 // Updates of the URLBlacklist are done on IO, after building the blacklist |
| 554 // on the blocking pool, which is initiated from IO. | 483 // on the blocking pool, which is initiated from IO. |
| 555 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 484 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
| 556 BrowserThread::GetBlockingPool()->FlushForTesting(); | 485 BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 557 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 486 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
| 558 } | 487 } |
| 559 | 488 |
| 560 bool ContainsVisibleElement(content::WebContents* contents, | 489 bool ContainsVisibleElement(content::WebContents* contents, |
| 561 const std::string& id) { | 490 const std::string& id) { |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1353 policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY, | 1282 policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY, |
| 1354 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 1283 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 1355 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 1284 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
| 1356 UpdateProviderPolicy(policies); | 1285 UpdateProviderPolicy(policies); |
| 1357 content::RunAllPendingInMessageLoop(); | 1286 content::RunAllPendingInMessageLoop(); |
| 1358 | 1287 |
| 1359 // It should now reflect as disabled. | 1288 // It should now reflect as disabled. |
| 1360 EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled()); | 1289 EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled()); |
| 1361 } | 1290 } |
| 1362 | 1291 |
| 1363 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { | |
| 1364 // Verifies that plugins can be forced to be disabled by policy. | |
| 1365 | |
| 1366 // Verify that the Flash plugin exists and that it can be enabled and disabled | |
| 1367 // by the user. | |
| 1368 std::vector<content::WebPluginInfo> plugins; | |
| 1369 GetPluginList(&plugins); | |
| 1370 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | |
| 1371 if (!flash) | |
| 1372 return; | |
| 1373 PluginPrefs* plugin_prefs = | |
| 1374 PluginPrefs::GetForProfile(browser()->profile()).get(); | |
| 1375 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1376 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | |
| 1377 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1378 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | |
| 1379 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1380 | |
| 1381 // Now disable it with a policy. | |
| 1382 base::ListValue disabled_plugins; | |
| 1383 disabled_plugins.AppendString("*Flash*"); | |
| 1384 PolicyMap policies; | |
| 1385 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 1386 POLICY_SOURCE_CLOUD, disabled_plugins.CreateDeepCopy(), nullptr); | |
| 1387 UpdateProviderPolicy(policies); | |
| 1388 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1389 // The user shouldn't be able to enable it. | |
| 1390 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | |
| 1391 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1392 } | |
| 1393 | |
| 1394 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { | |
| 1395 // Verifies that plugins with an exception in the blacklist can be enabled. | |
| 1396 | |
| 1397 // Verify that the Flash plugin exists and that it can be enabled and disabled | |
| 1398 // by the user. | |
| 1399 std::vector<content::WebPluginInfo> plugins; | |
| 1400 GetPluginList(&plugins); | |
| 1401 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | |
| 1402 if (!flash) | |
| 1403 return; | |
| 1404 PluginPrefs* plugin_prefs = | |
| 1405 PluginPrefs::GetForProfile(browser()->profile()).get(); | |
| 1406 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1407 | |
| 1408 // Disable all plugins. | |
| 1409 base::ListValue disabled_plugins; | |
| 1410 disabled_plugins.AppendString("*"); | |
| 1411 PolicyMap policies; | |
| 1412 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 1413 POLICY_SOURCE_CLOUD, disabled_plugins.CreateDeepCopy(), nullptr); | |
| 1414 UpdateProviderPolicy(policies); | |
| 1415 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1416 // The user shouldn't be able to enable it. | |
| 1417 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | |
| 1418 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1419 | |
| 1420 // Now open an exception for flash. | |
| 1421 base::ListValue disabled_plugins_exceptions; | |
| 1422 disabled_plugins_exceptions.AppendString("*Flash*"); | |
| 1423 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, | |
| 1424 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | |
| 1425 disabled_plugins_exceptions.CreateDeepCopy(), nullptr); | |
| 1426 UpdateProviderPolicy(policies); | |
| 1427 // It should revert to the user's preference automatically. | |
| 1428 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1429 // And the user should be able to disable and enable again. | |
| 1430 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | |
| 1431 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1432 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | |
| 1433 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1434 } | |
| 1435 | |
| 1436 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { | |
| 1437 // Verifies that a plugin can be force-installed with a policy. | |
| 1438 std::vector<content::WebPluginInfo> plugins; | |
| 1439 GetPluginList(&plugins); | |
| 1440 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | |
| 1441 if (!flash) | |
| 1442 return; | |
| 1443 PluginPrefs* plugin_prefs = | |
| 1444 PluginPrefs::GetForProfile(browser()->profile()).get(); | |
| 1445 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1446 | |
| 1447 // The user disables it and then a policy forces it to be enabled. | |
| 1448 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | |
| 1449 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1450 base::ListValue plugin_list; | |
| 1451 plugin_list.AppendString(content::kFlashPluginName); | |
| 1452 PolicyMap policies; | |
| 1453 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 1454 POLICY_SOURCE_CLOUD, plugin_list.CreateDeepCopy(), nullptr); | |
| 1455 UpdateProviderPolicy(policies); | |
| 1456 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1457 // The user can't disable it anymore. | |
| 1458 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); | |
| 1459 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1460 | |
| 1461 // When a plugin is both enabled and disabled, the whitelist takes precedence. | |
| 1462 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 1463 POLICY_SOURCE_CLOUD, plugin_list.CreateDeepCopy(), nullptr); | |
| 1464 UpdateProviderPolicy(policies); | |
| 1465 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | |
| 1466 } | |
| 1467 | |
| 1468 IN_PROC_BROWSER_TEST_F(PolicyTest, AlwaysAuthorizePlugins) { | |
| 1469 // Verifies that dangerous plugins can be always authorized to run with | |
| 1470 // a policy. | |
| 1471 | |
| 1472 // Verify that the test page exists. It is only present in checkouts with | |
| 1473 // src-internal. | |
| 1474 if (!base::PathExists(ui_test_utils::GetTestFilePath( | |
| 1475 base::FilePath(FILE_PATH_LITERAL("plugin")), | |
| 1476 base::FilePath(FILE_PATH_LITERAL("quicktime.html"))))) { | |
| 1477 LOG(INFO) << | |
| 1478 "Test skipped because plugin/quicktime.html test file wasn't found."; | |
| 1479 return; | |
| 1480 } | |
| 1481 | |
| 1482 ServeContentTestData(); | |
| 1483 // No plugins at startup. | |
| 1484 EXPECT_EQ(0, CountPlugins()); | |
| 1485 | |
| 1486 content::WebContents* contents = | |
| 1487 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1488 ASSERT_TRUE(contents); | |
| 1489 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); | |
| 1490 ASSERT_TRUE(infobar_service); | |
| 1491 EXPECT_EQ(0u, infobar_service->infobar_count()); | |
| 1492 | |
| 1493 GURL url(URLRequestMockHTTPJob::GetMockUrl("plugin/quicktime.html")); | |
| 1494 ui_test_utils::NavigateToURL(browser(), url); | |
| 1495 // This should have triggered the dangerous plugin infobar. | |
| 1496 ASSERT_EQ(1u, infobar_service->infobar_count()); | |
| 1497 EXPECT_TRUE( | |
| 1498 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()); | |
| 1499 // And the plugin isn't running. | |
| 1500 EXPECT_EQ(0, CountPlugins()); | |
| 1501 | |
| 1502 // Now set a policy to always authorize this. | |
| 1503 PolicyMap policies; | |
| 1504 policies.Set(key::kAlwaysAuthorizePlugins, POLICY_LEVEL_MANDATORY, | |
| 1505 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | |
| 1506 base::MakeUnique<base::FundamentalValue>(true), nullptr); | |
| 1507 UpdateProviderPolicy(policies); | |
| 1508 // Reloading the page shouldn't trigger the infobar this time. | |
| 1509 ui_test_utils::NavigateToURL(browser(), url); | |
| 1510 EXPECT_EQ(0u, infobar_service->infobar_count()); | |
| 1511 // And the plugin started automatically. | |
| 1512 EXPECT_EQ(1, CountPlugins()); | |
| 1513 } | |
| 1514 | |
| 1515 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { | 1292 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { |
| 1516 // Verifies that access to the developer tools can be disabled. | 1293 // Verifies that access to the developer tools can be disabled. |
| 1517 | 1294 |
| 1518 // Open devtools. | 1295 // Open devtools. |
| 1519 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1296 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
| 1520 content::WebContents* contents = | 1297 content::WebContents* contents = |
| 1521 browser()->tab_strip_model()->GetActiveWebContents(); | 1298 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1522 DevToolsWindow* devtools_window = | 1299 DevToolsWindow* devtools_window = |
| 1523 DevToolsWindow::GetInstanceForInspectedWebContents(contents); | 1300 DevToolsWindow::GetInstanceForInspectedWebContents(contents); |
| 1524 EXPECT_TRUE(devtools_window); | 1301 EXPECT_TRUE(devtools_window); |
| (...skipping 2965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4490 | 4267 |
| 4491 SetEmptyPolicy(); | 4268 SetEmptyPolicy(); |
| 4492 // Policy not set. | 4269 // Policy not set. |
| 4493 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4270 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4494 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4271 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4495 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4272 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4496 } | 4273 } |
| 4497 #endif // defined(OS_CHROMEOS) | 4274 #endif // defined(OS_CHROMEOS) |
| 4498 | 4275 |
| 4499 } // namespace policy | 4276 } // namespace policy |
| OLD | NEW |