| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ash/desktop_background/desktop_background_controller.h" | 5 #include "ash/desktop_background/desktop_background_controller.h" |
| 6 #include "ash/desktop_background/desktop_background_controller_observer.h" | 6 #include "ash/desktop_background/desktop_background_controller_observer.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 28 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 29 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 29 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
| 30 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 30 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
| 31 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 31 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 32 #include "chrome/browser/chromeos/login/wizard_controller.h" | 32 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 33 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 33 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 34 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 34 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 35 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 35 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 36 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 36 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
| 37 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 37 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
| 38 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 38 #include "chrome/browser/extensions/extension_service.h" | 39 #include "chrome/browser/extensions/extension_service.h" |
| 39 #include "chrome/browser/profiles/profile_impl.h" | 40 #include "chrome/browser/profiles/profile_impl.h" |
| 40 #include "chrome/browser/profiles/profile_manager.h" | 41 #include "chrome/browser/profiles/profile_manager.h" |
| 41 #include "chrome/browser/profiles/profiles_state.h" | 42 #include "chrome/browser/profiles/profiles_state.h" |
| 42 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" | 43 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" |
| 43 #include "chrome/common/chrome_constants.h" | 44 #include "chrome/common/chrome_constants.h" |
| 44 #include "chrome/common/chrome_paths.h" | 45 #include "chrome/common/chrome_paths.h" |
| 45 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 46 #include "chromeos/chromeos_switches.h" | 47 #include "chromeos/chromeos_switches.h" |
| 47 #include "chromeos/dbus/cryptohome_client.h" | 48 #include "chromeos/dbus/cryptohome_client.h" |
| 48 #include "chromeos/disks/disk_mount_manager.h" | 49 #include "chromeos/disks/disk_mount_manager.h" |
| 49 #include "chromeos/system/fake_statistics_provider.h" | 50 #include "chromeos/system/fake_statistics_provider.h" |
| 50 #include "chromeos/system/statistics_provider.h" | 51 #include "chromeos/system/statistics_provider.h" |
| 51 #include "components/signin/core/common/signin_pref_names.h" | 52 #include "components/signin/core/common/signin_pref_names.h" |
| 52 #include "content/public/browser/browser_thread.h" | 53 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/notification_observer.h" | 54 #include "content/public/browser/notification_observer.h" |
| 54 #include "content/public/browser/notification_registrar.h" | 55 #include "content/public/browser/notification_registrar.h" |
| 55 #include "content/public/browser/notification_service.h" | 56 #include "content/public/browser/notification_service.h" |
| 57 #include "content/public/browser/web_ui.h" |
| 56 #include "content/public/test/browser_test_utils.h" | 58 #include "content/public/test/browser_test_utils.h" |
| 57 #include "extensions/browser/app_window/app_window.h" | 59 #include "extensions/browser/app_window/app_window.h" |
| 58 #include "extensions/browser/app_window/app_window_registry.h" | 60 #include "extensions/browser/app_window/app_window_registry.h" |
| 59 #include "extensions/browser/app_window/native_app_window.h" | 61 #include "extensions/browser/app_window/native_app_window.h" |
| 60 #include "extensions/browser/extension_system.h" | 62 #include "extensions/browser/extension_system.h" |
| 61 #include "extensions/components/native_app_window/native_app_window_views.h" | 63 #include "extensions/components/native_app_window/native_app_window_views.h" |
| 62 #include "extensions/test/extension_test_message_listener.h" | 64 #include "extensions/test/extension_test_message_listener.h" |
| 63 #include "extensions/test/result_catcher.h" | 65 #include "extensions/test/result_catcher.h" |
| 64 #include "google_apis/gaia/gaia_constants.h" | 66 #include "google_apis/gaia/gaia_constants.h" |
| 65 #include "google_apis/gaia/gaia_switches.h" | 67 #include "google_apis/gaia/gaia_switches.h" |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // app launching process itself. | 590 // app launching process itself. |
| 589 scoped_ptr<base::AutoLock> LockFileThread() { | 591 scoped_ptr<base::AutoLock> LockFileThread() { |
| 590 scoped_ptr<base::Lock> lock(new base::Lock); | 592 scoped_ptr<base::Lock> lock(new base::Lock); |
| 591 scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(*lock)); | 593 scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(*lock)); |
| 592 content::BrowserThread::PostTask( | 594 content::BrowserThread::PostTask( |
| 593 content::BrowserThread::FILE, FROM_HERE, | 595 content::BrowserThread::FILE, FROM_HERE, |
| 594 base::Bind(&LockAndUnlock, base::Passed(&lock))); | 596 base::Bind(&LockAndUnlock, base::Passed(&lock))); |
| 595 return auto_lock.Pass(); | 597 return auto_lock.Pass(); |
| 596 } | 598 } |
| 597 | 599 |
| 600 void MakeCrosSettingsPermanentlyUntrusted() { |
| 601 policy::DevicePolicyCrosTestHelper().InstallOwnerKey(); |
| 602 DeviceSettingsService::Get()->OwnerKeySet(true); |
| 603 } |
| 604 |
| 598 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } | 605 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } |
| 599 | 606 |
| 600 void set_test_app_id(const std::string& test_app_id) { | 607 void set_test_app_id(const std::string& test_app_id) { |
| 601 test_app_id_ = test_app_id; | 608 test_app_id_ = test_app_id; |
| 602 } | 609 } |
| 603 const std::string& test_app_id() const { return test_app_id_; } | 610 const std::string& test_app_id() const { return test_app_id_; } |
| 604 void set_test_app_version(const std::string& version) { | 611 void set_test_app_version(const std::string& version) { |
| 605 test_app_version_ = version; | 612 test_app_version_ = version; |
| 606 } | 613 } |
| 607 const std::string& test_app_version() const { return test_app_version_; } | 614 const std::string& test_app_version() const { return test_app_version_; } |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 // Show kiosk enable screen again. | 1054 // Show kiosk enable screen again. |
| 1048 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 1055 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
| 1049 base::StringValue("kiosk_enable")); | 1056 base::StringValue("kiosk_enable")); |
| 1050 | 1057 |
| 1051 // And it should show up. | 1058 // And it should show up. |
| 1052 content::WindowedNotificationObserver( | 1059 content::WindowedNotificationObserver( |
| 1053 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, | 1060 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, |
| 1054 content::NotificationService::AllSources()).Wait(); | 1061 content::NotificationService::AllSources()).Wait(); |
| 1055 } | 1062 } |
| 1056 | 1063 |
| 1064 IN_PROC_BROWSER_TEST_F(KioskTest, DoNotLaunchWhenUntrusted) { |
| 1065 PrepareAppLaunch(); |
| 1066 SimulateNetworkOnline(); |
| 1067 |
| 1068 // Make cros settings untrusted. |
| 1069 MakeCrosSettingsPermanentlyUntrusted(); |
| 1070 |
| 1071 // Check that the attempt to start a kiosk app fails with an error. |
| 1072 LaunchApp(test_app_id(), false); |
| 1073 bool ignored = false; |
| 1074 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1075 GetLoginUI()->GetWebContents(), |
| 1076 "if (cr.ui.Oobe.getInstance().errorMessageWasShownForTesting_) {" |
| 1077 " window.domAutomationController.send(true);" |
| 1078 "} else {" |
| 1079 " cr.ui.Oobe.showSignInError = function(" |
| 1080 " loginAttempts, message, link, helpId) {" |
| 1081 " window.domAutomationController.send(true);" |
| 1082 " };" |
| 1083 "}", |
| 1084 &ignored)); |
| 1085 } |
| 1086 |
| 1087 IN_PROC_BROWSER_TEST_F(KioskTest, NoAutoLaunchWhenUntrusted) { |
| 1088 EnableConsumerKioskMode(); |
| 1089 |
| 1090 // Wait for and confirm the auto-launch warning. |
| 1091 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| 1092 chromeos::WizardController* wizard_controller = |
| 1093 chromeos::WizardController::default_controller(); |
| 1094 ASSERT_TRUE(wizard_controller); |
| 1095 wizard_controller->AdvanceToScreen(WizardController::kNetworkScreenName); |
| 1096 ReloadAutolaunchKioskApps(); |
| 1097 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
| 1098 content::WindowedNotificationObserver( |
| 1099 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
| 1100 content::NotificationService::AllSources()).Wait(); |
| 1101 GetLoginUI()->CallJavascriptFunction( |
| 1102 "login.AutolaunchScreen.confirmAutoLaunchForTesting", |
| 1103 base::FundamentalValue(true)); |
| 1104 |
| 1105 // Make cros settings untrusted. |
| 1106 MakeCrosSettingsPermanentlyUntrusted(); |
| 1107 |
| 1108 // Check that the attempt to auto-launch a kiosk app fails with an error. |
| 1109 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 1110 } |
| 1111 |
| 1057 class KioskUpdateTest : public KioskTest { | 1112 class KioskUpdateTest : public KioskTest { |
| 1058 public: | 1113 public: |
| 1059 KioskUpdateTest() {} | 1114 KioskUpdateTest() {} |
| 1060 virtual ~KioskUpdateTest() {} | 1115 virtual ~KioskUpdateTest() {} |
| 1061 | 1116 |
| 1062 protected: | 1117 protected: |
| 1063 virtual void SetUp() override { | 1118 virtual void SetUp() override { |
| 1064 fake_disk_mount_manager_ = new KioskFakeDiskMountManager(); | 1119 fake_disk_mount_manager_ = new KioskFakeDiskMountManager(); |
| 1065 disks::DiskMountManager::InitializeForTesting(fake_disk_mount_manager_); | 1120 disks::DiskMountManager::InitializeForTesting(fake_disk_mount_manager_); |
| 1066 | 1121 |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 content::WindowedNotificationObserver( | 1877 content::WindowedNotificationObserver( |
| 1823 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1878 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
| 1824 content::NotificationService::AllSources()).Wait(); | 1879 content::NotificationService::AllSources()).Wait(); |
| 1825 | 1880 |
| 1826 // Wait for the wallpaper to load. | 1881 // Wait for the wallpaper to load. |
| 1827 WaitForWallpaper(); | 1882 WaitForWallpaper(); |
| 1828 EXPECT_TRUE(wallpaper_loaded()); | 1883 EXPECT_TRUE(wallpaper_loaded()); |
| 1829 } | 1884 } |
| 1830 | 1885 |
| 1831 } // namespace chromeos | 1886 } // namespace chromeos |
| OLD | NEW |