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

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 + some fixes 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 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after
3732 3733
3733 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { 3734 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) {
3734 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); 3735 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile()));
3735 } 3736 }
3736 3737
3737 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { 3738 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) {
3738 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); 3739 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile()));
3739 } 3740 }
3740 #endif // defined(ENABLE_MEDIA_ROUTER) 3741 #endif // defined(ENABLE_MEDIA_ROUTER)
3741 3742
3743 #if defined(ENABLE_WEBRTC)
3744 // Sets the proper policy before the browser is started.
3745 template <bool enable>
3746 class WebRtcUdpPortRangePolicyTest : public PolicyTest {
3747 public:
3748 void SetUpInProcessBrowserTestFixture() override {
3749 PolicyTest::SetUpInProcessBrowserTestFixture();
3750 PolicyMap policies;
3751 if (enable) {
3752 policies.Set(key::kWebRtcUdpPortRange, POLICY_LEVEL_MANDATORY,
3753 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3754 base::WrapUnique(new base::StringValue("10000-10100")),
3755 nullptr);
3756 }
3757 provider_.UpdateChromePolicy(policies);
3758 }
3759 };
sky 2016/08/08 15:20:38 nit: private: DISALLOW...
Guido Urdaneta 2016/08/08 16:27:11 Done.
3760
3761 using WebRtcUdpPortRangeEnabledPolicyTest = WebRtcUdpPortRangePolicyTest<true>;
3762 using WebRtcUdpPortRangeDisabledPolicyTest =
3763 WebRtcUdpPortRangePolicyTest<false>;
3764
3765 IN_PROC_BROWSER_TEST_F(WebRtcUdpPortRangeEnabledPolicyTest,
3766 WebRtcUdpPortRangeEnabled) {
3767 std::string port_range;
3768 const PrefService::Preference* pref =
3769 user_prefs::UserPrefs::Get(browser()->profile())
3770 ->FindPreference(prefs::kWebRTCUDPPortRange);
3771 pref->GetValue()->GetAsString(&port_range);
3772 EXPECT_EQ("10000-10100", port_range);
sky 2016/08/08 15:20:38 Document where this string comes from.
Guido Urdaneta 2016/08/08 16:27:11 Done. Using a constant now.
3773 }
3774
3775 IN_PROC_BROWSER_TEST_F(WebRtcUdpPortRangeDisabledPolicyTest,
3776 WebRtcUdpPortRangeDisabled) {
3777 std::string port_range;
3778 const PrefService::Preference* pref =
3779 user_prefs::UserPrefs::Get(browser()->profile())
3780 ->FindPreference(prefs::kWebRTCUDPPortRange);
3781 pref->GetValue()->GetAsString(&port_range);
3782 EXPECT_TRUE(port_range.empty());
3783 }
3784 #endif // defined(ENABLE_WEBRTC)
3785
3742 #if !defined(OS_CHROMEOS) 3786 #if !defined(OS_CHROMEOS)
3743 // Similar to PolicyTest but sets the proper policy before the browser is 3787 // Similar to PolicyTest but sets the proper policy before the browser is
3744 // started. 3788 // started.
3745 class PolicyVariationsServiceTest : public PolicyTest { 3789 class PolicyVariationsServiceTest : public PolicyTest {
3746 public: 3790 public:
3747 void SetUpInProcessBrowserTestFixture() override { 3791 void SetUpInProcessBrowserTestFixture() override {
3748 PolicyTest::SetUpInProcessBrowserTestFixture(); 3792 PolicyTest::SetUpInProcessBrowserTestFixture();
3749 PolicyMap policies; 3793 PolicyMap policies;
3750 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY, 3794 policies.Set(key::kVariationsRestrictParameter, POLICY_LEVEL_MANDATORY,
3751 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 3795 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 4165
4122 SetEmptyPolicy(); 4166 SetEmptyPolicy();
4123 // Policy not set. 4167 // Policy not set.
4124 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4168 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4125 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4169 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4126 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4170 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4127 } 4171 }
4128 #endif // defined(OS_CHROMEOS) 4172 #endif // defined(OS_CHROMEOS)
4129 4173
4130 } // namespace policy 4174 } // 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