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

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: rebase Created 4 years, 5 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 3617 matching lines...) Expand 10 before | Expand all | Expand 10 after
3748 3749
3749 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { 3750 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) {
3750 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); 3751 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile()));
3751 } 3752 }
3752 3753
3753 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { 3754 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) {
3754 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); 3755 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile()));
3755 } 3756 }
3756 #endif // defined(ENABLE_MEDIA_ROUTER) 3757 #endif // defined(ENABLE_MEDIA_ROUTER)
3757 3758
3759 #if defined(ENABLE_WEBRTC)
3760 // Sets the proper policy before the browser is started.
3761 template <bool enable>
3762 class WebRtcUdpPortRangePolicyTest : public PolicyTest {
3763 public:
3764 void SetUpInProcessBrowserTestFixture() override {
3765 PolicyTest::SetUpInProcessBrowserTestFixture();
3766 PolicyMap policies;
3767 if (enable) {
3768 policies.Set(key::kWebRtcUdpPortRange, POLICY_LEVEL_MANDATORY,
3769 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3770 base::WrapUnique(new base::StringValue("10000-10100")),
3771 nullptr);
3772 }
3773 provider_.UpdateChromePolicy(policies);
3774 }
3775 };
3776
3777 using WebRtcUdpPortRangeEnabledPolicyTest = WebRtcUdpPortRangePolicyTest<true>;
3778 using WebRtcUdpPortRangeDisabledPolicyTest =
3779 WebRtcUdpPortRangePolicyTest<false>;
3780
3781 IN_PROC_BROWSER_TEST_F(WebRtcUdpPortRangeEnabledPolicyTest,
3782 WebRtcUdpPortRangeEnabled) {
3783 std::string port_range;
3784 const PrefService::Preference* pref =
3785 user_prefs::UserPrefs::Get(browser()->profile())
3786 ->FindPreference(prefs::kWebRTCUDPPortRange);
3787 pref->GetValue()->GetAsString(&port_range);
3788 EXPECT_EQ("10000-10100", port_range);
3789 }
3790
3791 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest,
3792 WebRtcUdpPortRangeDisabled) {
3793 std::string port_range;
3794 const PrefService::Preference* pref =
3795 user_prefs::UserPrefs::Get(browser()->profile())
3796 ->FindPreference(prefs::kWebRTCUDPPortRange);
3797 pref->GetValue()->GetAsString(&port_range);
3798 EXPECT_TRUE(port_range.empty());
3799 }
3800 #endif // defined(ENABLE_WEBRTC)
3801
3758 #if !defined(OS_CHROMEOS) 3802 #if !defined(OS_CHROMEOS)
3759 // Similar to PolicyTest but sets the proper policy before the browser is 3803 // Similar to PolicyTest but sets the proper policy before the browser is
3760 // started. 3804 // started.
3761 class PolicyVariationsServiceTest : public PolicyTest { 3805 class PolicyVariationsServiceTest : public PolicyTest {
3762 public: 3806 public:
3763 void SetUpInProcessBrowserTestFixture() override { 3807 void SetUpInProcessBrowserTestFixture() override {
3764 PolicyTest::SetUpInProcessBrowserTestFixture(); 3808 PolicyTest::SetUpInProcessBrowserTestFixture();
3765 PolicyMap policies; 3809 PolicyMap policies;
3766 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY, 3810 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY,
3767 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 3811 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
4107 4151
4108 SetEmptyPolicy(); 4152 SetEmptyPolicy();
4109 // Policy not set. 4153 // Policy not set.
4110 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4154 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4111 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4155 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4112 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4156 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4113 } 4157 }
4114 #endif // defined(OS_CHROMEOS) 4158 #endif // defined(OS_CHROMEOS)
4115 4159
4116 } // namespace policy 4160 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698