OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "base/values.h" | 21 #include "base/values.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chromeos/app_mode/fake_cws.h" | 23 #include "chrome/browser/chromeos/app_mode/fake_cws.h" |
23 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" | 24 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" |
24 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" | 25 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
25 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" | 26 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // Helper KioskAppManager::EnableKioskModeCallback implementation. | 73 // Helper KioskAppManager::EnableKioskModeCallback implementation. |
73 void ConsumerKioskModeLockCheck( | 74 void ConsumerKioskModeLockCheck( |
74 bool* out_locked, | 75 bool* out_locked, |
75 const base::Closure& runner_quit_task, | 76 const base::Closure& runner_quit_task, |
76 bool in_locked) { | 77 bool in_locked) { |
77 LOG(INFO) << "kiosk locked = " << in_locked; | 78 LOG(INFO) << "kiosk locked = " << in_locked; |
78 *out_locked = in_locked; | 79 *out_locked = in_locked; |
79 runner_quit_task.Run(); | 80 runner_quit_task.Run(); |
80 } | 81 } |
81 | 82 |
82 // Helper EnterpriseInstallAttributes::LockResultCallback implementation. | 83 // Helper InstallAttributes::LockResultCallback implementation. |
83 void OnEnterpriseDeviceLock( | 84 void OnEnterpriseDeviceLock(InstallAttributes::LockResult* out_locked, |
84 policy::EnterpriseInstallAttributes::LockResult* out_locked, | 85 const base::Closure& runner_quit_task, |
85 const base::Closure& runner_quit_task, | 86 InstallAttributes::LockResult in_locked) { |
86 policy::EnterpriseInstallAttributes::LockResult in_locked) { | |
87 LOG(INFO) << "Enterprise lock = " << in_locked; | 87 LOG(INFO) << "Enterprise lock = " << in_locked; |
88 *out_locked = in_locked; | 88 *out_locked = in_locked; |
89 runner_quit_task.Run(); | 89 runner_quit_task.Run(); |
90 } | 90 } |
91 | 91 |
92 scoped_refptr<extensions::Extension> MakeKioskApp( | 92 scoped_refptr<extensions::Extension> MakeKioskApp( |
93 const std::string& name, | 93 const std::string& name, |
94 const std::string& version, | 94 const std::string& version, |
95 const std::string& id, | 95 const std::string& id, |
96 const std::string& required_platform_version) { | 96 const std::string& required_platform_version) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 for (size_t i = 0; i < apps.size(); ++i) { | 276 for (size_t i = 0; i < apps.size(); ++i) { |
277 if (i > 0) | 277 if (i > 0) |
278 str += ','; | 278 str += ','; |
279 str += apps[i].app_id; | 279 str += apps[i].app_id; |
280 } | 280 } |
281 | 281 |
282 return str; | 282 return str; |
283 } | 283 } |
284 | 284 |
285 // Locks device for enterprise. | 285 // Locks device for enterprise. |
286 policy::EnterpriseInstallAttributes::LockResult LockDeviceForEnterprise() { | 286 InstallAttributes::LockResult LockDeviceForEnterprise() { |
287 std::unique_ptr<policy::EnterpriseInstallAttributes::LockResult> | 287 std::unique_ptr<InstallAttributes::LockResult> lock_result = |
288 lock_result(new policy::EnterpriseInstallAttributes::LockResult( | 288 base::MakeUnique<InstallAttributes::LockResult>( |
289 policy::EnterpriseInstallAttributes::LOCK_NOT_READY)); | 289 InstallAttributes::LOCK_NOT_READY); |
290 scoped_refptr<content::MessageLoopRunner> runner = | 290 scoped_refptr<content::MessageLoopRunner> runner = |
291 new content::MessageLoopRunner; | 291 new content::MessageLoopRunner; |
292 policy::BrowserPolicyConnectorChromeOS* connector = | 292 policy::BrowserPolicyConnectorChromeOS* connector = |
293 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 293 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
294 connector->GetInstallAttributes()->LockDevice( | 294 connector->GetInstallAttributes()->LockDevice( |
295 "user@domain.com", | 295 "user@domain.com", |
296 policy::DEVICE_MODE_ENTERPRISE, | 296 policy::DEVICE_MODE_ENTERPRISE, |
297 "device-id", | 297 "device-id", |
298 base::Bind( | 298 base::Bind( |
299 &OnEnterpriseDeviceLock, lock_result.get(), runner->QuitClosure())); | 299 &OnEnterpriseDeviceLock, lock_result.get(), runner->QuitClosure())); |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 status.get(), | 810 status.get(), |
811 runner3->QuitClosure())); | 811 runner3->QuitClosure())); |
812 runner3->Run(); | 812 runner3->Run(); |
813 EXPECT_EQ(*status.get(), | 813 EXPECT_EQ(*status.get(), |
814 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED); | 814 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED); |
815 } | 815 } |
816 | 816 |
817 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, | 817 IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, |
818 PreventEnableConsumerKioskForEnterprise) { | 818 PreventEnableConsumerKioskForEnterprise) { |
819 // First, lock the device as enterprise. | 819 // First, lock the device as enterprise. |
820 EXPECT_EQ(LockDeviceForEnterprise(), | 820 EXPECT_EQ(LockDeviceForEnterprise(), InstallAttributes::LOCK_SUCCESS); |
821 policy::EnterpriseInstallAttributes::LOCK_SUCCESS); | |
822 | 821 |
823 std::unique_ptr<KioskAppManager::ConsumerKioskAutoLaunchStatus> status( | 822 std::unique_ptr<KioskAppManager::ConsumerKioskAutoLaunchStatus> status( |
824 new KioskAppManager::ConsumerKioskAutoLaunchStatus( | 823 new KioskAppManager::ConsumerKioskAutoLaunchStatus( |
825 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED)); | 824 KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED)); |
826 std::unique_ptr<bool> locked(new bool(true)); | 825 std::unique_ptr<bool> locked(new bool(true)); |
827 | 826 |
828 scoped_refptr<content::MessageLoopRunner> runner = | 827 scoped_refptr<content::MessageLoopRunner> runner = |
829 new content::MessageLoopRunner; | 828 new content::MessageLoopRunner; |
830 manager()->GetConsumerKioskAutoLaunchStatus( | 829 manager()->GetConsumerKioskAutoLaunchStatus( |
831 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, | 830 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 MakeKioskApp("App Name", "1.0", kNoneAutoLaucnhedAppId, | 937 MakeKioskApp("App Name", "1.0", kNoneAutoLaucnhedAppId, |
939 kTestCases[i].required_platform_version); | 938 kTestCases[i].required_platform_version); |
940 EXPECT_TRUE(manager()->IsPlatformCompliantWithApp(app.get())) | 939 EXPECT_TRUE(manager()->IsPlatformCompliantWithApp(app.get())) |
941 << "Test case for non auto launch app: " << i | 940 << "Test case for non auto launch app: " << i |
942 << ", required_platform_version=" | 941 << ", required_platform_version=" |
943 << kTestCases[i].required_platform_version; | 942 << kTestCases[i].required_platform_version; |
944 } | 943 } |
945 } | 944 } |
946 | 945 |
947 } // namespace chromeos | 946 } // namespace chromeos |
OLD | NEW |