| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "content/public/browser/notification_types.h" | 55 #include "content/public/browser/notification_types.h" |
| 56 #include "content/public/browser/render_view_host.h" | 56 #include "content/public/browser/render_view_host.h" |
| 57 #include "content/public/browser/web_contents.h" | 57 #include "content/public/browser/web_contents.h" |
| 58 #include "content/public/common/url_constants.h" | 58 #include "content/public/common/url_constants.h" |
| 59 #include "content/public/test/browser_test_utils.h" | 59 #include "content/public/test/browser_test_utils.h" |
| 60 #include "content/public/test/download_test_observer.h" | 60 #include "content/public/test/download_test_observer.h" |
| 61 #include "content/public/test/test_utils.h" | 61 #include "content/public/test/test_utils.h" |
| 62 #include "content/test/net/url_request_mock_http_job.h" | 62 #include "content/test/net/url_request_mock_http_job.h" |
| 63 #include "googleurl/src/gurl.h" | 63 #include "googleurl/src/gurl.h" |
| 64 #include "net/base/net_util.h" | 64 #include "net/base/net_util.h" |
| 65 #include "net/http/http_stream_factory.h" |
| 65 #include "net/url_request/url_request.h" | 66 #include "net/url_request/url_request.h" |
| 66 #include "net/url_request/url_request_filter.h" | 67 #include "net/url_request/url_request_filter.h" |
| 67 #include "policy/policy_constants.h" | 68 #include "policy/policy_constants.h" |
| 68 #include "testing/gmock/include/gmock/gmock.h" | 69 #include "testing/gmock/include/gmock/gmock.h" |
| 69 #include "testing/gtest/include/gtest/gtest.h" | 70 #include "testing/gtest/include/gtest/gtest.h" |
| 70 | 71 |
| 71 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
| 72 #include "ash/accelerators/accelerator_controller.h" | 73 #include "ash/accelerators/accelerator_controller.h" |
| 73 #include "ash/accelerators/accelerator_table.h" | 74 #include "ash/accelerators/accelerator_table.h" |
| 74 #include "ash/shell.h" | 75 #include "ash/shell.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // Enable with a policy. | 426 // Enable with a policy. |
| 426 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, | 427 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, |
| 427 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); | 428 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); |
| 428 provider_.UpdateChromePolicy(policies); | 429 provider_.UpdateChromePolicy(policies); |
| 429 content::CrashTab(contents); | 430 content::CrashTab(contents); |
| 430 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); | 431 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_RELOAD)); |
| 431 EXPECT_TRUE(IsWebGLEnabled(contents)); | 432 EXPECT_TRUE(IsWebGLEnabled(contents)); |
| 432 } | 433 } |
| 433 #endif | 434 #endif |
| 434 | 435 |
| 436 IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) { |
| 437 // Verifies that SPDY can be disable by policy. |
| 438 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); |
| 439 PolicyMap policies; |
| 440 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, |
| 441 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
| 442 provider_.UpdateChromePolicy(policies); |
| 443 content::RunAllPendingInMessageLoop(); |
| 444 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); |
| 445 // Verify that it can be force-enabled too. |
| 446 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableSpdy, true); |
| 447 policies.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, |
| 448 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); |
| 449 provider_.UpdateChromePolicy(policies); |
| 450 content::RunAllPendingInMessageLoop(); |
| 451 EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled()); |
| 452 } |
| 453 |
| 435 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { | 454 IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { |
| 436 // Verifies that access to the developer tools can be disabled. | 455 // Verifies that access to the developer tools can be disabled. |
| 437 | 456 |
| 438 // Open devtools. | 457 // Open devtools. |
| 439 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 458 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
| 440 content::WebContents* contents = chrome::GetActiveWebContents(browser()); | 459 content::WebContents* contents = chrome::GetActiveWebContents(browser()); |
| 441 EXPECT_TRUE(DevToolsWindow::GetDevToolsContents(contents)); | 460 EXPECT_TRUE(DevToolsWindow::GetDevToolsContents(contents)); |
| 442 | 461 |
| 443 // Disable devtools via policy. | 462 // Disable devtools via policy. |
| 444 PolicyMap policies; | 463 PolicyMap policies; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 TestScreenshotFile(true); | 706 TestScreenshotFile(true); |
| 688 ASSERT_EQ(CountScreenshots(), screenshot_count + 1); | 707 ASSERT_EQ(CountScreenshots(), screenshot_count + 1); |
| 689 | 708 |
| 690 // Check if trying to take a screenshot fails when disabled by policy. | 709 // Check if trying to take a screenshot fails when disabled by policy. |
| 691 TestScreenshotFile(false); | 710 TestScreenshotFile(false); |
| 692 ASSERT_EQ(CountScreenshots(), screenshot_count + 1); | 711 ASSERT_EQ(CountScreenshots(), screenshot_count + 1); |
| 693 } | 712 } |
| 694 #endif | 713 #endif |
| 695 | 714 |
| 696 } // namespace policy | 715 } // namespace policy |
| OLD | NEW |