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 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 #include "ui/base/page_transition_types.h" | 181 #include "ui/base/page_transition_types.h" |
182 #include "ui/base/resource/resource_bundle.h" | 182 #include "ui/base/resource/resource_bundle.h" |
183 #include "url/gurl.h" | 183 #include "url/gurl.h" |
184 | 184 |
185 #if defined(OS_CHROMEOS) | 185 #if defined(OS_CHROMEOS) |
186 #include "ash/accelerators/accelerator_controller.h" | 186 #include "ash/accelerators/accelerator_controller.h" |
187 #include "ash/accelerators/accelerator_table.h" | 187 #include "ash/accelerators/accelerator_table.h" |
188 #include "ash/shell.h" | 188 #include "ash/shell.h" |
189 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 189 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
190 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 190 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 191 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
191 #include "chrome/browser/profiles/profile_manager.h" | 192 #include "chrome/browser/profiles/profile_manager.h" |
192 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" | 193 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
| 194 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
193 #include "chromeos/audio/cras_audio_handler.h" | 195 #include "chromeos/audio/cras_audio_handler.h" |
| 196 #include "chromeos/chromeos_switches.h" |
| 197 #include "chromeos/dbus/dbus_thread_manager.h" |
| 198 #include "chromeos/dbus/fake_session_manager_client.h" |
| 199 #include "chromeos/dbus/session_manager_client.h" |
| 200 #include "components/arc/arc_bridge_service.h" |
| 201 #include "components/arc/arc_bridge_service_impl.h" |
| 202 #include "components/arc/arc_service_manager.h" |
| 203 #include "components/arc/test/fake_arc_bridge_bootstrap.h" |
| 204 #include "components/arc/test/fake_arc_bridge_instance.h" |
194 #include "ui/chromeos/accessibility_types.h" | 205 #include "ui/chromeos/accessibility_types.h" |
195 #include "ui/keyboard/keyboard_util.h" | 206 #include "ui/keyboard/keyboard_util.h" |
196 #include "ui/snapshot/screenshot_grabber.h" | 207 #include "ui/snapshot/screenshot_grabber.h" |
197 #endif | 208 #endif |
198 | 209 |
199 #if !defined(OS_MACOSX) | 210 #if !defined(OS_MACOSX) |
200 #include "base/compiler_specific.h" | 211 #include "base/compiler_specific.h" |
201 #include "chrome/browser/ui/extensions/app_launch_params.h" | 212 #include "chrome/browser/ui/extensions/app_launch_params.h" |
202 #include "chrome/browser/ui/extensions/application_launch.h" | 213 #include "chrome/browser/ui/extensions/application_launch.h" |
203 #include "extensions/browser/app_window/app_window.h" | 214 #include "extensions/browser/app_window/app_window.h" |
(...skipping 3730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3934 EXPECT_TRUE(display_manager->unified_desktop_enabled()); | 3945 EXPECT_TRUE(display_manager->unified_desktop_enabled()); |
3935 policies.Set(key::kUnifiedDesktopEnabledByDefault, | 3946 policies.Set(key::kUnifiedDesktopEnabledByDefault, |
3936 POLICY_LEVEL_MANDATORY, | 3947 POLICY_LEVEL_MANDATORY, |
3937 POLICY_SCOPE_USER, | 3948 POLICY_SCOPE_USER, |
3938 POLICY_SOURCE_CLOUD, | 3949 POLICY_SOURCE_CLOUD, |
3939 new base::FundamentalValue(false), | 3950 new base::FundamentalValue(false), |
3940 NULL); | 3951 NULL); |
3941 UpdateProviderPolicy(policies); | 3952 UpdateProviderPolicy(policies); |
3942 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 3953 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
3943 } | 3954 } |
| 3955 |
| 3956 class ArcPolicyTest : public PolicyTest { |
| 3957 public: |
| 3958 ArcPolicyTest() {} |
| 3959 ~ArcPolicyTest() override {} |
| 3960 |
| 3961 protected: |
| 3962 void SetUpTest() { |
| 3963 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 3964 chromeos::switches::kDisableArcOptInVerification); |
| 3965 arc::ArcAuthService::DisableUIForTesting(); |
| 3966 |
| 3967 arc::ArcServiceManager::Get()->OnPrimaryUserProfilePrepared( |
| 3968 multi_user_util::GetAccountIdFromProfile(browser()->profile())); |
| 3969 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared( |
| 3970 browser()->profile()); |
| 3971 } |
| 3972 |
| 3973 void TearDownTest() { |
| 3974 arc::ArcAuthService::Get()->Shutdown(); |
| 3975 } |
| 3976 |
| 3977 void SetUpInProcessBrowserTestFixture() override { |
| 3978 PolicyTest::SetUpInProcessBrowserTestFixture(); |
| 3979 fake_session_manager_client_ = new chromeos::FakeSessionManagerClient; |
| 3980 fake_session_manager_client_->set_arc_available(true); |
| 3981 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 3982 scoped_ptr<chromeos::SessionManagerClient>( |
| 3983 fake_session_manager_client_)); |
| 3984 |
| 3985 fake_arc_bridge_instance_.reset(new arc::FakeArcBridgeInstance); |
| 3986 arc::ArcServiceManager::SetArcBridgeServiceForTesting(make_scoped_ptr( |
| 3987 new arc::ArcBridgeServiceImpl(make_scoped_ptr( |
| 3988 new arc::FakeArcBridgeBootstrap( |
| 3989 fake_arc_bridge_instance_.get()))))); |
| 3990 } |
| 3991 |
| 3992 private: |
| 3993 chromeos::FakeSessionManagerClient *fake_session_manager_client_; |
| 3994 scoped_ptr<arc::FakeArcBridgeInstance> fake_arc_bridge_instance_; |
| 3995 |
| 3996 DISALLOW_COPY_AND_ASSIGN(ArcPolicyTest); |
| 3997 }; |
| 3998 |
| 3999 // Test ArcEnabled policy. |
| 4000 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcEnabled) { |
| 4001 SetUpTest(); |
| 4002 |
| 4003 const PrefService* const pref = browser()->profile()->GetPrefs(); |
| 4004 const arc::ArcBridgeService* const arc_bridge_service |
| 4005 = arc::ArcBridgeService::Get(); |
| 4006 |
| 4007 // ARC is switched off by default. |
| 4008 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); |
| 4009 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4010 |
| 4011 // Enable ARC. |
| 4012 PolicyMap policies; |
| 4013 policies.Set(key::kArcEnabled, |
| 4014 POLICY_LEVEL_MANDATORY, |
| 4015 POLICY_SCOPE_USER, |
| 4016 POLICY_SOURCE_CLOUD, |
| 4017 new base::FundamentalValue(true), |
| 4018 nullptr); |
| 4019 UpdateProviderPolicy(policies); |
| 4020 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4021 EXPECT_EQ(arc::ArcBridgeService::State::READY, arc_bridge_service->state()); |
| 4022 |
| 4023 // Disable ARC. |
| 4024 policies.Set(key::kArcEnabled, |
| 4025 POLICY_LEVEL_MANDATORY, |
| 4026 POLICY_SCOPE_USER, |
| 4027 POLICY_SOURCE_CLOUD, |
| 4028 new base::FundamentalValue(false), |
| 4029 nullptr); |
| 4030 UpdateProviderPolicy(policies); |
| 4031 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); |
| 4032 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, arc_bridge_service->state()); |
| 4033 |
| 4034 TearDownTest(); |
| 4035 } |
3944 #endif // defined(OS_CHROMEOS) | 4036 #endif // defined(OS_CHROMEOS) |
3945 | 4037 |
3946 } // namespace policy | 4038 } // namespace policy |
OLD | NEW |