| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 #if !defined(OS_MACOSX) | 222 #if !defined(OS_MACOSX) |
| 223 #include "base/compiler_specific.h" | 223 #include "base/compiler_specific.h" |
| 224 #include "chrome/browser/ui/extensions/app_launch_params.h" | 224 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 225 #include "chrome/browser/ui/extensions/application_launch.h" | 225 #include "chrome/browser/ui/extensions/application_launch.h" |
| 226 #include "extensions/browser/app_window/app_window.h" | 226 #include "extensions/browser/app_window/app_window.h" |
| 227 #include "extensions/browser/app_window/app_window_registry.h" | 227 #include "extensions/browser/app_window/app_window_registry.h" |
| 228 #include "extensions/browser/app_window/native_app_window.h" | 228 #include "extensions/browser/app_window/native_app_window.h" |
| 229 #include "ui/base/window_open_disposition.h" | 229 #include "ui/base/window_open_disposition.h" |
| 230 #endif | 230 #endif |
| 231 | 231 |
| 232 #if defined(ENABLE_MEDIA_ROUTER) |
| 233 #if !defined(OS_ANDROID) |
| 234 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" |
| 235 #include "chrome/browser/ui/toolbar/media_router_action_controller.h" |
| 236 #endif // !defined(OS_ANDROID) |
| 237 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 238 |
| 232 using content::BrowserThread; | 239 using content::BrowserThread; |
| 233 using net::URLRequestMockHTTPJob; | 240 using net::URLRequestMockHTTPJob; |
| 234 using testing::Mock; | 241 using testing::Mock; |
| 235 using testing::Return; | 242 using testing::Return; |
| 236 using testing::_; | 243 using testing::_; |
| 237 | 244 |
| 238 namespace policy { | 245 namespace policy { |
| 239 | 246 |
| 240 namespace { | 247 namespace { |
| 241 | 248 |
| (...skipping 3334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3576 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; | 3583 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; |
| 3577 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; | 3584 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; |
| 3578 | 3585 |
| 3579 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { | 3586 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { |
| 3580 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); | 3587 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3581 } | 3588 } |
| 3582 | 3589 |
| 3583 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { | 3590 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { |
| 3584 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); | 3591 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); |
| 3585 } | 3592 } |
| 3593 |
| 3594 #if !defined(OS_ANDROID) |
| 3595 template <bool enable> |
| 3596 class MediaRouterActionPolicyTest : public PolicyTest { |
| 3597 public: |
| 3598 void SetUpInProcessBrowserTestFixture() override { |
| 3599 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3600 PolicyMap policies; |
| 3601 policies.Set(key::kShowCastIconInToolbar, POLICY_LEVEL_MANDATORY, |
| 3602 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 3603 base::MakeUnique<base::FundamentalValue>(enable), nullptr); |
| 3604 provider_.UpdateChromePolicy(policies); |
| 3605 } |
| 3606 |
| 3607 protected: |
| 3608 bool HasMediaRouterActionAtInit() const { |
| 3609 const std::set<std::string>& component_ids = |
| 3610 ComponentToolbarActionsFactory::GetInstance()->GetInitialComponentIds( |
| 3611 browser()->profile()); |
| 3612 return base::ContainsKey( |
| 3613 component_ids, ComponentToolbarActionsFactory::kMediaRouterActionId); |
| 3614 } |
| 3615 }; |
| 3616 |
| 3617 using MediaRouterActionEnabledPolicyTest = MediaRouterActionPolicyTest<true>; |
| 3618 using MediaRouterActionDisabledPolicyTest = MediaRouterActionPolicyTest<false>; |
| 3619 |
| 3620 IN_PROC_BROWSER_TEST_F(MediaRouterActionEnabledPolicyTest, |
| 3621 MediaRouterActionEnabled) { |
| 3622 EXPECT_TRUE( |
| 3623 MediaRouterActionController::IsActionShownByPolicy(browser()->profile())); |
| 3624 EXPECT_TRUE(HasMediaRouterActionAtInit()); |
| 3625 } |
| 3626 |
| 3627 IN_PROC_BROWSER_TEST_F(MediaRouterActionDisabledPolicyTest, |
| 3628 MediaRouterActionDisabled) { |
| 3629 EXPECT_FALSE( |
| 3630 MediaRouterActionController::IsActionShownByPolicy(browser()->profile())); |
| 3631 EXPECT_FALSE(HasMediaRouterActionAtInit()); |
| 3632 } |
| 3633 #endif // !defined(OS_ANDROID) |
| 3586 #endif // defined(ENABLE_MEDIA_ROUTER) | 3634 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 3587 | 3635 |
| 3588 #if BUILDFLAG(ENABLE_WEBRTC) | 3636 #if BUILDFLAG(ENABLE_WEBRTC) |
| 3589 // Sets the proper policy before the browser is started. | 3637 // Sets the proper policy before the browser is started. |
| 3590 template <bool enable> | 3638 template <bool enable> |
| 3591 class WebRtcUdpPortRangePolicyTest : public PolicyTest { | 3639 class WebRtcUdpPortRangePolicyTest : public PolicyTest { |
| 3592 public: | 3640 public: |
| 3593 WebRtcUdpPortRangePolicyTest() = default; | 3641 WebRtcUdpPortRangePolicyTest() = default; |
| 3594 void SetUpInProcessBrowserTestFixture() override { | 3642 void SetUpInProcessBrowserTestFixture() override { |
| 3595 PolicyTest::SetUpInProcessBrowserTestFixture(); | 3643 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4324 | 4372 |
| 4325 SetEmptyPolicy(); | 4373 SetEmptyPolicy(); |
| 4326 // Policy not set. | 4374 // Policy not set. |
| 4327 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4375 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4328 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4376 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4329 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4377 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4330 } | 4378 } |
| 4331 #endif // defined(OS_CHROMEOS) | 4379 #endif // defined(OS_CHROMEOS) |
| 4332 | 4380 |
| 4333 } // namespace policy | 4381 } // namespace policy |
| OLD | NEW |