Commit d9b4aa78 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Remove NOTIFICATION_KIOSK_APP_LAUNCHED

Replace it's usages (in tests) with a new KioskAppManagerObserver
method.

BUG=None

Change-Id: I45b569ed23bc69ac0d4888959769828453b3ed3d
Reviewed-on: https://chromium-review.googlesource.com/862242Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530699}
parent 8b6cd640
...@@ -318,8 +318,6 @@ enum NotificationType { ...@@ -318,8 +318,6 @@ enum NotificationType {
// NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE // NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE
// 4. Boot into retail mode // 4. Boot into retail mode
// NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE // NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE
// 5. Boot into kiosk mode
// NOTIFICATION_KIOSK_APP_LAUNCHED
NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
// Send when kiosk auto-launch warning screen is visible. // Send when kiosk auto-launch warning screen is visible.
...@@ -340,9 +338,6 @@ enum NotificationType { ...@@ -340,9 +338,6 @@ enum NotificationType {
// Sent when kiosk app list is loaded in UI. // Sent when kiosk app list is loaded in UI.
NOTIFICATION_KIOSK_APPS_LOADED, NOTIFICATION_KIOSK_APPS_LOADED,
// Sent when a kiosk app is launched.
NOTIFICATION_KIOSK_APP_LAUNCHED,
// Sent when the user list has changed. // Sent when the user list has changed.
NOTIFICATION_USER_LIST_CHANGED, NOTIFICATION_USER_LIST_CHANGED,
......
...@@ -316,6 +316,9 @@ void KioskAppManager::InitSession(Profile* profile, ...@@ -316,6 +316,9 @@ void KioskAppManager::InitSession(Profile* profile,
app_session_ = CreateAppSession(); app_session_ = CreateAppSession();
if (app_session_) if (app_session_)
app_session_->Init(profile, app_id); app_session_->Init(profile, app_id);
for (auto& observer : observers_)
observer.OnKioskSessionInitialized();
} }
bool KioskAppManager::GetSwitchesForSessionRestore( bool KioskAppManager::GetSwitchesForSessionRestore(
......
...@@ -33,6 +33,10 @@ class KioskAppManagerObserver { ...@@ -33,6 +33,10 @@ class KioskAppManagerObserver {
// |success| indicates if all the updates are completed successfully. // |success| indicates if all the updates are completed successfully.
virtual void OnKioskAppExternalUpdateComplete(bool success) {} virtual void OnKioskAppExternalUpdateComplete(bool success) {}
// Called when kiosk app session initialization is complete - i.e. when
// KioskAppManager::InitSession() is called.
virtual void OnKioskSessionInitialized() {}
protected: protected:
virtual ~KioskAppManagerObserver() {} virtual ~KioskAppManagerObserver() {}
}; };
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/app_mode/kiosk_diagnosis_runner.h" #include "chrome/browser/chromeos/app_mode/kiosk_diagnosis_runner.h"
#include "chrome/browser/chromeos/app_mode/startup_app_launcher_update_checker.h" #include "chrome/browser/chromeos/app_mode/startup_app_launcher_update_checker.h"
...@@ -27,7 +26,6 @@ ...@@ -27,7 +26,6 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "components/crx_file/id_util.h" #include "components/crx_file/id_util.h"
#include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
...@@ -392,11 +390,6 @@ void StartupAppLauncher::LaunchApp() { ...@@ -392,11 +390,6 @@ void StartupAppLauncher::LaunchApp() {
KioskAppManager::Get()->InitSession(profile_, app_id_); KioskAppManager::Get()->InitSession(profile_, app_id_);
session_manager::SessionManager::Get()->SessionStarted(); session_manager::SessionManager::Get()->SessionStarted();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
if (diagnostic_mode_) if (diagnostic_mode_)
KioskDiagnosisRunner::Run(profile_, app_id_); KioskDiagnosisRunner::Run(profile_, app_id_);
......
...@@ -259,6 +259,25 @@ void SetPlatformVersion(const std::string& platform_version) { ...@@ -259,6 +259,25 @@ void SetPlatformVersion(const std::string& platform_version) {
base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, base::Time::Now()); base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, base::Time::Now());
} }
class KioskSessionInitializedWaiter : public KioskAppManagerObserver {
public:
KioskSessionInitializedWaiter() : scoped_observer_(this) {
scoped_observer_.Add(KioskAppManager::Get());
}
~KioskSessionInitializedWaiter() override = default;
void Wait() { run_loop_.Run(); }
// KioskAppManagerObserver:
void OnKioskSessionInitialized() override { run_loop_.Quit(); }
private:
ScopedObserver<KioskAppManager, KioskAppManagerObserver> scoped_observer_;
base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(KioskSessionInitializedWaiter);
};
// Helper functions for CanConfigureNetwork mock. // Helper functions for CanConfigureNetwork mock.
class ScopedCanConfigureNetwork { class ScopedCanConfigureNetwork {
public: public:
...@@ -629,10 +648,7 @@ class KioskTest : public OobeBaseTest { ...@@ -629,10 +648,7 @@ class KioskTest : public OobeBaseTest {
"launchData.isKioskSession = true", false); "launchData.isKioskSession = true", false);
// Wait for the Kiosk App to launch. // Wait for the Kiosk App to launch.
content::WindowedNotificationObserver( KioskSessionInitializedWaiter().Wait();
chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
content::NotificationService::AllSources())
.Wait();
// Default profile switches to app profile after app is launched. // Default profile switches to app profile after app is launched.
Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
...@@ -2202,11 +2218,7 @@ IN_PROC_BROWSER_TEST_F(KioskEnterpriseTest, EnterpriseKioskApp) { ...@@ -2202,11 +2218,7 @@ IN_PROC_BROWSER_TEST_F(KioskEnterpriseTest, EnterpriseKioskApp) {
PrepareAppLaunch(); PrepareAppLaunch();
LaunchApp(kTestEnterpriseKioskApp, false); LaunchApp(kTestEnterpriseKioskApp, false);
// Wait for the Kiosk App to launch. KioskSessionInitializedWaiter().Wait();
content::WindowedNotificationObserver(
chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
content::NotificationService::AllSources())
.Wait();
// Check installer status. // Check installer status.
EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, EXPECT_EQ(chromeos::KioskAppLaunchError::NONE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment