Commit 6b2e55d9 authored by Taras Antoshchuk's avatar Taras Antoshchuk Committed by Commit Bot

OOBE: Fix profile initialization on supervision screen

SupervisionTransitionScreenHandler::profile_ field was initialized in
::Initialize method. By the time profile_ was used in ::Show, current
active profile was already changed, causing screen handler to interact
with wrong profile. This CL moves initialization of profile_ field, to
ensure that screen handler interacts with actual current active profile.

Bug: 1105127
Test: manual gellerization/degellerization flow
Change-Id: Ib2563d3fd7d0910e1b11c3a4962905601950a07e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2356424Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Taras Antoshchuk <tantoshchuk@google.com>
Cr-Commit-Position: refs/heads/master@{#799086}
parent 231e0a51
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h" #include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/supervision_transition_screen.h" #include "chrome/browser/chromeos/login/screens/supervision_transition_screen.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/login_screen_client.h" #include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/ash/system_tray_client.h" #include "chrome/browser/ui/ash/system_tray_client.h"
...@@ -90,7 +91,10 @@ void SupervisionTransitionScreenHandler::Show() { ...@@ -90,7 +91,10 @@ void SupervisionTransitionScreenHandler::Show() {
&SupervisionTransitionScreenHandler::OnSupervisionTransitionFailed, &SupervisionTransitionScreenHandler::OnSupervisionTransitionFailed,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
registrar_.Init(profile_->GetPrefs()); Profile* profile = ProfileManager::GetActiveUserProfile();
DCHECK(!ProfileHelper::IsSigninProfile(profile));
registrar_.Init(profile->GetPrefs());
registrar_.Add( registrar_.Add(
arc::prefs::kArcSupervisionTransition, arc::prefs::kArcSupervisionTransition,
base::BindRepeating( base::BindRepeating(
...@@ -106,7 +110,7 @@ void SupervisionTransitionScreenHandler::Show() { ...@@ -106,7 +110,7 @@ void SupervisionTransitionScreenHandler::Show() {
base::DictionaryValue data; base::DictionaryValue data;
data.SetBoolean("isRemovingSupervision", data.SetBoolean("isRemovingSupervision",
arc::GetSupervisionTransition(profile_) == arc::GetSupervisionTransition(profile) ==
arc::ArcSupervisionTransition::CHILD_TO_REGULAR); arc::ArcSupervisionTransition::CHILD_TO_REGULAR);
ShowScreenWithData(kScreenId, &data); ShowScreenWithData(kScreenId, &data);
} }
...@@ -118,8 +122,6 @@ base::OneShotTimer* SupervisionTransitionScreenHandler::GetTimerForTesting() { ...@@ -118,8 +122,6 @@ base::OneShotTimer* SupervisionTransitionScreenHandler::GetTimerForTesting() {
} }
void SupervisionTransitionScreenHandler::Initialize() { void SupervisionTransitionScreenHandler::Initialize() {
profile_ = ProfileManager::GetPrimaryUserProfile();
if (!screen_ || !show_on_init_) if (!screen_ || !show_on_init_)
return; return;
......
...@@ -82,9 +82,6 @@ class SupervisionTransitionScreenHandler ...@@ -82,9 +82,6 @@ class SupervisionTransitionScreenHandler
base::TimeTicks screen_shown_time_; base::TimeTicks screen_shown_time_;
// The primary user profile.
Profile* profile_ = nullptr;
// Timer used to exit the page when timeout reaches. // Timer used to exit the page when timeout reaches.
base::OneShotTimer timer_; base::OneShotTimer timer_;
......
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