Commit 58a957b5 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Fix condition of showing IME feature pod

This CL fixes the condition of IME feature pod button to be shown.
It should hide the button when a separate IME tray is shown in Shelf.

TEST=manual
BUG=882824

Change-Id: I4907f3cb01facbcbe7e14cd3329c413bb1adce24
Reviewed-on: https://chromium-review.googlesource.com/c/1255753Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596960}
parent 30774113
...@@ -129,6 +129,7 @@ void ImeController::SetImesManagedByPolicy(bool managed) { ...@@ -129,6 +129,7 @@ void ImeController::SetImesManagedByPolicy(bool managed) {
} }
void ImeController::ShowImeMenuOnShelf(bool show) { void ImeController::ShowImeMenuOnShelf(bool show) {
is_menu_active_ = show;
Shell::Get()->system_tray_notifier()->NotifyRefreshIMEMenu(show); Shell::Get()->system_tray_notifier()->NotifyRefreshIMEMenu(show);
} }
......
...@@ -57,6 +57,7 @@ class ASH_EXPORT ImeController : public mojom::ImeController { ...@@ -57,6 +57,7 @@ class ASH_EXPORT ImeController : public mojom::ImeController {
bool is_voice_enabled() const { return is_voice_enabled_; } bool is_voice_enabled() const { return is_voice_enabled_; }
bool managed_by_policy() const { return managed_by_policy_; } bool managed_by_policy() const { return managed_by_policy_; }
bool is_menu_active() const { return is_menu_active_; }
const std::vector<mojom::ImeMenuItem>& current_ime_menu_items() const { const std::vector<mojom::ImeMenuItem>& current_ime_menu_items() const {
return current_ime_menu_items_; return current_ime_menu_items_;
...@@ -167,6 +168,10 @@ class ASH_EXPORT ImeController : public mojom::ImeController { ...@@ -167,6 +168,10 @@ class ASH_EXPORT ImeController : public mojom::ImeController {
// True if voice input should be available from the IME menu. // True if voice input should be available from the IME menu.
bool is_voice_enabled_ = false; bool is_voice_enabled_ = false;
// True if the IME menu is active. IME related items in system tray should be
// removed if |is_menu_active_| is true.
bool is_menu_active_ = false;
base::ObserverList<Observer>::Unchecked observers_; base::ObserverList<Observer>::Unchecked observers_;
std::unique_ptr<ModeIndicatorObserver> mode_indicator_observer_; std::unique_ptr<ModeIndicatorObserver> mode_indicator_observer_;
......
...@@ -22,7 +22,8 @@ bool IsButtonVisible() { ...@@ -22,7 +22,8 @@ bool IsButtonVisible() {
DCHECK(Shell::Get()); DCHECK(Shell::Get());
ImeController* ime_controller = Shell::Get()->ime_controller(); ImeController* ime_controller = Shell::Get()->ime_controller();
size_t ime_count = ime_controller->available_imes().size(); size_t ime_count = ime_controller->available_imes().size();
return ime_count > 1; return !ime_controller->is_menu_active() &&
(ime_count > 1 || ime_controller->managed_by_policy());
} }
base::string16 GetLabelString() { base::string16 GetLabelString() {
...@@ -85,7 +86,7 @@ void IMEFeaturePodController::OnIMERefresh() { ...@@ -85,7 +86,7 @@ void IMEFeaturePodController::OnIMERefresh() {
Update(); Update();
} }
void IMEFeaturePodController::OnIMEMenuActivationChanged(bool is_activated) { void IMEFeaturePodController::OnIMEMenuActivationChanged(bool is_active) {
Update(); Update();
} }
......
...@@ -31,7 +31,7 @@ class ASH_EXPORT IMEFeaturePodController : public FeaturePodControllerBase, ...@@ -31,7 +31,7 @@ class ASH_EXPORT IMEFeaturePodController : public FeaturePodControllerBase,
// IMEObserver: // IMEObserver:
void OnIMERefresh() override; void OnIMERefresh() override;
void OnIMEMenuActivationChanged(bool is_activated) override; void OnIMEMenuActivationChanged(bool is_active) override;
// Unowned. // Unowned.
UnifiedSystemTrayController* const tray_controller_; UnifiedSystemTrayController* const tray_controller_;
......
...@@ -101,4 +101,29 @@ TEST_F(IMEFeaturePodControllerTest, ButtonVisibilityIMECount) { ...@@ -101,4 +101,29 @@ TEST_F(IMEFeaturePodControllerTest, ButtonVisibilityIMECount) {
EXPECT_TRUE(button()->visible()); EXPECT_TRUE(button()->visible());
} }
TEST_F(IMEFeaturePodControllerTest, ButtonVisibilityImeMenuActive) {
SetUpButton();
Shell::Get()->ime_controller()->ShowImeMenuOnShelf(true);
SetActiveIMECount(0);
EXPECT_FALSE(button()->visible());
SetActiveIMECount(1);
EXPECT_FALSE(button()->visible());
SetActiveIMECount(2);
EXPECT_FALSE(button()->visible());
}
TEST_F(IMEFeaturePodControllerTest, ButtonVisibilityPolicy) {
SetUpButton();
Shell::Get()->ime_controller()->SetImesManagedByPolicy(true);
SetActiveIMECount(0);
EXPECT_TRUE(button()->visible());
SetActiveIMECount(1);
EXPECT_TRUE(button()->visible());
SetActiveIMECount(2);
EXPECT_TRUE(button()->visible());
}
} // namespace ash } // namespace ash
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