Commit 235834ce authored by Xiaohui Chen's avatar Xiaohui Chen Committed by Commit Bot

assistant: refactor service init flow

* Pass in profile instead of mojom connector, this will guarantee the
  profile and connector always matches

Bug: 908919
Test: locally build and run
Change-Id: Iae0a73524456c108c75e1a21400d28a99afe6cd2
Reviewed-on: https://chromium-review.googlesource.com/c/1352769
Commit-Queue: Xiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611936}
parent b592282e
......@@ -1645,10 +1645,8 @@ bool UserSessionManager::InitializeUserSession(Profile* profile) {
if (start_session_type_ == PRIMARY_USER_SESSION) {
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
// Initialize Assistant early to be used in post login Oobe steps.
if (chromeos::switches::IsAssistantEnabled()) {
AssistantClient::Get()->MaybeInit(
content::BrowserContext::GetConnectorFor(profile));
}
if (chromeos::switches::IsAssistantEnabled())
AssistantClient::Get()->MaybeInit(profile);
#endif
UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow();
WizardController* oobe_controller = WizardController::default_controller();
......
......@@ -38,9 +38,8 @@ AssistantClient::~AssistantClient() {
g_instance = nullptr;
}
void AssistantClient::MaybeInit(service_manager::Connector* connector) {
if (arc::IsAssistantAllowedForProfile(
ProfileManager::GetActiveUserProfile()) !=
void AssistantClient::MaybeInit(Profile* profile) {
if (arc::IsAssistantAllowedForProfile(profile) !=
ash::mojom::AssistantAllowedState::ALLOWED) {
return;
}
......@@ -49,6 +48,7 @@ void AssistantClient::MaybeInit(service_manager::Connector* connector) {
return;
initialized_ = true;
auto* connector = content::BrowserContext::GetConnectorFor(profile);
connector->BindInterface(chromeos::assistant::mojom::kServiceName,
&assistant_connection_);
......
......@@ -12,10 +12,7 @@
#include "chromeos/services/assistant/public/mojom/assistant.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace service_manager {
class Connector;
} // namespace service_manager
class Profile;
class AssistantImageDownloader;
class AssistantSetup;
......@@ -27,7 +24,7 @@ class AssistantClient : chromeos::assistant::mojom::Client {
AssistantClient();
~AssistantClient() override;
void MaybeInit(service_manager::Connector* connector);
void MaybeInit(Profile* profile);
// assistant::mojom::Client overrides:
void OnAssistantStatusChanged(bool running) override;
......
......@@ -474,8 +474,7 @@ void SessionControllerClient::OnSessionStateChanged() {
// Assistant is initialized only once when primary user logs in.
if (chromeos::switches::IsAssistantEnabled()) {
AssistantClient::Get()->MaybeInit(
content::BrowserContext::GetConnectorFor(
ProfileManager::GetPrimaryUserProfile()));
ProfileManager::GetPrimaryUserProfile());
}
#endif
}
......
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