| 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #include "content/public/browser/notification_details.h" | 96 #include "content/public/browser/notification_details.h" |
| 97 #include "content/public/browser/notification_service.h" | 97 #include "content/public/browser/notification_service.h" |
| 98 #include "content/public/browser/notification_source.h" | 98 #include "content/public/browser/notification_source.h" |
| 99 #include "content/public/browser/web_contents.h" | 99 #include "content/public/browser/web_contents.h" |
| 100 #include "content/public/browser/web_ui.h" | 100 #include "content/public/browser/web_ui.h" |
| 101 #include "content/public/test/browser_test_utils.h" | 101 #include "content/public/test/browser_test_utils.h" |
| 102 #include "content/public/test/test_utils.h" | 102 #include "content/public/test/test_utils.h" |
| 103 #include "crypto/rsa_private_key.h" | 103 #include "crypto/rsa_private_key.h" |
| 104 #include "extensions/browser/extension_system.h" | 104 #include "extensions/browser/extension_system.h" |
| 105 #include "extensions/browser/management_policy.h" | 105 #include "extensions/browser/management_policy.h" |
| 106 #include "extensions/browser/notification_types.h" |
| 106 #include "extensions/common/extension.h" | 107 #include "extensions/common/extension.h" |
| 107 #include "grit/chromium_strings.h" | 108 #include "grit/chromium_strings.h" |
| 108 #include "grit/generated_resources.h" | 109 #include "grit/generated_resources.h" |
| 109 #include "net/base/url_util.h" | 110 #include "net/base/url_util.h" |
| 110 #include "net/http/http_status_code.h" | 111 #include "net/http/http_status_code.h" |
| 111 #include "net/test/embedded_test_server/embedded_test_server.h" | 112 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 112 #include "net/test/embedded_test_server/http_request.h" | 113 #include "net/test/embedded_test_server/http_request.h" |
| 113 #include "net/test/embedded_test_server/http_response.h" | 114 #include "net/test/embedded_test_server/http_response.h" |
| 114 #include "net/url_request/test_url_fetcher_factory.h" | 115 #include "net/url_request/test_url_fetcher_factory.h" |
| 115 #include "net/url_request/url_fetcher_delegate.h" | 116 #include "net/url_request/url_fetcher_delegate.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 ASSERT_TRUE(host); | 717 ASSERT_TRUE(host); |
| 717 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); | 718 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); |
| 718 ASSERT_TRUE(oobe_ui); | 719 ASSERT_TRUE(oobe_ui); |
| 719 base::RunLoop run_loop; | 720 base::RunLoop run_loop; |
| 720 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); | 721 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); |
| 721 if (!oobe_ui_ready) | 722 if (!oobe_ui_ready) |
| 722 run_loop.Run(); | 723 run_loop.Run(); |
| 723 | 724 |
| 724 // Start listening for app/extension installation results. | 725 // Start listening for app/extension installation results. |
| 725 content::WindowedNotificationObserver hosted_app_observer( | 726 content::WindowedNotificationObserver hosted_app_observer( |
| 726 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 727 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
| 727 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); | 728 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); |
| 728 content::WindowedNotificationObserver extension_observer( | 729 content::WindowedNotificationObserver extension_observer( |
| 729 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 730 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 730 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); | 731 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); |
| 731 | 732 |
| 732 // Start login into the device-local account. | 733 // Start login into the device-local account. |
| 733 host->StartSignInScreen(LoginScreenContext()); | 734 host->StartSignInScreen(LoginScreenContext()); |
| 734 chromeos::ExistingUserController* controller = | 735 chromeos::ExistingUserController* controller = |
| 735 chromeos::ExistingUserController::current_controller(); | 736 chromeos::ExistingUserController::current_controller(); |
| 736 ASSERT_TRUE(controller); | 737 ASSERT_TRUE(controller); |
| 737 controller->LoginAsPublicAccount(user_id_1_); | 738 controller->LoginAsPublicAccount(user_id_1_); |
| 738 | 739 |
| 739 // Wait for the hosted app installation to succeed and the extension | 740 // Wait for the hosted app installation to succeed and the extension |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 ASSERT_TRUE(host); | 818 ASSERT_TRUE(host); |
| 818 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); | 819 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); |
| 819 ASSERT_TRUE(oobe_ui); | 820 ASSERT_TRUE(oobe_ui); |
| 820 base::RunLoop run_loop; | 821 base::RunLoop run_loop; |
| 821 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); | 822 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); |
| 822 if (!oobe_ui_ready) | 823 if (!oobe_ui_ready) |
| 823 run_loop.Run(); | 824 run_loop.Run(); |
| 824 | 825 |
| 825 // Start listening for app/extension installation results. | 826 // Start listening for app/extension installation results. |
| 826 content::WindowedNotificationObserver hosted_app_observer( | 827 content::WindowedNotificationObserver hosted_app_observer( |
| 827 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 828 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
| 828 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); | 829 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); |
| 829 content::WindowedNotificationObserver extension_observer( | 830 content::WindowedNotificationObserver extension_observer( |
| 830 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 831 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 831 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); | 832 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); |
| 832 | 833 |
| 833 // Start login into the device-local account. | 834 // Start login into the device-local account. |
| 834 host->StartSignInScreen(LoginScreenContext()); | 835 host->StartSignInScreen(LoginScreenContext()); |
| 835 chromeos::ExistingUserController* controller = | 836 chromeos::ExistingUserController* controller = |
| 836 chromeos::ExistingUserController::current_controller(); | 837 chromeos::ExistingUserController::current_controller(); |
| 837 ASSERT_TRUE(controller); | 838 ASSERT_TRUE(controller); |
| 838 controller->LoginAsPublicAccount(user_id_1_); | 839 controller->LoginAsPublicAccount(user_id_1_); |
| 839 | 840 |
| 840 // Wait for the hosted app installation to succeed and the extension | 841 // Wait for the hosted app installation to succeed and the extension |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 extension_system->management_policy()->UnregisterAllProviders(); | 1122 extension_system->management_policy()->UnregisterAllProviders(); |
| 1122 | 1123 |
| 1123 // Install and a platform app. | 1124 // Install and a platform app. |
| 1124 scoped_refptr<extensions::CrxInstaller> installer = | 1125 scoped_refptr<extensions::CrxInstaller> installer = |
| 1125 extensions::CrxInstaller::CreateSilent( | 1126 extensions::CrxInstaller::CreateSilent( |
| 1126 extension_system->extension_service()); | 1127 extension_system->extension_service()); |
| 1127 installer->set_allow_silent_install(true); | 1128 installer->set_allow_silent_install(true); |
| 1128 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); | 1129 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); |
| 1129 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); | 1130 installer->set_creation_flags(extensions::Extension::FROM_WEBSTORE); |
| 1130 content::WindowedNotificationObserver app_install_observer( | 1131 content::WindowedNotificationObserver app_install_observer( |
| 1131 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 1132 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| 1132 content::NotificationService::AllSources()); | 1133 content::NotificationService::AllSources()); |
| 1133 base::FilePath test_dir; | 1134 base::FilePath test_dir; |
| 1134 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 1135 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
| 1135 installer->InstallCrx(test_dir.Append(kPackagedAppCRXPath)); | 1136 installer->InstallCrx(test_dir.Append(kPackagedAppCRXPath)); |
| 1136 app_install_observer.Wait(); | 1137 app_install_observer.Wait(); |
| 1137 const extensions::Extension* app = | 1138 const extensions::Extension* app = |
| 1138 content::Details<const extensions::Extension>( | 1139 content::Details<const extensions::Extension>( |
| 1139 app_install_observer.details()).ptr(); | 1140 app_install_observer.details()).ptr(); |
| 1140 | 1141 |
| 1141 // Start the platform app, causing it to open a window. | 1142 // Start the platform app, causing it to open a window. |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 if (!IsSessionStarted()) { | 1400 if (!IsSessionStarted()) { |
| 1400 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, | 1401 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, |
| 1401 base::Bind(IsSessionStarted)).Wait(); | 1402 base::Bind(IsSessionStarted)).Wait(); |
| 1402 } | 1403 } |
| 1403 } | 1404 } |
| 1404 | 1405 |
| 1405 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, | 1406 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, |
| 1406 TermsOfServiceTest, testing::Bool()); | 1407 TermsOfServiceTest, testing::Bool()); |
| 1407 | 1408 |
| 1408 } // namespace policy | 1409 } // namespace policy |
| OLD | NEW |