From eb7089ad459643fd6e0c2b1def42fbb8e1c50284 Mon Sep 17 00:00:00 2001 From: khmel Date: Tue, 7 Mar 2017 17:20:37 -0800 Subject: [PATCH] [Merge M58] Fix crash whem window created before shelf creation. This fix crash due race condition in multi-profile mode in case some window is created before shelf initialized. Easiest way to repo is on fresh machine first sign-in to public account, sign-out, sign-in to corp Google account. ARC++ OptIn window should pop-up on start. NOTRY=true NOPRESUBMIT=true TBR=skuhne@chromium.org BUG=684860 TEST=Manually, no more crashes. Review-Url: https://codereview.chromium.org/2736993002 Cr-Commit-Position: refs/heads/master@{#455315} (cherry picked from commit a89719254bb2ba3420b3eefb14b811f711532f99) Review-Url: https://codereview.chromium.org/2738773003 Cr-Commit-Position: refs/branch-heads/3029@{#55} Cr-Branched-From: 939b32ee5ba05c396eef3fd992822fcca9a2e262-refs/heads/master@{#454471} --- .../multi_profile_app_window_launcher_controller.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_controller.cc index 6d7f1cab3feb6..f57876e6db826 100644 --- a/chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_controller.cc @@ -6,6 +6,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" #include "components/signin/core/account_id/account_id.h" @@ -15,7 +16,14 @@ MultiProfileAppWindowLauncherController:: MultiProfileAppWindowLauncherController(ChromeLauncherController* owner) - : ExtensionAppWindowLauncherController(owner) {} + : ExtensionAppWindowLauncherController(owner) { + // We might have already active windows. + extensions::AppWindowRegistry* registry = + extensions::AppWindowRegistry::Get(owner->profile()); + app_window_list_.insert(app_window_list_.end(), + registry->app_windows().begin(), + registry->app_windows().end()); +} MultiProfileAppWindowLauncherController:: ~MultiProfileAppWindowLauncherController() { @@ -61,6 +69,7 @@ void MultiProfileAppWindowLauncherController::AdditionalUserAddedToSession( // Each users AppWindowRegistry needs to be observed. extensions::AppWindowRegistry* registry = extensions::AppWindowRegistry::Get(profile); + DCHECK(registry->app_windows().empty()); multi_user_registry_.push_back(registry); registry->AddObserver(this); }