Commit 1823ac30 authored by Yue Li's avatar Yue Li Committed by Commit Bot

[Assistant Opt-in] Fix regression on first run OOBE locales

Bug: b/156405987
Test: Manual Test
Change-Id: I57c0c37ca7865f23df730e84167f9be6368dc33a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227900
Commit-Queue: Yue Li <updowndota@chromium.org>
Reviewed-by: default avatarJeroen Dhollander <jeroendh@google.com>
Cr-Commit-Position: refs/heads/master@{#776593}
parent 90ddc4bf
......@@ -194,15 +194,10 @@ void AssistantClientImpl::OnExtendedAccountInfoUpdated(
}
void AssistantClientImpl::OnUserProfileLoaded(const AccountId& account_id) {
// Initialize Assistant when primary user profile is loaded so that it could
// be used in post oobe steps. OnUserSessionStarted() is too late
// because it happens after post oobe steps
Profile* user_profile =
chromeos::ProfileHelper::Get()->GetProfileByAccountId(account_id);
if (!chromeos::ProfileHelper::IsPrimaryProfile(user_profile))
return;
MaybeInit(user_profile);
if (assistant_state_observer_.IsObservingSources() && !initialized_ &&
ash::AssistantState::Get()) {
assistant_state_observer_.Add(ash::AssistantState::Get());
}
}
void AssistantClientImpl::OnUserSessionStarted(bool is_primary_user) {
......@@ -214,3 +209,12 @@ void AssistantClientImpl::OnUserSessionStarted(bool is_primary_user) {
MaybeStartAssistantOptInFlow();
}
}
void AssistantClientImpl::OnAssistantFeatureAllowedChanged(
chromeos::assistant::AssistantAllowedState allowed_state) {
if (allowed_state != chromeos::assistant::AssistantAllowedState::ALLOWED)
return;
Profile* profile = ProfileManager::GetActiveUserProfile();
MaybeInit(profile);
}
......@@ -9,7 +9,9 @@
#include <vector>
#include "ash/public/cpp/assistant/assistant_client.h"
#include "ash/public/cpp/assistant/assistant_state.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "chrome/browser/ui/ash/assistant/device_actions.h"
#include "chromeos/services/assistant/public/cpp/assistant_client.h"
#include "chromeos/services/assistant/public/mojom/assistant.mojom-forward.h"
......@@ -32,7 +34,8 @@ class AssistantClientImpl : public ash::AssistantClient,
public chromeos::assistant::AssistantClient,
public content::NotificationObserver,
public signin::IdentityManager::Observer,
public session_manager::SessionManagerObserver {
public session_manager::SessionManagerObserver,
public ash::AssistantStateObserver {
public:
AssistantClientImpl();
~AssistantClientImpl() override;
......@@ -95,6 +98,10 @@ class AssistantClientImpl : public ash::AssistantClient,
void OnUserProfileLoaded(const AccountId& account_id) override;
void OnUserSessionStarted(bool is_primary_user) override;
// ash::AssistantStateObserver:
void OnAssistantFeatureAllowedChanged(
chromeos::assistant::AssistantAllowedState allowed_state) override;
std::unique_ptr<DeviceActions> device_actions_;
std::unique_ptr<chromeos::assistant::Service> service_;
std::unique_ptr<AssistantSetup> assistant_setup_;
......@@ -114,6 +121,9 @@ class AssistantClientImpl : public ash::AssistantClient,
Profile* profile_ = nullptr;
signin::IdentityManager* identity_manager_ = nullptr;
ScopedObserver<ash::AssistantStateBase, ash::AssistantStateObserver>
assistant_state_observer_{this};
DISALLOW_COPY_AND_ASSIGN(AssistantClientImpl);
};
......
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