0

[PhoneHub][Exo] Pass phone name to eche bubble

Add phone name on top of eche bubble to make it clear it's streaming
from phone.

Screenshot: https://screenshot.googleplex.com/6TDsEeZdhP6WYW2.png

Test:manually tested

Fixed: b/261607895
Change-Id: I4e2099bce466defa7802a1382bb39cd04e558e75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4083804
Reviewed-by: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: Abbas Nayebi <nayebi@google.com>
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Commit-Queue: Pu Shi <pushi@google.com>
Cr-Commit-Position: refs/heads/main@{#1081074}
This commit is contained in:
Pu Shi
2022-12-08 20:21:22 +00:00
committed by Chromium LUCI CQ
parent 257921c265
commit 939bc06314
24 changed files with 117 additions and 68 deletions

@ -5716,6 +5716,9 @@ New install
<message name="IDS_ASH_ECHE_TOAST_TABLET_MODE_NOT_SUPPORTED" desc="A toast message that we show when user tries to switch to tablet mode.">
Can't stream apps in tablet mode. Try again in laptop mode.
</message>
<message name="ID_ASH_ECHE_APP_STREAMING_BUBBLE_TITLE" desc="The title appear on the top of app streaming bubble">
From <ph name="PHONE_NAME">$1<ex>Pixel 7</ex></ph>
</message>
<!-- Deferred update dialog -->
<message name="IDS_DEFERRED_UPDATE_DIALOG_TITLE" desc="Title of the dialog for notifying deferred update available to be applied.">

@ -0,0 +1 @@
04e3969ffe01e445482699f9d7b97e1f6d823a1a

@ -5067,7 +5067,8 @@ TEST_F(ShelfLayoutManagerWithEcheTest, AutoHideShelfWithEcheHidden) {
gfx::ImageSkia image_skia = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
image_skia.MakeThreadSafe();
status_area->eche_tray()->LoadBubble(GURL("http://google.com"),
gfx::Image(image_skia), u"app 1");
gfx::Image(image_skia), u"app 1",
u"your phone");
status_area->eche_tray()->ShowBubble();
UpdateAutoHideStateNow();

@ -395,7 +395,8 @@ void EcheTray::SetIcon(const gfx::Image& icon,
bool EcheTray::LoadBubble(const GURL& url,
const gfx::Image& icon,
const std::u16string& visible_name) {
const std::u16string& visible_name,
const std::u16string& phone_name) {
if (Shell::Get()->IsInTabletMode()) {
ash::ToastManager::Get()->Show(ash::ToastData(
kEcheTrayTabletModeNotSupportedId,
@ -417,7 +418,7 @@ bool EcheTray::LoadBubble(const GURL& url,
ShowBubble();
return true;
}
InitBubble();
InitBubble(phone_name);
StartLoadingAnimation();
auto* phone_hub_tray = GetPhoneHubTray();
if (phone_hub_tray) {
@ -477,7 +478,7 @@ void EcheTray::HideBubble() {
shelf()->UpdateAutoHideState();
}
void EcheTray::InitBubble() {
void EcheTray::InitBubble(const std::u16string& phone_name) {
base::UmaHistogramEnumeration(
"Eche.StreamEvent",
eche_app::mojom::StreamStatus::kStreamStatusInitializing);
@ -504,7 +505,8 @@ void EcheTray::InitBubble() {
bubble_view->SetCanActivate(true);
bubble_view->SetBorder(views::CreateEmptyBorder(kBubblePadding));
auto* header_view = bubble_view->AddChildView(CreateBubbleHeaderView());
auto* header_view =
bubble_view->AddChildView(CreateBubbleHeaderView(phone_name));
// We need the header be always visible with the same size.
static_cast<views::BoxLayout*>(bubble_view->GetLayoutManager())
@ -585,7 +587,8 @@ void EcheTray::OnArrowBackActivated() {
}
}
std::unique_ptr<views::View> EcheTray::CreateBubbleHeaderView() {
std::unique_ptr<views::View> EcheTray::CreateBubbleHeaderView(
const std::u16string& phone_name) {
auto header = std::make_unique<views::View>();
header->SetLayoutManager(std::make_unique<views::FlexLayout>())
->SetInteriorMargin(gfx::Insets::VH(0, kHeaderHorizontalInteriorMargins))
@ -601,10 +604,11 @@ std::unique_ptr<views::View> EcheTray::CreateBubbleHeaderView() {
kEcheArrowBackIcon, IDS_APP_ACCNAME_BACK));
views::Label* title = header->AddChildView(std::make_unique<views::Label>(
std::u16string(), views::style::CONTEXT_DIALOG_TITLE,
views::style::STYLE_PRIMARY,
l10n_util::GetStringFUTF16(ID_ASH_ECHE_APP_STREAMING_BUBBLE_TITLE,
phone_name),
views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY,
gfx::DirectionalityMode::DIRECTIONALITY_AS_URL));
title->SetMultiLine(true);
title->SetMultiLine(false);
title->SetAllowCharacterBreak(true);
title->SetProperty(
views::kFlexBehaviorKey,
@ -612,7 +616,7 @@ std::unique_ptr<views::View> EcheTray::CreateBubbleHeaderView() {
views::MaximumFlexSizeRule::kUnbounded,
/*adjust_height_for_width =*/true)
.WithWeight(1));
title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
title->SetHorizontalAlignment(gfx::ALIGN_CENTER);
// Add minimize button
minimize_button_ = header->AddChildView(CreateButton(

@ -182,7 +182,8 @@ class ASH_EXPORT EcheTray : public TrayBackgroundView,
// Returns true if the bubble is loaded or initialized successfully.
bool LoadBubble(const GURL& url,
const gfx::Image& icon,
const std::u16string& visible_name);
const std::u16string& visible_name,
const std::u16string& phone_name);
// Destroys the view inclusing the web view.
// Note: `CloseBubble` only hides the view.
@ -199,7 +200,7 @@ class ASH_EXPORT EcheTray : public TrayBackgroundView,
// Set up the params and init the bubble.
// Note: This function makes the bubble active and makes the
// TrayBackgroundView's background inkdrop activate.
void InitBubble();
void InitBubble(const std::u16string& phone_name);
// Starts graceful close to ensure the connection resource is released before
// the window is closed.
@ -243,7 +244,8 @@ class ASH_EXPORT EcheTray : public TrayBackgroundView,
// Creates the header of the bubble that includes a back arrow,
// close, and minimize buttons.
std::unique_ptr<views::View> CreateBubbleHeaderView();
std::unique_ptr<views::View> CreateBubbleHeaderView(
const std::u16string& phone_name);
void StopLoadingAnimation();
void StartLoadingAnimation();

@ -139,7 +139,7 @@ TEST_F(EcheTrayTest, EcheTrayShowBubbleAndTapTwice) {
eche_tray()->SetVisiblePreferred(true);
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(eche_tray()->is_active());
@ -176,7 +176,7 @@ TEST_F(EcheTrayTest, EcheTrayShowBubbleAndTapTwice) {
TEST_F(EcheTrayTest, EcheTrayIconResize) {
eche_tray()->SetVisiblePreferred(true);
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
int image_width = phone_hub_tray()
@ -196,7 +196,7 @@ TEST_F(EcheTrayTest, EcheTrayIconResize) {
TEST_F(EcheTrayTest, OnAnyBubbleVisibilityChanged) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -215,7 +215,7 @@ TEST_F(EcheTrayTest, OnAnyBubbleVisibilityChanged) {
// should be ignored.
TEST_F(EcheTrayTest, OnAnyBubbleVisibilityChanged_SameWidget) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -232,7 +232,7 @@ TEST_F(EcheTrayTest, OnAnyBubbleVisibilityChanged_SameWidget) {
// visible parameter is false, hence we should not do anything.
TEST_F(EcheTrayTest, OnAnyBubbleVisibilityChanged_NonVisible) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -254,7 +254,7 @@ TEST_F(EcheTrayTest, EcheTrayCreatesBubbleButHideFirst) {
// Allow us to create the bubble but it is not visible until we need this
// bubble to show up.
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
EXPECT_FALSE(eche_tray()->is_active());
EXPECT_TRUE(eche_tray()->get_bubble_wrapper_for_test());
@ -282,7 +282,7 @@ TEST_F(EcheTrayTest, EcheTrayCreatesBubbleButStreamStatusChanged) {
// Allow us to create the bubble but it is not visible until we need this
// bubble to show up.
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
EXPECT_FALSE(eche_tray()->is_active());
EXPECT_TRUE(eche_tray()->get_bubble_wrapper_for_test());
@ -310,7 +310,7 @@ TEST_F(EcheTrayTest, EcheTrayCreatesBubbleButStreamStatusChanged) {
TEST_F(EcheTrayTest, EcheTrayMinimizeButtonClicked) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -327,7 +327,7 @@ TEST_F(EcheTrayTest, EcheTrayCloseButtonClicked) {
ResetUnloadWebContent();
eche_tray()->SetGracefulCloseCallback(base::BindOnce(&UnloadWebContent));
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
ClickButton(eche_tray()->GetCloseButtonForTesting());
@ -340,7 +340,7 @@ TEST_F(EcheTrayTest, EcheTrayBackButtonClicked) {
eche_tray()->SetGracefulGoBackCallback(
base::BindRepeating(&WebContentGoBack));
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
ClickButton(eche_tray()->GetArrowBackButtonForTesting());
@ -354,7 +354,7 @@ TEST_F(EcheTrayTest, EcheTrayBackButtonClicked) {
TEST_F(EcheTrayTest, AcceleratorKeyHandled_Minimize) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -381,7 +381,7 @@ TEST_F(EcheTrayTest, AcceleratorKeyHandled_Ctrl_W) {
ResetUnloadWebContent();
eche_tray()->SetGracefulCloseCallback(base::BindOnce(&UnloadWebContent));
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -396,7 +396,7 @@ TEST_F(EcheTrayTest, AcceleratorKeyHandled_Ctrl_W) {
TEST_F(EcheTrayTest, AcceleratorKeyHandled_Ctrl_C) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -414,7 +414,7 @@ TEST_F(EcheTrayTest, AcceleratorKeyHandled_Ctrl_C) {
TEST_F(EcheTrayTest, AcceleratorKeyHandled_Ctrl_V) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -432,7 +432,7 @@ TEST_F(EcheTrayTest, AcceleratorKeyHandled_Ctrl_V) {
TEST_F(EcheTrayTest, AcceleratorKeyHandled_Ctrl_X) {
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -453,7 +453,7 @@ TEST_F(EcheTrayTest, AcceleratorKeyHandled_BROWSER_BACK_KEY) {
eche_tray()->SetGracefulGoBackCallback(
base::BindRepeating(&WebContentGoBack));
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
GetEventGenerator()->PressKey(ui::KeyboardCode::VKEY_BROWSER_BACK, 0);
@ -465,7 +465,7 @@ TEST_F(EcheTrayTest, AcceleratorKeyHandled_Esc) {
ResetUnloadWebContent();
eche_tray()->SetGracefulCloseCallback(base::BindOnce(&UnloadWebContent));
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_TRUE(
@ -482,7 +482,7 @@ TEST_F(EcheTrayTest, EcheTrayOnDisplayConfigurationChanged) {
UpdateDisplay("800x600");
gfx::Size expected_eche_size = eche_tray()->CalculateSizeForEche();
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_EQ(expected_eche_size.width(),
@ -506,7 +506,7 @@ TEST_F(EcheTrayTest, EcheTrayOnDisplayConfigurationChanged) {
TEST_F(EcheTrayTest, EcheTrayKeyboardShowHideUpdateBubbleBounds) {
gfx::Size expected_eche_size = eche_tray()->CalculateSizeForEche();
eche_tray()->LoadBubble(GURL("http://google.com"), CreateTestImage(),
u"app 1");
u"app 1", u"your phone");
eche_tray()->ShowBubble();
EXPECT_EQ(expected_eche_size.width(),

@ -391,7 +391,8 @@ TEST_F(PhoneHubUiControllerTest, TimerExpiresBluetoothDisconnectedView) {
TEST_F(PhoneHubUiControllerTest, HandleBubbleOpenedShouldCloseEcheBubble) {
EcheTray* eche_tray =
StatusAreaWidgetTestHelper::GetStatusAreaWidget()->eche_tray();
eche_tray->LoadBubble(GURL("http://google.com"), gfx::Image(), u"app 1");
eche_tray->LoadBubble(GURL("http://google.com"), gfx::Image(), u"app 1",
u"your phone");
eche_tray->ShowBubble();
EXPECT_TRUE(
eche_tray->get_bubble_wrapper_for_test()->bubble_view()->GetVisible());

@ -705,7 +705,8 @@ TEST_F(StatusAreaWidgetEcheTest, EcheTrayShowHide) {
gfx::ImageSkia image_skia = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
image_skia.MakeThreadSafe();
status_area->eche_tray()->LoadBubble(GURL("http://google.com"),
gfx::Image(image_skia), u"app 1");
gfx::Image(image_skia), u"app 1",
u"your phone");
status_area->eche_tray()->ShowBubble();
// Auto-hidden shelf would be forced to be visible.

@ -81,7 +81,8 @@ class EcheAlertGeneratorTest : public testing::Test {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {
const gfx::Image& icon,
const std::u16string& phone_name) {
// Do nothing.
}

@ -37,7 +37,8 @@ void LaunchEcheAppFunction(const absl::optional<int64_t>& notification_id,
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {}
const gfx::Image& icon,
const std::u16string& phone_name) {}
void LaunchNotificationFunction(
const absl::optional<std::u16string>& title,

@ -21,6 +21,7 @@ EcheNotificationClickHandler::EcheNotificationClickHandler(
: feature_status_provider_(feature_status_provider),
launch_app_helper_(launch_app_helper) {
handler_ = phone_hub_manager->GetNotificationInteractionHandler();
phone_model_ = phone_hub_manager->GetPhoneModel();
feature_status_provider_->AddObserver(this);
if (handler_ && IsClickable(feature_status_provider_->GetStatus())) {
handler_->AddNotificationClickHandler(this);
@ -51,7 +52,8 @@ void EcheNotificationClickHandler::HandleNotificationClick(
launch_app_helper_->LaunchEcheApp(
notification_id, app_metadata.package_name,
app_metadata.visible_app_name, app_metadata.user_id,
app_metadata.icon);
app_metadata.icon,
phone_model_->phone_name().value_or(std::u16string()));
break;
case LaunchAppHelper::AppLaunchProhibitedReason::kDisabledByScreenLock:
launch_app_helper_->ShowNotification(

@ -11,6 +11,7 @@
#include "chromeos/ash/components/phonehub/notification.h"
#include "chromeos/ash/components/phonehub/notification_click_handler.h"
#include "chromeos/ash/components/phonehub/notification_interaction_handler.h"
#include "chromeos/ash/components/phonehub/phone_model.h"
namespace ash {
@ -47,6 +48,7 @@ class EcheNotificationClickHandler : public phonehub::NotificationClickHandler,
bool IsClickable(FeatureStatus status);
phonehub::NotificationInteractionHandler* handler_;
phonehub::PhoneModel* phone_model_;
FeatureStatusProvider* feature_status_provider_;
LaunchAppHelper* launch_app_helper_;
bool is_click_handler_set_ = false;

@ -64,7 +64,8 @@ class EcheNotificationClickHandlerTest : public testing::Test {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {
const gfx::Image& icon,
const std::u16string& phone_name) {
num_app_launch_++;
}

@ -87,7 +87,9 @@ void EcheRecentAppClickHandler::OnRecentAppClicked(
launch_app_helper_->LaunchEcheApp(
/*notification_id=*/absl::nullopt, app_metadata.package_name,
app_metadata.visible_app_name, app_metadata.user_id,
app_metadata.icon);
app_metadata.icon,
phone_hub_manager_->GetPhoneModel()->phone_name().value_or(
std::u16string()));
break;
case LaunchAppHelper::AppLaunchProhibitedReason::kDisabledByScreenLock:
launch_app_helper_->ShowNotification(

@ -67,7 +67,8 @@ class EcheRecentAppClickHandlerTest : public testing::Test {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {
const gfx::Image& icon,
const std::u16string& phone_name) {
package_name_ = package_name;
visible_name_ = visible_name;
user_id_ = user_id.value();

@ -39,11 +39,12 @@ namespace eche_app {
void LaunchBubble(const GURL& url,
const gfx::Image& icon,
const std::u16string& visible_name,
const std::u16string& phone_name,
EcheTray::GracefulCloseCallback graceful_close_callback,
EcheTray::GracefulGoBackCallback graceful_go_back_callback) {
auto* eche_tray = ash::GetEcheTray();
DCHECK(eche_tray);
eche_tray->LoadBubble(url, icon, visible_name);
eche_tray->LoadBubble(url, icon, visible_name, phone_name);
eche_tray->SetGracefulCloseCallback(std::move(graceful_close_callback));
eche_tray->SetGracefulGoBackCallback(std::move(graceful_go_back_callback));
}

@ -25,6 +25,7 @@ namespace eche_app {
void LaunchBubble(const GURL& url,
const gfx::Image& icon,
const std::u16string& visible_name,
const std::u16string& phone_name,
EcheTray::GracefulCloseCallback graceful_close_callback,
EcheTray::GracefulGoBackCallback graceful_go_back_callback);

@ -96,7 +96,7 @@ class EcheTrayStreamStatusObserverTest : public AshTestBase {
};
TEST_F(EcheTrayStreamStatusObserverTest, LaunchBubble) {
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1",
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1", u"your phone",
base::BindOnce(&GracefulCloseFunction),
base::BindRepeating(&GracefulGoBackFunction));
@ -114,7 +114,7 @@ TEST_F(EcheTrayStreamStatusObserverTest, OnStartStreaming) {
// The bubble should not be created if LaunchBubble be called before.
EXPECT_FALSE(eche_tray()->get_bubble_wrapper_for_test());
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1",
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1", u"your phone",
base::BindOnce(&GracefulCloseFunction),
base::BindRepeating(&GracefulGoBackFunction));
@ -134,7 +134,7 @@ TEST_F(EcheTrayStreamStatusObserverTest, OnStartStreaming) {
}
TEST_F(EcheTrayStreamStatusObserverTest, OnStreamStatusChanged) {
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1",
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1", u"your phone",
base::BindOnce(&GracefulCloseFunction),
base::BindRepeating(&GracefulGoBackFunction));
OnStreamStatusChanged(mojom::StreamStatus::kStreamStatusStarted);
@ -156,7 +156,7 @@ TEST_F(EcheTrayStreamStatusObserverTest,
StartGracefulCloseWhenFeatureStatusToIneligible) {
ResetUnloadWebContent();
SetStatus(FeatureStatus::kConnecting);
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1",
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1", u"your phone",
base::BindOnce(&GracefulCloseFunction),
base::BindRepeating(&GracefulGoBackFunction));
OnStreamStatusChanged(mojom::StreamStatus::kStreamStatusStarted);
@ -179,7 +179,7 @@ TEST_F(EcheTrayStreamStatusObserverTest,
StartGracefulCloseWhenFeatureDependent) {
ResetUnloadWebContent();
SetStatus(FeatureStatus::kConnecting);
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1",
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1", u"your phone",
base::BindOnce(&GracefulCloseFunction),
base::BindRepeating(&GracefulGoBackFunction));
OnStreamStatusChanged(mojom::StreamStatus::kStreamStatusStarted);
@ -202,7 +202,7 @@ TEST_F(EcheTrayStreamStatusObserverTest,
StartGracefulCloseWhenFeatureDisabled) {
ResetUnloadWebContent();
SetStatus(FeatureStatus::kConnecting);
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1",
LaunchBubble(GURL("http://google.com"), gfx::Image(), u"app 1", u"your phone",
base::BindOnce(&GracefulCloseFunction),
base::BindRepeating(&GracefulGoBackFunction));
OnStreamStatusChanged(mojom::StreamStatus::kStreamStatusStarted);

@ -87,9 +87,10 @@ void LaunchAppHelper::LaunchEcheApp(absl::optional<int64_t> notification_id,
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) const {
const gfx::Image& icon,
const std::u16string& phone_name) const {
launch_eche_app_function_.Run(notification_id, package_name, visible_name,
user_id, icon);
user_id, icon, phone_name);
}
} // namespace eche_app

@ -68,7 +68,8 @@ class LaunchAppHelper {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon)>;
const gfx::Image& icon,
const std::u16string& phone_name)>;
// Enum representing potential reasons why an app is forbidden to launch.
enum class AppLaunchProhibitedReason {
@ -112,7 +113,8 @@ class LaunchAppHelper {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) const;
const gfx::Image& icon,
const std::u16string& phone_name) const;
private:
bool IsScreenLockRequired() const;

@ -31,7 +31,8 @@ class Callback {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {
const gfx::Image& icon,
const std::u16string& phone_name) {
launchEcheApp_ = true;
}
@ -111,9 +112,10 @@ class LaunchAppHelperTest : public ash::AshTestBase {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {
const gfx::Image& icon,
const std::u16string& phone_name) {
launch_app_helper_->LaunchEcheApp(notification_id, package_name,
visible_name, user_id, icon);
visible_name, user_id, icon, phone_name);
}
void ShowNotification(
@ -173,9 +175,10 @@ TEST_F(LaunchAppHelperTest, LaunchEcheApp) {
const std::string package_name = "package_name";
const std::u16string visible_name = u"visible_name";
const absl::optional<int64_t> user_id = 0;
const std::u16string phone_name = u"your phone";
LaunchEcheApp(notification_id, package_name, visible_name, user_id,
gfx::Image());
gfx::Image(), phone_name);
EXPECT_TRUE(Callback::getLaunchEcheApp());
}

@ -67,6 +67,7 @@ void LaunchWebApp(const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon,
const std::u16string& phone_name,
Profile* profile) {
EcheAppManagerFactory::GetInstance()->SetLastLaunchedAppInfo(
LaunchedAppInfo::Builder()
@ -74,6 +75,7 @@ void LaunchWebApp(const std::string& package_name,
.SetVisibleName(visible_name)
.SetUserId(user_id)
.SetIcon(icon)
.SetPhoneName(phone_name)
.Build());
std::u16string url;
// Use hash mark(#) to send params to webui so we don't need to reload the
@ -101,7 +103,7 @@ void LaunchWebApp(const std::string& package_name,
}
const auto gurl = GURL(url);
return LaunchBubble(gurl, icon, visible_name,
return LaunchBubble(gurl, icon, visible_name, phone_name,
base::BindOnce(&EnsureStreamClose, profile),
base::BindRepeating(&StreamGoBack, profile));
}
@ -112,7 +114,7 @@ void RelaunchLast(Profile* profile) {
EcheAppManagerFactory::LaunchEcheApp(
profile, absl::nullopt, last_launched_app_info->package_name(),
last_launched_app_info->visible_name(), last_launched_app_info->user_id(),
last_launched_app_info->icon());
last_launched_app_info->icon(), last_launched_app_info->phone_name());
}
} // namespace
@ -121,11 +123,13 @@ LaunchedAppInfo::~LaunchedAppInfo() = default;
LaunchedAppInfo::LaunchedAppInfo(const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {
const gfx::Image& icon,
const std::u16string& phone_name) {
package_name_ = package_name;
visible_name_ = visible_name;
user_id_ = user_id;
icon_ = icon;
phone_name_ = phone_name;
}
LaunchedAppInfo::Builder::Builder() = default;
@ -192,9 +196,10 @@ void EcheAppManagerFactory::LaunchEcheApp(
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon) {
const gfx::Image& icon,
const std::u16string& phone_name) {
LaunchWebApp(package_name, notification_id, visible_name, user_id, icon,
profile);
phone_name, profile);
EcheAppManagerFactory::GetInstance()
->CloseConnectionOrLaunchErrorNotifications();
}

@ -29,8 +29,8 @@ class LaunchedAppInfo {
~Builder();
std::unique_ptr<LaunchedAppInfo> Build() {
return base::WrapUnique(
new LaunchedAppInfo(package_name_, visible_name_, user_id_, icon_));
return base::WrapUnique(new LaunchedAppInfo(
package_name_, visible_name_, user_id_, icon_, phone_name_));
}
Builder& SetPackageName(const std::string& package_name) {
package_name_ = package_name;
@ -52,11 +52,17 @@ class LaunchedAppInfo {
return *this;
}
Builder& SetPhoneName(const std::u16string& phone_name) {
phone_name_ = phone_name;
return *this;
}
private:
std::string package_name_;
std::u16string visible_name_;
absl::optional<int64_t> user_id_;
gfx::Image icon_;
std::u16string phone_name_;
};
LaunchedAppInfo() = delete;
@ -68,18 +74,21 @@ class LaunchedAppInfo {
std::u16string visible_name() const { return visible_name_; }
absl::optional<int64_t> user_id() const { return user_id_; }
gfx::Image icon() const { return icon_; }
std::u16string phone_name() const { return phone_name_; }
protected:
LaunchedAppInfo(const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon);
const gfx::Image& icon,
const std::u16string& phone_name);
private:
std::string package_name_;
std::u16string visible_name_;
absl::optional<int64_t> user_id_;
gfx::Image icon_;
std::u16string phone_name_;
};
// Factory to create a single EcheAppManager.
@ -101,7 +110,8 @@ class EcheAppManagerFactory : public ProfileKeyedServiceFactory {
const std::string& package_name,
const std::u16string& visible_name,
const absl::optional<int64_t>& user_id,
const gfx::Image& icon);
const gfx::Image& icon,
const std::u16string& phone_name);
void SetLastLaunchedAppInfo(
std::unique_ptr<LaunchedAppInfo> last_launched_app_info);

@ -158,9 +158,10 @@ TEST_F(EcheAppManagerFactoryTest, LaunchEcheApp) {
const int64_t user_id = 1;
const char16_t visible_name_1[] = u"Fake App 1";
const char package_name_1[] = "com.fakeapp1";
const char16_t phone_name[] = u"your phone";
EcheAppManagerFactory::LaunchEcheApp(
GetProfile(), /*notification_id=*/absl::nullopt, package_name_1,
visible_name_1, user_id, gfx::Image());
visible_name_1, user_id, gfx::Image(), phone_name);
// Wait for Eche Tray to load Eche Web to complete
base::RunLoop().RunUntilIdle();
// Eche icon should be visible after launch.
@ -172,7 +173,7 @@ TEST_F(EcheAppManagerFactoryTest, LaunchEcheApp) {
const char package_name_2[] = "com.fakeapp2";
EcheAppManagerFactory::LaunchEcheApp(
GetProfile(), /*notification_id=*/absl::nullopt, package_name_2,
visible_name_2, user_id, gfx::Image());
visible_name_2, user_id, gfx::Image(), phone_name);
// Wait for Eche Tray to load Eche Web to complete
base::RunLoop().RunUntilIdle();
EXPECT_EQ(widget, eche_tray()->GetBubbleWidget());
@ -183,10 +184,11 @@ TEST_F(EcheAppManagerFactoryTest, LaunchedAppInfo) {
const std::u16string visible_name = u"Fake App";
const std::string package_name = "com.fakeapp";
const gfx::Image icon = gfx::test::CreateImage(100, 100);
const std::u16string phone_name = u"your phone";
EcheAppManagerFactory::LaunchEcheApp(
GetProfile(), /*notification_id=*/absl::nullopt, package_name,
visible_name, user_id, icon);
visible_name, user_id, icon, phone_name);
std::unique_ptr<LaunchedAppInfo> launched_app_info =
EcheAppManagerFactory::GetInstance()->GetLastLaunchedAppInfo();
@ -205,9 +207,10 @@ TEST_F(EcheAppManagerFactoryWithBackgroundTest, LaunchEcheApp) {
const int64_t user_id = 1;
const char16_t visible_name[] = u"Fake App";
const char package_name[] = "com.fakeapp";
const char16_t phone_name[] = u"your phone";
EcheAppManagerFactory::LaunchEcheApp(
GetProfile(), /*notification_id=*/absl::nullopt, package_name,
visible_name, user_id, gfx::Image());
visible_name, user_id, gfx::Image(), phone_name);
// Wait for Eche Tray to load Eche Web to complete
base::RunLoop().RunUntilIdle();
// Eche tray should be visible when streaming is active, not ative when