Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1943)

Unified Diff: ash/system/ime_menu/ime_menu_tray.cc

Issue 2920883002: chromeos: Make ash system tray directly observe IME state changes (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/ime_menu/ime_menu_tray.h ('k') | ash/system/ime_menu/ime_menu_tray_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/ime_menu/ime_menu_tray.cc
diff --git a/ash/system/ime_menu/ime_menu_tray.cc b/ash/system/ime_menu/ime_menu_tray.cc
index bd845fac4c1a5e2a31fa5d0a1af64520421c88b8..1615c748e3e7bf35d31ca1a945dda19f0f5e815b 100644
--- a/ash/system/ime_menu/ime_menu_tray.cc
+++ b/ash/system/ime_menu/ime_menu_tray.cc
@@ -26,7 +26,6 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "components/session_manager/session_manager_types.h"
-#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ime/ime_bridge.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/base/l10n/l10n_util.h"
@@ -292,15 +291,27 @@ ImeMenuTray::ImeMenuTray(Shelf* shelf)
label_->SetElideBehavior(gfx::TRUNCATE);
tray_container()->AddChildView(label_);
SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier();
- tray_notifier->AddIMEObserver(this);
tray_notifier->AddVirtualKeyboardObserver(this);
+
+ // May be null in tests.
+ InputMethodManager* input_method_manager = InputMethodManager::Get();
+ if (input_method_manager) {
+ input_method_manager->AddObserver(this);
+ input_method_manager->AddImeMenuObserver(this);
+ }
+ ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
}
ImeMenuTray::~ImeMenuTray() {
if (bubble_)
bubble_->bubble_view()->reset_delegate();
+ ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
+ InputMethodManager* input_method_manager = InputMethodManager::Get();
+ if (input_method_manager) {
+ input_method_manager->RemoveImeMenuObserver(this);
+ input_method_manager->RemoveObserver(this);
+ }
SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier();
- tray_notifier->RemoveIMEObserver(this);
tray_notifier->RemoveVirtualKeyboardObserver(this);
keyboard::KeyboardController* keyboard_controller =
keyboard::KeyboardController::GetInstance();
@@ -442,7 +453,7 @@ bool ImeMenuTray::PerformAction(const ui::Event& event) {
return true;
}
-void ImeMenuTray::OnIMERefresh() {
+void ImeMenuTray::RefreshCurrentIme() {
UpdateTrayLabel();
if (bubble_ && ime_list_view_) {
IMEInfoList list = ime_util::GetAvailableIMEList();
@@ -452,7 +463,15 @@ void ImeMenuTray::OnIMERefresh() {
}
}
-void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) {
+// InputMethodManager::Observer:
+void ImeMenuTray::InputMethodChanged(InputMethodManager* manager,
+ Profile* profile,
+ bool show_message) {
+ RefreshCurrentIme();
+}
+
+// InputMethodMenuManager::Observer:
+void ImeMenuTray::ImeMenuActivationChanged(bool is_activated) {
SetVisible(is_activated);
if (is_activated)
UpdateTrayLabel();
@@ -460,9 +479,20 @@ void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) {
HideImeMenuBubble();
}
-void ImeMenuTray::BubbleViewDestroyed() {
+void ImeMenuTray::ImeMenuListChanged() {}
+
+void ImeMenuTray::ImeMenuItemsChanged(
+ const std::string& engine_id,
+ const std::vector<InputMethodManager::MenuItem>& items) {}
+
+// ui::ime::InputMethodMenuManager::Observer:
+void ImeMenuTray::InputMethodMenuItemChanged(
+ ui::ime::InputMethodMenuManager* manager) {
+ RefreshCurrentIme();
}
+void ImeMenuTray::BubbleViewDestroyed() {}
+
void ImeMenuTray::OnMouseEnteredView() {}
void ImeMenuTray::OnMouseExitedView() {}
« no previous file with comments | « ash/system/ime_menu/ime_menu_tray.h ('k') | ash/system/ime_menu/ime_menu_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698