| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 #if !defined(OS_MACOSX) | 217 #if !defined(OS_MACOSX) |
| 218 #include "base/compiler_specific.h" | 218 #include "base/compiler_specific.h" |
| 219 #include "chrome/browser/ui/extensions/app_launch_params.h" | 219 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 220 #include "chrome/browser/ui/extensions/application_launch.h" | 220 #include "chrome/browser/ui/extensions/application_launch.h" |
| 221 #include "extensions/browser/app_window/app_window.h" | 221 #include "extensions/browser/app_window/app_window.h" |
| 222 #include "extensions/browser/app_window/app_window_registry.h" | 222 #include "extensions/browser/app_window/app_window_registry.h" |
| 223 #include "extensions/browser/app_window/native_app_window.h" | 223 #include "extensions/browser/app_window/native_app_window.h" |
| 224 #include "ui/base/window_open_disposition.h" | 224 #include "ui/base/window_open_disposition.h" |
| 225 #endif | 225 #endif |
| 226 | 226 |
| 227 #if defined(ENABLE_MEDIA_ROUTER) && !defined(OS_ANDROID) |
| 228 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" |
| 229 #include "chrome/browser/ui/toolbar/media_router_action_controller.h" |
| 230 #endif // defined(ENABLE_MEDIA_ROUTER) && !defined(OS_ANDROID) |
| 231 |
| 227 using content::BrowserThread; | 232 using content::BrowserThread; |
| 228 using net::URLRequestMockHTTPJob; | 233 using net::URLRequestMockHTTPJob; |
| 229 using testing::Mock; | 234 using testing::Mock; |
| 230 using testing::Return; | 235 using testing::Return; |
| 231 using testing::_; | 236 using testing::_; |
| 232 | 237 |
| 233 namespace policy { | 238 namespace policy { |
| 234 | 239 |
| 235 namespace { | 240 namespace { |
| 236 | 241 |
| (...skipping 3334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3571 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; | 3576 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; |
| 3572 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; | 3577 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; |
| 3573 | 3578 |
| 3574 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { | 3579 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { |
| 3575 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); | 3580 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3576 } | 3581 } |
| 3577 | 3582 |
| 3578 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { | 3583 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { |
| 3579 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); | 3584 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3580 } | 3585 } |
| 3586 |
| 3587 #if !defined(OS_ANDROID) |
| 3588 template <bool enable> |
| 3589 class MediaRouterActionPolicyTest : public PolicyTest { |
| 3590 public: |
| 3591 void SetUpInProcessBrowserTestFixture() override { |
| 3592 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3593 PolicyMap policies; |
| 3594 policies.Set(key::kShowCastIconInToolbar, POLICY_LEVEL_MANDATORY, |
| 3595 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3596 base::MakeUnique<base::FundamentalValue>(enable), nullptr); |
| 3597 provider_.UpdateChromePolicy(policies); |
| 3598 } |
| 3599 |
| 3600 protected: |
| 3601 bool HasMediaRouterActionAtInit() const { |
| 3602 const std::set<std::string>& component_ids = |
| 3603 ComponentToolbarActionsFactory::GetInstance()->GetInitialComponentIds( |
| 3604 browser()->profile()); |
| 3605 return base::ContainsKey( |
| 3606 component_ids, ComponentToolbarActionsFactory::kMediaRouterActionId); |
| 3607 } |
| 3608 }; |
| 3609 |
| 3610 using MediaRouterActionEnabledPolicyTest = MediaRouterActionPolicyTest<true>; |
| 3611 using MediaRouterActionDisabledPolicyTest = MediaRouterActionPolicyTest<false>; |
| 3612 |
| 3613 IN_PROC_BROWSER_TEST_F(MediaRouterActionEnabledPolicyTest, |
| 3614 MediaRouterActionEnabled) { |
| 3615 EXPECT_TRUE( |
| 3616 MediaRouterActionController::IsActionShownByPolicy(browser()->profile())); |
| 3617 EXPECT_TRUE(HasMediaRouterActionAtInit()); |
| 3618 } |
| 3619 |
| 3620 IN_PROC_BROWSER_TEST_F(MediaRouterActionDisabledPolicyTest, |
| 3621 MediaRouterActionDisabled) { |
| 3622 EXPECT_FALSE( |
| 3623 MediaRouterActionController::IsActionShownByPolicy(browser()->profile())); |
| 3624 EXPECT_FALSE(HasMediaRouterActionAtInit()); |
| 3625 } |
| 3626 #endif // !defined(OS_ANDROID) |
| 3581 #endif // defined(ENABLE_MEDIA_ROUTER) | 3627 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 3582 | 3628 |
| 3583 #if BUILDFLAG(ENABLE_WEBRTC) | 3629 #if BUILDFLAG(ENABLE_WEBRTC) |
| 3584 // Sets the proper policy before the browser is started. | 3630 // Sets the proper policy before the browser is started. |
| 3585 template <bool enable> | 3631 template <bool enable> |
| 3586 class WebRtcUdpPortRangePolicyTest : public PolicyTest { | 3632 class WebRtcUdpPortRangePolicyTest : public PolicyTest { |
| 3587 public: | 3633 public: |
| 3588 WebRtcUdpPortRangePolicyTest() = default; | 3634 WebRtcUdpPortRangePolicyTest() = default; |
| 3589 void SetUpInProcessBrowserTestFixture() override { | 3635 void SetUpInProcessBrowserTestFixture() override { |
| 3590 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3636 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4297 | 4343 |
| 4298 SetEmptyPolicy(); | 4344 SetEmptyPolicy(); |
| 4299 // Policy not set. | 4345 // Policy not set. |
| 4300 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4346 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4301 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4347 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4302 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4348 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4303 } | 4349 } |
| 4304 #endif // defined(OS_CHROMEOS) | 4350 #endif // defined(OS_CHROMEOS) |
| 4305 | 4351 |
| 4306 } // namespace policy | 4352 } // namespace policy |
| OLD | NEW |