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

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

Issue 2127653002: Add policy to control valid UDP port range in WebRTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tnagel's comments Created 4 years, 4 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 #include "components/policy/core/common/policy_service_impl.h" 111 #include "components/policy/core/common/policy_service_impl.h"
112 #include "components/policy/core/common/policy_types.h" 112 #include "components/policy/core/common/policy_types.h"
113 #include "components/prefs/pref_service.h" 113 #include "components/prefs/pref_service.h"
114 #include "components/search/search.h" 114 #include "components/search/search.h"
115 #include "components/search_engines/template_url.h" 115 #include "components/search_engines/template_url.h"
116 #include "components/search_engines/template_url_service.h" 116 #include "components/search_engines/template_url_service.h"
117 #include "components/security_interstitials/core/controller_client.h" 117 #include "components/security_interstitials/core/controller_client.h"
118 #include "components/strings/grit/components_strings.h" 118 #include "components/strings/grit/components_strings.h"
119 #include "components/translate/core/browser/language_state.h" 119 #include "components/translate/core/browser/language_state.h"
120 #include "components/translate/core/browser/translate_infobar_delegate.h" 120 #include "components/translate/core/browser/translate_infobar_delegate.h"
121 #include "components/user_prefs/user_prefs.h"
121 #include "components/variations/service/variations_service.h" 122 #include "components/variations/service/variations_service.h"
122 #include "components/version_info/version_info.h" 123 #include "components/version_info/version_info.h"
123 #include "content/public/browser/browser_child_process_host_iterator.h" 124 #include "content/public/browser/browser_child_process_host_iterator.h"
124 #include "content/public/browser/browser_context.h" 125 #include "content/public/browser/browser_context.h"
125 #include "content/public/browser/browser_thread.h" 126 #include "content/public/browser/browser_thread.h"
126 #include "content/public/browser/child_process_data.h" 127 #include "content/public/browser/child_process_data.h"
127 #include "content/public/browser/download_item.h" 128 #include "content/public/browser/download_item.h"
128 #include "content/public/browser/download_manager.h" 129 #include "content/public/browser/download_manager.h"
129 #include "content/public/browser/gpu_data_manager.h" 130 #include "content/public/browser/gpu_data_manager.h"
130 #include "content/public/browser/interstitial_page.h" 131 #include "content/public/browser/interstitial_page.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 const base::FilePath::CharType kGoodUnpackedExt[] = 273 const base::FilePath::CharType kGoodUnpackedExt[] =
273 FILE_PATH_LITERAL("good_unpacked"); 274 FILE_PATH_LITERAL("good_unpacked");
274 const base::FilePath::CharType kAppUnpackedExt[] = 275 const base::FilePath::CharType kAppUnpackedExt[] =
275 FILE_PATH_LITERAL("app"); 276 FILE_PATH_LITERAL("app");
276 277
277 #if !defined(OS_MACOSX) 278 #if !defined(OS_MACOSX)
278 const base::FilePath::CharType kUnpackedFullscreenAppName[] = 279 const base::FilePath::CharType kUnpackedFullscreenAppName[] =
279 FILE_PATH_LITERAL("fullscreen_app"); 280 FILE_PATH_LITERAL("fullscreen_app");
280 #endif // !defined(OS_MACOSX) 281 #endif // !defined(OS_MACOSX)
281 282
283 #if defined(ENABLE_WEBRTC)
284 // Arbitrary port range for testing the WebRTC UDP port policy.
285 const char kTestWebRtcUdpPortRange[] = "10000-10100";
286 #endif
287
282 // Filters requests to the hosts in |urls| and redirects them to the test data 288 // Filters requests to the hosts in |urls| and redirects them to the test data
283 // dir through URLRequestMockHTTPJobs. 289 // dir through URLRequestMockHTTPJobs.
284 void RedirectHostsToTestData(const char* const urls[], size_t size) { 290 void RedirectHostsToTestData(const char* const urls[], size_t size) {
285 // Map the given hosts to the test data dir. 291 // Map the given hosts to the test data dir.
286 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); 292 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance();
287 base::FilePath base_path; 293 base::FilePath base_path;
288 PathService::Get(chrome::DIR_TEST_DATA, &base_path); 294 PathService::Get(chrome::DIR_TEST_DATA, &base_path);
289 for (size_t i = 0; i < size; ++i) { 295 for (size_t i = 0; i < size; ++i) {
290 const GURL url(urls[i]); 296 const GURL url(urls[i]);
291 EXPECT_TRUE(url.is_valid()); 297 EXPECT_TRUE(url.is_valid());
(...skipping 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3734 3740
3735 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { 3741 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) {
3736 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); 3742 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile()));
3737 } 3743 }
3738 3744
3739 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { 3745 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) {
3740 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); 3746 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile()));
3741 } 3747 }
3742 #endif // defined(ENABLE_MEDIA_ROUTER) 3748 #endif // defined(ENABLE_MEDIA_ROUTER)
3743 3749
3750 #if defined(ENABLE_WEBRTC)
3751 // Sets the proper policy before the browser is started.
3752 template <bool enable>
3753 class WebRtcUdpPortRangePolicyTest : public PolicyTest {
3754 public:
3755 WebRtcUdpPortRangePolicyTest() = default;
3756 void SetUpInProcessBrowserTestFixture() override {
3757 PolicyTest::SetUpInProcessBrowserTestFixture();
3758 PolicyMap policies;
3759 if (enable) {
3760 policies.Set(
3761 key::kWebRtcUdpPortRange, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
3762 POLICY_SOURCE_CLOUD,
3763 base::WrapUnique(new base::StringValue(kTestWebRtcUdpPortRange)),
3764 nullptr);
3765 }
3766 provider_.UpdateChromePolicy(policies);
3767 }
3768
3769 private:
3770 DISALLOW_COPY_AND_ASSIGN(WebRtcUdpPortRangePolicyTest<enable>);
3771 };
3772
3773 using WebRtcUdpPortRangeEnabledPolicyTest = WebRtcUdpPortRangePolicyTest<true>;
3774 using WebRtcUdpPortRangeDisabledPolicyTest =
3775 WebRtcUdpPortRangePolicyTest<false>;
3776
3777 IN_PROC_BROWSER_TEST_F(WebRtcUdpPortRangeEnabledPolicyTest,
3778 WebRtcUdpPortRangeEnabled) {
3779 std::string port_range;
3780 const PrefService::Preference* pref =
3781 user_prefs::UserPrefs::Get(browser()->profile())
3782 ->FindPreference(prefs::kWebRTCUDPPortRange);
3783 pref->GetValue()->GetAsString(&port_range);
3784 EXPECT_EQ(kTestWebRtcUdpPortRange, port_range);
3785 }
3786
3787 IN_PROC_BROWSER_TEST_F(WebRtcUdpPortRangeDisabledPolicyTest,
3788 WebRtcUdpPortRangeDisabled) {
3789 std::string port_range;
3790 const PrefService::Preference* pref =
3791 user_prefs::UserPrefs::Get(browser()->profile())
3792 ->FindPreference(prefs::kWebRTCUDPPortRange);
3793 pref->GetValue()->GetAsString(&port_range);
3794 EXPECT_TRUE(port_range.empty());
3795 }
3796 #endif // defined(ENABLE_WEBRTC)
3797
3744 #if !defined(OS_CHROMEOS) 3798 #if !defined(OS_CHROMEOS)
3745 // Similar to PolicyTest but sets the proper policy before the browser is 3799 // Similar to PolicyTest but sets the proper policy before the browser is
3746 // started. 3800 // started.
3747 class PolicyVariationsServiceTest : public PolicyTest { 3801 class PolicyVariationsServiceTest : public PolicyTest {
3748 public: 3802 public:
3749 void SetUpInProcessBrowserTestFixture() override { 3803 void SetUpInProcessBrowserTestFixture() override {
3750 PolicyTest::SetUpInProcessBrowserTestFixture(); 3804 PolicyTest::SetUpInProcessBrowserTestFixture();
3751 PolicyMap policies; 3805 PolicyMap policies;
3752 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY, 3806 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY,
3753 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 3807 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
4123 4177
4124 SetEmptyPolicy(); 4178 SetEmptyPolicy();
4125 // Policy not set. 4179 // Policy not set.
4126 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4180 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4127 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4181 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4128 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4182 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4129 } 4183 }
4130 #endif // defined(OS_CHROMEOS) 4184 #endif // defined(OS_CHROMEOS)
4131 4185
4132 } // namespace policy 4186 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_handler_list_factory.cc ('k') | chrome/browser/renderer_preferences_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698