| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chrome_browser_main.h" | 9 #include "chrome/browser/chrome_browser_main.h" |
| 10 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 10 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
| 11 #include "chrome/browser/chrome_content_browser_client.h" | 11 #include "chrome/browser/chrome_content_browser_client.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
| 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 15 #include "chrome/browser/chromeos/login/app_launch_controller.h" |
| 15 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 16 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 16 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 17 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 17 #include "chrome/browser/chromeos/login/webui_login_display.h" | 18 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 18 #include "chrome/browser/chromeos/login/wizard_controller.h" | 19 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/extension_system.h" | 21 #include "chrome/browser/extensions/extension_system.h" |
| 21 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
| 22 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Used to add an observer to NotificationService after it's created. | 108 // Used to add an observer to NotificationService after it's created. |
| 108 class KioskAppLaunchScenarioHandler : public TestBrowserMainExtraParts { | 109 class KioskAppLaunchScenarioHandler : public TestBrowserMainExtraParts { |
| 109 public: | 110 public: |
| 110 KioskAppLaunchScenarioHandler() {} | 111 KioskAppLaunchScenarioHandler() {} |
| 111 | 112 |
| 112 virtual ~KioskAppLaunchScenarioHandler() {} | 113 virtual ~KioskAppLaunchScenarioHandler() {} |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 // ChromeBrowserMainExtraParts implementation. | 116 // ChromeBrowserMainExtraParts implementation. |
| 116 virtual void PreEarlyInitialization() OVERRIDE { | 117 virtual void PreEarlyInitialization() OVERRIDE { |
| 117 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | |
| 118 content::NotificationService::AllSources()); | |
| 119 registrar_.Add(this, chrome::NOTIFICATION_KIOSK_APPS_LOADED, | 118 registrar_.Add(this, chrome::NOTIFICATION_KIOSK_APPS_LOADED, |
| 120 content::NotificationService::AllSources()); | 119 content::NotificationService::AllSources()); |
| 121 registrar_.Add(this, chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, | 120 registrar_.Add(this, chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, |
| 122 content::NotificationService::AllSources()); | 121 content::NotificationService::AllSources()); |
| 123 } | 122 } |
| 124 | 123 |
| 125 // Overridden from content::NotificationObserver: | 124 // Overridden from content::NotificationObserver: |
| 126 virtual void Observe(int type, | 125 virtual void Observe(int type, |
| 127 const content::NotificationSource& source, | 126 const content::NotificationSource& source, |
| 128 const content::NotificationDetails& details) OVERRIDE { | 127 const content::NotificationDetails& details) OVERRIDE { |
| 129 if (type == chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE) { | 128 if (type == chrome::NOTIFICATION_KIOSK_APPS_LOADED) { |
| 130 LOG(INFO) << "NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE"; | |
| 131 SetupSigninScreen(); | |
| 132 } else if (type == chrome::NOTIFICATION_KIOSK_APPS_LOADED) { | |
| 133 LOG(INFO) << "chrome::NOTIFICATION_KIOSK_APPS_LOADED"; | 129 LOG(INFO) << "chrome::NOTIFICATION_KIOSK_APPS_LOADED"; |
| 134 content::WebUI* web_ui = static_cast<chromeos::LoginDisplayHostImpl*>( | 130 content::WebUI* web_ui = static_cast<chromeos::LoginDisplayHostImpl*>( |
| 135 chromeos::LoginDisplayHostImpl::default_host())-> | 131 chromeos::LoginDisplayHostImpl::default_host())-> |
| 136 GetOobeUI()->web_ui(); | 132 GetOobeUI()->web_ui(); |
| 137 web_ui->CallJavascriptFunction("login.AppsMenuButton.runAppForTesting", | 133 web_ui->CallJavascriptFunction("login.AppsMenuButton.runAppForTesting", |
| 138 base::StringValue(kTestKioskApp)); | 134 base::StringValue(kTestKioskApp)); |
| 139 } else if (type == chrome::NOTIFICATION_KIOSK_APP_LAUNCHED) { | 135 } else if (type == chrome::NOTIFICATION_KIOSK_APP_LAUNCHED) { |
| 140 LOG(INFO) << "chrome::NOTIFICATION_KIOSK_APP_LAUNCHED"; | 136 LOG(INFO) << "chrome::NOTIFICATION_KIOSK_APP_LAUNCHED"; |
| 141 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 137 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 142 content::NotificationService::AllSources()); | 138 content::NotificationService::AllSources()); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 | 533 |
| 538 // KioskTest overrides. | 534 // KioskTest overrides. |
| 539 virtual void InitializeKioskTest() OVERRIDE { | 535 virtual void InitializeKioskTest() OVERRIDE { |
| 540 content_browser_client_.reset( | 536 content_browser_client_.reset( |
| 541 new TestContentBrowserClient(TestContentBrowserClient::KioskAppLaunch)); | 537 new TestContentBrowserClient(TestContentBrowserClient::KioskAppLaunch)); |
| 542 } | 538 } |
| 543 }; | 539 }; |
| 544 | 540 |
| 545 IN_PROC_BROWSER_TEST_P(KioskLaunchTest, InstallAndLaunchApp) { | 541 IN_PROC_BROWSER_TEST_P(KioskLaunchTest, InstallAndLaunchApp) { |
| 546 EnableConsumerKioskMode(); | 542 EnableConsumerKioskMode(); |
| 543 chromeos::AppLaunchController::SkipSplashWaitForTesting(); |
| 547 // Start UI, find menu entry for this app and launch it. | 544 // Start UI, find menu entry for this app and launch it. |
| 548 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 545 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| 549 chromeos::WizardController* wizard_controller = | 546 chromeos::WizardController* wizard_controller = |
| 550 chromeos::WizardController::default_controller(); | 547 chromeos::WizardController::default_controller(); |
| 551 CHECK(wizard_controller); | 548 CHECK(wizard_controller); |
| 552 wizard_controller->SkipToLoginForTesting(); | 549 wizard_controller->SkipToLoginForTesting(); |
| 553 | 550 |
| 554 ReloadKioskApps(); | 551 ReloadKioskApps(); |
| 555 | 552 |
| 556 // The first loop exits after we receive NOTIFICATION_KIOSK_APP_LAUNCHED | 553 // The first loop exits after we receive NOTIFICATION_KIOSK_APP_LAUNCHED |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 | 842 |
| 846 INSTANTIATE_TEST_CASE_P(KioskEnableCancelTestInstantiation, | 843 INSTANTIATE_TEST_CASE_P(KioskEnableCancelTestInstantiation, |
| 847 KioskEnableCancelTest, | 844 KioskEnableCancelTest, |
| 848 testing::Bool()); | 845 testing::Bool()); |
| 849 | 846 |
| 850 INSTANTIATE_TEST_CASE_P(KioskEnableConfirmedTestInstantiation, | 847 INSTANTIATE_TEST_CASE_P(KioskEnableConfirmedTestInstantiation, |
| 851 KioskEnableConfirmedTest, | 848 KioskEnableConfirmedTest, |
| 852 testing::Bool()); | 849 testing::Bool()); |
| 853 | 850 |
| 854 } // namespace chromeos | 851 } // namespace chromeos |
| OLD | NEW |