Commit cd12853a authored by Muyuan Li's avatar Muyuan Li Committed by Commit Bot

move c/b/chromeos/assistant to c/b/ui/ash/.

Bug: 798569
Test: Manual build and test
Change-Id: I8050699311b1cb5c19859178ee5dcedebfa2538f
Reviewed-on: https://chromium-review.googlesource.com/1054700
Commit-Queue: Muyuan Li <muyuanli@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558066}
parent b11895a7
......@@ -4,7 +4,6 @@
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//chromeos/assistant/assistant.gni")
import("//extensions/buildflags/buildflags.gni")
import("//media/media_options.gni")
import("//printing/buildflags/buildflags.gni")
......@@ -71,7 +70,6 @@ source_set("chromeos") {
"//chromeos:biod_proto",
"//chromeos:cryptohome_proto",
"//chromeos:cryptohome_signkey_proto",
"//chromeos/assistant:buildflags",
"//chromeos/components/drivefs",
"//chromeos/components/proximity_auth",
"//chromeos/components/proximity_auth/logging",
......@@ -1721,23 +1719,6 @@ source_set("chromeos") {
"extensions/wallpaper_private_api.h",
]
if (enable_cros_assistant) {
deps += [
"//ash/public/cpp",
"//chromeos/services/assistant:lib",
"//chromeos/services/assistant/public/mojom",
]
sources += [
"assistant/assistant_card_renderer.cc",
"assistant/assistant_card_renderer.h",
"assistant/assistant_client.cc",
"assistant/assistant_client.h",
"assistant/platform_audio_input_host.cc",
"assistant/platform_audio_input_host.h",
]
}
if (use_cups) {
sources += [
"printing/cups_print_job_manager_impl.cc",
......
include_rules = [
# Add browser dependencies explicitly.
"-chrome",
"+chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h",
"+chrome/browser/chromeos/assistant",
"+chrome/browser/chromeos/profiles/profile_helper.h",
"-chromeos/services",
"+chromeos/services/assistant/public",
]
......@@ -186,10 +186,6 @@
#include "components/rlz/rlz_tracker.h"
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chrome/browser/chromeos/assistant/assistant_client.h"
#endif
namespace chromeos {
namespace {
......@@ -711,11 +707,6 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
arc_voice_interaction_controller_client_ =
std::make_unique<arc::VoiceInteractionControllerClient>();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
if (chromeos::switches::IsAssistantEnabled())
assistant_client_ = std::make_unique<assistant::AssistantClient>();
#endif
chromeos::ResourceReporter::GetInstance()->StartMonitoring(
task_manager::TaskManagerInterface::GetTaskManager());
......@@ -1089,10 +1080,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
arc_voice_interaction_controller_client_.reset();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
assistant_client_.reset();
#endif
// Unregister CrosSettings observers before CrosSettings is destroyed.
shutdown_policy_forwarder_.reset();
......
......@@ -12,7 +12,6 @@
#include "chrome/browser/chrome_browser_main_linux.h"
#include "chrome/browser/chromeos/external_metrics.h"
#include "chrome/browser/memory/memory_kills_monitor.h"
#include "chromeos/assistant/buildflags.h"
#include "chromeos/system/version_loader.h"
class NotificationPlatformBridge;
......@@ -44,11 +43,6 @@ namespace default_app_order {
class ExternalLoader;
}
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
namespace assistant {
class AssistantClient;
} // namespace assistant
#endif
namespace internal {
class DBusPreEarlyInit;
......@@ -116,10 +110,6 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
std::unique_ptr<arc::ArcServiceLauncher> arc_service_launcher_;
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
std::unique_ptr<assistant::AssistantClient> assistant_client_;
#endif
std::unique_ptr<arc::VoiceInteractionControllerClient>
arc_voice_interaction_controller_client_;
......
......@@ -31,7 +31,6 @@
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chromeos/assistant/buildflags.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/dbus_thread_manager.h"
......@@ -48,11 +47,6 @@
#include "services/identity/public/cpp/identity_manager.h"
#include "services/service_manager/public/cpp/connector.h"
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chrome/browser/chromeos/assistant/assistant_client.h"
#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
#endif
namespace chromeos {
namespace {
......@@ -130,13 +124,6 @@ void StartUserSession(Profile* user_profile, const std::string& login_user_id) {
}
arc::ArcServiceLauncher::Get()->OnPrimaryUserProfilePrepared(user_profile);
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
if (chromeos::switches::IsAssistantEnabled()) {
assistant::AssistantClient::Get()->Start(
content::BrowserContext::GetConnectorFor(user_profile));
}
#endif
// Send the PROFILE_PREPARED notification and call SessionStarted()
// so that the Launcher and other Profile dependent classes are created.
content::NotificationService::current()->Notify(
......
......@@ -92,7 +92,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/pref_names.h"
#include "chromeos/assistant/buildflags.h"
#include "chromeos/cert_loader.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
......@@ -142,10 +141,6 @@
#include "components/rlz/rlz_tracker.h"
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chrome/browser/chromeos/assistant/assistant_client.h"
#endif
namespace chromeos {
namespace {
......@@ -1410,13 +1405,6 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) {
}
arc::ArcServiceLauncher::Get()->OnPrimaryUserProfilePrepared(profile);
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
if (chromeos::switches::IsAssistantEnabled()) {
assistant::AssistantClient::Get()->Start(
content::BrowserContext::GetConnectorFor(profile));
}
#endif
TetherService* tether_service = TetherService::Get(profile);
if (tether_service)
tether_service->StartTetherIfPossible();
......
......@@ -8,6 +8,7 @@ import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//build/split_static_library.gni")
import("//chrome/common/features.gni")
import("//chromeos/assistant/assistant.gni")
import("//components/nacl/features.gni")
import("//components/offline_pages/buildflags/features.gni")
import("//components/signin/features.gni")
......@@ -914,6 +915,7 @@ split_static_library("ui") {
"//chrome/common",
"//chrome/common/net",
"//chrome/installer/util:with_no_strings",
"//chromeos/assistant:buildflags",
"//components/about_ui",
"//components/account_id",
"//components/app_modal",
......@@ -3690,6 +3692,23 @@ split_static_library("ui") {
}
}
if (enable_cros_assistant) {
deps += [
"//ash/public/cpp",
"//chromeos/services/assistant:lib",
"//chromeos/services/assistant/public/mojom",
]
sources += [
"ash/assistant/assistant_card_renderer.cc",
"ash/assistant/assistant_card_renderer.h",
"ash/assistant/assistant_client.cc",
"ash/assistant/assistant_client.h",
"ash/assistant/platform_audio_input_host.cc",
"ash/assistant/platform_audio_input_host.h",
]
}
if (enable_extensions) {
deps += [
"//apps",
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/assistant/assistant_card_renderer.h"
#include "chrome/browser/ui/ash/assistant/assistant_card_renderer.h"
#include <memory>
......@@ -21,9 +21,6 @@
#include "ui/views/controls/webview/webview.h"
#include "ui/views/view.h"
namespace chromeos {
namespace assistant {
namespace {
constexpr char kDataUriPrefix[] = "data:text/html,";
......@@ -160,6 +157,3 @@ void AssistantCardRenderer::ReleaseAll(
for (const base::UnguessableToken& id_token : id_tokens)
assistant_cards_.erase(id_token);
}
} // namespace assistant
} // namespace chromeos
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ASSISTANT_ASSISTANT_CARD_RENDERER_H_
#define CHROME_BROWSER_CHROMEOS_ASSISTANT_ASSISTANT_CARD_RENDERER_H_
#ifndef CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_CARD_RENDERER_H_
#define CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_CARD_RENDERER_H_
#include <unordered_map>
#include <vector>
......@@ -19,9 +19,6 @@ namespace service_manager {
class Connector;
} // namespace service_manager
namespace chromeos {
namespace assistant {
namespace {
class AssistantCard;
} // namespace
......@@ -59,7 +56,4 @@ class AssistantCardRenderer : public ash::mojom::AssistantCardRenderer {
DISALLOW_COPY_AND_ASSIGN(AssistantCardRenderer);
};
} // namespace assistant
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_ASSISTANT_ASSISTANT_CARD_RENDERER_H_
#endif // CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_CARD_RENDERER_H_
......@@ -2,19 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/assistant/assistant_client.h"
#include "chrome/browser/ui/ash/assistant/assistant_client.h"
#include <utility>
#include "ash/public/interfaces/voice_interaction_controller.mojom.h"
#include "chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h"
#include "chrome/browser/chromeos/assistant/assistant_card_renderer.h"
#include "chrome/browser/ui/ash/assistant/assistant_card_renderer.h"
#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
namespace chromeos {
namespace assistant {
namespace {
// Owned by ChromeBrowserMainChromeOS:
AssistantClient* g_instance = nullptr;
......@@ -37,12 +34,16 @@ AssistantClient::~AssistantClient() {
g_instance = nullptr;
}
void AssistantClient::Start(service_manager::Connector* connector) {
connector->BindInterface(mojom::kServiceName, &assistant_connection_);
mojom::AudioInputPtr audio_input_ptr;
void AssistantClient::MaybeInit(service_manager::Connector* connector) {
if (initialized_)
return;
initialized_ = true;
connector->BindInterface(chromeos::assistant::mojom::kServiceName,
&assistant_connection_);
chromeos::assistant::mojom::AudioInputPtr audio_input_ptr;
audio_input_binding_.Bind(mojo::MakeRequest(&audio_input_ptr));
mojom::ClientPtr client_ptr;
chromeos::assistant::mojom::ClientPtr client_ptr;
client_binding_.Bind(mojo::MakeRequest(&client_ptr));
assistant_connection_->Init(std::move(client_ptr),
......@@ -56,6 +57,3 @@ void AssistantClient::OnAssistantStatusChanged(bool running) {
running ? ash::mojom::VoiceInteractionState::RUNNING
: ash::mojom::VoiceInteractionState::STOPPED);
}
} // namespace assistant
} // namespace chromeos
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ASSISTANT_ASSISTANT_CLIENT_H_
#define CHROME_BROWSER_CHROMEOS_ASSISTANT_ASSISTANT_CLIENT_H_
#ifndef CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_CLIENT_H_
#define CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_CLIENT_H_
#include <memory>
#include "base/macros.h"
#include "chrome/browser/chromeos/assistant/platform_audio_input_host.h"
#include "chrome/browser/ui/ash/assistant/platform_audio_input_host.h"
#include "chromeos/services/assistant/public/mojom/assistant.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
......@@ -16,38 +16,34 @@ namespace service_manager {
class Connector;
} // namespace service_manager
namespace chromeos {
namespace assistant {
class AssistantCardRenderer;
// Class to handle all assistant in-browser-process functionalities.
class AssistantClient : mojom::Client {
class AssistantClient : chromeos::assistant::mojom::Client {
public:
static AssistantClient* Get();
AssistantClient();
~AssistantClient() override;
void Start(service_manager::Connector* connector);
void MaybeInit(service_manager::Connector* connector);
// assistant::mojom::Client overrides:
void OnAssistantStatusChanged(bool running) override;
private:
mojo::Binding<mojom::Client> client_binding_;
mojo::Binding<chromeos::assistant::mojom::Client> client_binding_;
mojom::AssistantPlatformPtr assistant_connection_;
mojo::Binding<mojom::AudioInput> audio_input_binding_;
chromeos::assistant::mojom::AssistantPlatformPtr assistant_connection_;
mojo::Binding<chromeos::assistant::mojom::AudioInput> audio_input_binding_;
PlatformAudioInputHost audio_input_;
std::unique_ptr<AssistantCardRenderer> assistant_card_renderer_;
bool initialized_ = false;
DISALLOW_COPY_AND_ASSIGN(AssistantClient);
};
} // namespace assistant
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_ASSISTANT_ASSISTANT_CLIENT_H_
#endif // CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_CLIENT_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/assistant/platform_audio_input_host.h"
#include "chrome/browser/ui/ash/assistant/platform_audio_input_host.h"
#include <utility>
......@@ -17,9 +17,6 @@
#include "media/base/audio_sample_types.h"
#include "media/base/channel_layout.h"
namespace chromeos {
namespace assistant {
namespace {
void NotifyDataAvailable(const base::WeakPtr<PlatformAudioInputHost>& host,
......@@ -57,14 +54,13 @@ class PlatformAudioInputHost::Writer
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&::chromeos::assistant::NotifyDataAvailable, host_,
std::move(buffer), data->frames(), capture_time));
base::BindOnce(&::NotifyDataAvailable, host_, std::move(buffer),
data->frames(), capture_time));
}
void Close() override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&::chromeos::assistant::NotifyAudioClosed, host_));
task_runner_->PostTask(FROM_HERE,
base::BindOnce(&::NotifyAudioClosed, host_));
}
private:
......@@ -115,7 +111,7 @@ PlatformAudioInputHost::~PlatformAudioInputHost() {
}
void PlatformAudioInputHost::AddObserver(
mojom::AudioInputObserverPtr observer) {
chromeos::assistant::mojom::AudioInputObserverPtr observer) {
observers_.AddPtr(std::move(observer));
if (!recording_) {
audio_input_controller_->Record();
......@@ -142,6 +138,3 @@ void PlatformAudioInputHost::NotifyAudioClosed() {
observers_.ForAllPtrs([](auto* observer) { observer->OnAudioInputClosed(); });
observers_.CloseAll();
}
} // namespace assistant
} // namespace chromeos
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ASSISTANT_PLATFORM_AUDIO_INPUT_HOST_H_
#define CHROME_BROWSER_CHROMEOS_ASSISTANT_PLATFORM_AUDIO_INPUT_HOST_H_
#ifndef CHROME_BROWSER_UI_ASH_ASSISTANT_PLATFORM_AUDIO_INPUT_HOST_H_
#define CHROME_BROWSER_UI_ASH_ASSISTANT_PLATFORM_AUDIO_INPUT_HOST_H_
#include <memory>
#include <vector>
......@@ -19,17 +19,15 @@ namespace media {
class AudioInputController;
} // namespace media
namespace chromeos {
namespace assistant {
// Interacts with AudioController and forwards audio input stream to assistant.
class PlatformAudioInputHost : public mojom::AudioInput {
class PlatformAudioInputHost : public chromeos::assistant::mojom::AudioInput {
public:
PlatformAudioInputHost();
~PlatformAudioInputHost() override;
// mojom::AudioInput overrides:
void AddObserver(mojom::AudioInputObserverPtr observer) override;
void AddObserver(
chromeos::assistant::mojom::AudioInputObserverPtr observer) override;
void NotifyDataAvailable(const std::vector<int32_t>& data,
int32_t frames,
......@@ -43,7 +41,8 @@ class PlatformAudioInputHost : public mojom::AudioInput {
std::unique_ptr<Writer> sync_writer_;
std::unique_ptr<EventHandler> event_handler_;
scoped_refptr<media::AudioInputController> audio_input_controller_;
mojo::InterfacePtrSet<mojom::AudioInputObserver> observers_;
mojo::InterfacePtrSet<chromeos::assistant::mojom::AudioInputObserver>
observers_;
bool recording_ = false;
......@@ -52,7 +51,4 @@ class PlatformAudioInputHost : public mojom::AudioInput {
DISALLOW_COPY_AND_ASSIGN(PlatformAudioInputHost);
};
} // namespace assistant
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_ASSISTANT_PLATFORM_AUDIO_INPUT_HOST_H_
#endif // CHROME_BROWSER_UI_ASH_ASSISTANT_PLATFORM_AUDIO_INPUT_HOST_H_
......@@ -64,6 +64,10 @@
#include "chrome/browser/exo_parts.h"
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chrome/browser/ui/ash/assistant/assistant_client.h"
#endif
namespace {
void PushProcessCreationTimeToAsh() {
......@@ -242,6 +246,10 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() {
chromeos::NetworkHandler::Get()->network_state_handler(),
chromeos::NetworkHandler::Get()->auto_connect_handler());
}
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
assistant_client_ = std::make_unique<AssistantClient>();
#endif
}
void ChromeBrowserMainExtraPartsAsh::PostBrowserStart() {
......@@ -263,7 +271,9 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
night_light_client_.reset();
data_promo_notification_.reset();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
assistant_client_.reset();
#endif
chrome_launcher_controller_initializer_.reset();
wallpaper_controller_client_.reset();
......
......@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/common/buildflags.h"
#include "chromeos/assistant/buildflags.h"
namespace aura {
class UserActivityForwarder;
......@@ -49,6 +50,10 @@ class WallpaperControllerClient;
class ExoParts;
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
class AssistantClient;
#endif
namespace internal {
class ChromeLauncherControllerInitializer;
}
......@@ -105,6 +110,10 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
std::unique_ptr<ExoParts> exo_parts_;
#endif
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
std::unique_ptr<AssistantClient> assistant_client_;
#endif
// Initialized in PostProfileInit if ash config == MASH:
std::unique_ptr<ChromeShellContentState> chrome_shell_content_state_;
......
......@@ -33,6 +33,8 @@
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/pref_names.h"
#include "chromeos/assistant/buildflags.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "components/prefs/pref_change_registrar.h"
......@@ -48,6 +50,10 @@
#include "ui/chromeos/resources/grit/ui_chromeos_resources.h"
#include "ui/gfx/image/image_skia.h"
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chrome/browser/ui/ash/assistant/assistant_client.h"
#endif
using session_manager::Session;
using session_manager::SessionManager;
using session_manager::SessionState;
......@@ -455,6 +461,15 @@ void SessionControllerClient::OnSessionStateChanged() {
primary_user_session_sent_ = true;
SendUserSession(*UserManager::Get()->GetPrimaryUser());
SendUserSessionOrder();
#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
// Assistant is initialized only once when primary user logs in.
if (chromeos::switches::IsAssistantEnabled()) {
AssistantClient::Get()->MaybeInit(
content::BrowserContext::GetConnectorFor(
ProfileManager::GetPrimaryUserProfile()));
}
#endif
}
SendSessionInfoIfChanged();
......
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