Commit 4c90708b authored by Jazz Xu's avatar Jazz Xu Committed by Commit Bot

CrOS GMC: Don't navigate to main menu automatically.

This CL modifies media controls detailed view such that it won't
navigate back to main menu until user clicks the back button or close
the menu.

Bug: 1135212
Change-Id: Ic63984ba87e44ab85ca62ab83e71a8093ef62ca2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450312Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814263}
parent 19e9e967
...@@ -18,17 +18,13 @@ UnifiedMediaControlsDetailedViewController:: ...@@ -18,17 +18,13 @@ UnifiedMediaControlsDetailedViewController::
UnifiedMediaControlsDetailedViewController( UnifiedMediaControlsDetailedViewController(
UnifiedSystemTrayController* tray_controller) UnifiedSystemTrayController* tray_controller)
: detailed_view_delegate_( : detailed_view_delegate_(
std::make_unique<DetailedViewDelegate>(tray_controller)) { std::make_unique<DetailedViewDelegate>(tray_controller)) {}
DCHECK(MediaNotificationProvider::Get());
MediaNotificationProvider::Get()->AddObserver(this);
}
UnifiedMediaControlsDetailedViewController:: UnifiedMediaControlsDetailedViewController::
~UnifiedMediaControlsDetailedViewController() { ~UnifiedMediaControlsDetailedViewController() {
if (!MediaNotificationProvider::Get()) if (!MediaNotificationProvider::Get())
return; return;
MediaNotificationProvider::Get()->RemoveObserver(this);
MediaNotificationProvider::Get()->OnBubbleClosing(); MediaNotificationProvider::Get()->OnBubbleClosing();
} }
...@@ -48,13 +44,4 @@ base::string16 UnifiedMediaControlsDetailedViewController::GetAccessibleName() ...@@ -48,13 +44,4 @@ base::string16 UnifiedMediaControlsDetailedViewController::GetAccessibleName()
IDS_ASH_QUICK_SETTINGS_BUBBLE_MEDIA_CONTROLS_ACCESSIBLE_DESCRIPTION); IDS_ASH_QUICK_SETTINGS_BUBBLE_MEDIA_CONTROLS_ACCESSIBLE_DESCRIPTION);
} }
void UnifiedMediaControlsDetailedViewController::OnNotificationListChanged() {
DCHECK(MediaNotificationProvider::Get());
if (MediaNotificationProvider::Get()->HasActiveNotifications() ||
MediaNotificationProvider::Get()->HasFrozenNotifications())
return;
detailed_view_delegate_->TransitionToMainView(false /* restore_focus */);
}
} // namespace ash } // namespace ash
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define ASH_SYSTEM_MEDIA_UNIFIED_MEDIA_CONTROLS_DETAILED_VIEW_CONTROLLER_H_ #define ASH_SYSTEM_MEDIA_UNIFIED_MEDIA_CONTROLS_DETAILED_VIEW_CONTROLLER_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/public/cpp/media_notification_provider_observer.h"
#include "ash/system/unified/detailed_view_controller.h" #include "ash/system/unified/detailed_view_controller.h"
namespace ash { namespace ash {
...@@ -16,8 +15,7 @@ class UnifiedSystemTrayController; ...@@ -16,8 +15,7 @@ class UnifiedSystemTrayController;
// Controller of UnifiedMediaControlsDetailedView in UnifiedSystemTray. // Controller of UnifiedMediaControlsDetailedView in UnifiedSystemTray.
class ASH_EXPORT UnifiedMediaControlsDetailedViewController class ASH_EXPORT UnifiedMediaControlsDetailedViewController
: public DetailedViewController, : public DetailedViewController {
public MediaNotificationProviderObserver {
public: public:
explicit UnifiedMediaControlsDetailedViewController( explicit UnifiedMediaControlsDetailedViewController(
UnifiedSystemTrayController* tray_controller); UnifiedSystemTrayController* tray_controller);
...@@ -27,11 +25,9 @@ class ASH_EXPORT UnifiedMediaControlsDetailedViewController ...@@ -27,11 +25,9 @@ class ASH_EXPORT UnifiedMediaControlsDetailedViewController
views::View* CreateView() override; views::View* CreateView() override;
base::string16 GetAccessibleName() const override; base::string16 GetAccessibleName() const override;
// MediaNotificationProviderObserver implementations.
void OnNotificationListChanged() override;
void OnNotificationListViewSizeChanged() override {}
private: private:
friend class UnifiedMediaControlsDetailedViewControllerTest;
const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_; const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_;
}; };
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/system/media/media_tray.h" #include "ash/system/media/media_tray.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/status_area_widget_test_helper.h" #include "ash/system/status_area_widget_test_helper.h"
#include "ash/system/tray/detailed_view_delegate.h"
#include "ash/system/unified/unified_system_tray.h" #include "ash/system/unified/unified_system_tray.h"
#include "ash/system/unified/unified_system_tray_bubble.h" #include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_controller.h"
...@@ -43,20 +44,8 @@ class MockMediaNotificationProvider : MediaNotificationProvider { ...@@ -43,20 +44,8 @@ class MockMediaNotificationProvider : MediaNotificationProvider {
} }
void AddObserver(MediaNotificationProviderObserver* observer) override {} void AddObserver(MediaNotificationProviderObserver* observer) override {}
void RemoveObserver(MediaNotificationProviderObserver* observer) override {} void RemoveObserver(MediaNotificationProviderObserver* observer) override {}
bool HasActiveNotifications() override { return has_active_notifications_; } bool HasActiveNotifications() override { return true; }
bool HasFrozenNotifications() override { return has_frozen_notifications_; } bool HasFrozenNotifications() override { return true; }
void SetHasActiveNotifications(bool has_active_notifications) {
has_active_notifications_ = has_active_notifications;
}
void SetHasFrozenNotifications(bool has_frozen_notifications) {
has_frozen_notifications_ = has_frozen_notifications;
}
private:
bool has_active_notifications_ = false;
bool has_frozen_notifications_ = false;
}; };
} // namespace } // namespace
...@@ -84,6 +73,14 @@ class UnifiedMediaControlsDetailedViewControllerTest : public AshTestBase { ...@@ -84,6 +73,14 @@ class UnifiedMediaControlsDetailedViewControllerTest : public AshTestBase {
provider_.reset(); provider_.reset();
} }
void SimulateTransitionToMainMenu() {
UnifiedMediaControlsDetailedViewController* controller =
static_cast<UnifiedMediaControlsDetailedViewController*>(
system_tray_controller()->detailed_view_controller());
controller->detailed_view_delegate_->TransitionToMainView(
true /* restore_focus */);
}
UnifiedSystemTrayController* system_tray_controller() { UnifiedSystemTrayController* system_tray_controller() {
return StatusAreaWidgetTestHelper::GetStatusAreaWidget() return StatusAreaWidgetTestHelper::GetStatusAreaWidget()
->unified_system_tray() ->unified_system_tray()
...@@ -98,7 +95,7 @@ class UnifiedMediaControlsDetailedViewControllerTest : public AshTestBase { ...@@ -98,7 +95,7 @@ class UnifiedMediaControlsDetailedViewControllerTest : public AshTestBase {
}; };
TEST_F(UnifiedMediaControlsDetailedViewControllerTest, TEST_F(UnifiedMediaControlsDetailedViewControllerTest,
ExitDetailedViewWhenNoMediaIsPlaying) { EnterAndExitDetailedView) {
// UnifiedSystemTrayController should have no DetailedViewController // UnifiedSystemTrayController should have no DetailedViewController
// initially. // initially.
EXPECT_EQ(system_tray_controller()->detailed_view_controller(), nullptr); EXPECT_EQ(system_tray_controller()->detailed_view_controller(), nullptr);
...@@ -109,12 +106,9 @@ TEST_F(UnifiedMediaControlsDetailedViewControllerTest, ...@@ -109,12 +106,9 @@ TEST_F(UnifiedMediaControlsDetailedViewControllerTest,
system_tray_controller()->OnMediaControlsViewClicked(); system_tray_controller()->OnMediaControlsViewClicked();
EXPECT_NE(system_tray_controller()->detailed_view_controller(), nullptr); EXPECT_NE(system_tray_controller()->detailed_view_controller(), nullptr);
// Notification list update with neither active nor frozen session should // Should notify provider when transition to main menu.
// close the detailed view and get back to main view.
EXPECT_CALL(*provider(), OnBubbleClosing); EXPECT_CALL(*provider(), OnBubbleClosing);
static_cast<UnifiedMediaControlsDetailedViewController*>( SimulateTransitionToMainMenu();
system_tray_controller()->detailed_view_controller())
->OnNotificationListChanged();
EXPECT_EQ(system_tray_controller()->detailed_view_controller(), nullptr); EXPECT_EQ(system_tray_controller()->detailed_view_controller(), nullptr);
} }
......
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