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

Side by Side Diff: ash/common/system/chromeos/ime_menu/ime_menu_tray.cc

Issue 2271483003: Updates the IME list when the IME has refreshed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix patch failure. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" 5 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 9 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 }; 52 };
53 53
54 TrayPopupHeaderButton* CreateImeMenuButton(views::ButtonListener* listener, 54 TrayPopupHeaderButton* CreateImeMenuButton(views::ButtonListener* listener,
55 int enabled_resource_id, 55 int enabled_resource_id,
56 int disabled_resource_id, 56 int disabled_resource_id,
57 int enabled_resource_id_hover, 57 int enabled_resource_id_hover,
58 int disabled_resource_id_hover, 58 int disabled_resource_id_hover,
59 int accessible_name_id, 59 int accessible_name_id,
60 int message_id, 60 int message_id,
61 int right_border) { 61 int right_border) {
62 TrayPopupHeaderButton* button = new ash::TrayPopupHeaderButton( 62 TrayPopupHeaderButton* button =
63 listener, enabled_resource_id, disabled_resource_id, 63 new TrayPopupHeaderButton(listener, enabled_resource_id,
64 enabled_resource_id_hover, disabled_resource_id_hover, 64 disabled_resource_id, enabled_resource_id_hover,
65 accessible_name_id); 65 disabled_resource_id_hover, accessible_name_id);
66 button->SetTooltipText(l10n_util::GetStringUTF16(message_id)); 66 button->SetTooltipText(l10n_util::GetStringUTF16(message_id));
67 button->SetBorder(views::Border::CreateSolidSidedBorder(0, 0, 0, right_border, 67 button->SetBorder(views::Border::CreateSolidSidedBorder(0, 0, 0, right_border,
68 kBorderDarkColor)); 68 kBorderDarkColor));
69 return button; 69 return button;
70 } 70 }
71 71
72 class ImeButtonsView : public views::View, public views::ButtonListener { 72 class ImeButtonsView : public views::View, public views::ButtonListener {
73 public: 73 public:
74 ImeButtonsView(bool show_emoji_button, 74 ImeButtonsView(bool show_emoji_button,
75 bool show_voice_button, 75 bool show_voice_button,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 SetContentsBackground(); 152 SetContentsBackground();
153 WmShell::Get()->system_tray_notifier()->AddIMEObserver(this); 153 WmShell::Get()->system_tray_notifier()->AddIMEObserver(this);
154 } 154 }
155 155
156 ImeMenuTray::~ImeMenuTray() { 156 ImeMenuTray::~ImeMenuTray() {
157 WmShell::Get()->system_tray_notifier()->RemoveIMEObserver(this); 157 WmShell::Get()->system_tray_notifier()->RemoveIMEObserver(this);
158 } 158 }
159 159
160 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) { 160 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) {
161 TrayBackgroundView::SetShelfAlignment(alignment); 161 TrayBackgroundView::SetShelfAlignment(alignment);
162 if (!ash::MaterialDesignController::IsShelfMaterial()) 162 if (!MaterialDesignController::IsShelfMaterial())
163 tray_container()->SetBorder(views::Border::NullBorder()); 163 tray_container()->SetBorder(views::Border::NullBorder());
164 } 164 }
165 165
166 base::string16 ImeMenuTray::GetAccessibleNameForTray() { 166 base::string16 ImeMenuTray::GetAccessibleNameForTray() {
167 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); 167 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
168 } 168 }
169 169
170 void ImeMenuTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { 170 void ImeMenuTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) {
171 if (bubble_->bubble_view() == bubble_view) 171 if (bubble_->bubble_view() == bubble_view)
172 HideImeMenuBubble(); 172 HideImeMenuBubble();
173 } 173 }
174 174
175 void ImeMenuTray::ClickedOutsideBubble() { 175 void ImeMenuTray::ClickedOutsideBubble() {
176 HideImeMenuBubble(); 176 HideImeMenuBubble();
177 } 177 }
178 178
179 bool ImeMenuTray::PerformAction(const ui::Event& event) { 179 bool ImeMenuTray::PerformAction(const ui::Event& event) {
180 if (bubble_) 180 if (bubble_)
181 HideImeMenuBubble(); 181 HideImeMenuBubble();
182 else 182 else
183 ShowImeMenuBubble(); 183 ShowImeMenuBubble();
184 return true; 184 return true;
185 } 185 }
186 186
187 void ImeMenuTray::OnIMERefresh() { 187 void ImeMenuTray::OnIMERefresh() {
188 UpdateTrayLabel(); 188 UpdateTrayLabel();
189 if (bubble_ && ime_list_view_) {
190 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
191 IMEInfoList list;
192 delegate->GetAvailableIMEList(&list);
193 IMEPropertyInfoList property_list;
194 delegate->GetCurrentIMEProperties(&property_list);
195 ime_list_view_->Update(list, property_list, false,
196 ImeListView::SHOW_SINGLE_IME);
197 }
189 } 198 }
190 199
191 void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) { 200 void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) {
192 SetVisible(is_activated); 201 SetVisible(is_activated);
193 if (is_activated) 202 if (is_activated)
194 UpdateTrayLabel(); 203 UpdateTrayLabel();
195 else 204 else
196 HideImeMenuBubble(); 205 HideImeMenuBubble();
197 } 206 }
198 207
199 void ImeMenuTray::BubbleViewDestroyed() { 208 void ImeMenuTray::BubbleViewDestroyed() {
200 SetDrawBackgroundAsActive(false);
201 } 209 }
202 210
203 void ImeMenuTray::OnMouseEnteredView() {} 211 void ImeMenuTray::OnMouseEnteredView() {}
204 212
205 void ImeMenuTray::OnMouseExitedView() {} 213 void ImeMenuTray::OnMouseExitedView() {}
206 214
207 base::string16 ImeMenuTray::GetAccessibleNameForBubble() { 215 base::string16 ImeMenuTray::GetAccessibleNameForBubble() {
208 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); 216 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
209 } 217 }
210 218
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 kTrayPopupMinWidth, kTrayPopupMaxWidth); 268 kTrayPopupMinWidth, kTrayPopupMaxWidth);
261 init_params.first_item_has_no_margin = true; 269 init_params.first_item_has_no_margin = true;
262 init_params.can_activate = true; 270 init_params.can_activate = true;
263 init_params.close_on_deactivate = true; 271 init_params.close_on_deactivate = true;
264 272
265 views::TrayBubbleView* bubble_view = 273 views::TrayBubbleView* bubble_view =
266 views::TrayBubbleView::Create(tray_container(), this, &init_params); 274 views::TrayBubbleView::Create(tray_container(), this, &init_params);
267 bubble_view->set_margins(gfx::Insets(7, 0, 0, 0)); 275 bubble_view->set_margins(gfx::Insets(7, 0, 0, 0));
268 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 276 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
269 277
270 ImeListView* ime_list_view = 278 // Adds IME list to the bubble.
279 ime_list_view_ =
271 new ImeListView(nullptr, false, ImeListView::SHOW_SINGLE_IME); 280 new ImeListView(nullptr, false, ImeListView::SHOW_SINGLE_IME);
272 if (ime_list_view->scroll_content()->height() > GetImeListViewMaxHeight()) { 281 if (ime_list_view_->scroll_content()->height() > GetImeListViewMaxHeight()) {
273 ime_list_view->scroller()->SetFixedSize( 282 ime_list_view_->scroller()->SetFixedSize(
274 gfx::Size(kTrayPopupMaxWidth, GetImeListViewMaxHeight())); 283 gfx::Size(kTrayPopupMaxWidth, GetImeListViewMaxHeight()));
275 } 284 }
276 // Adds IME list to the bubble. 285 bubble_view->AddChildView(ime_list_view_);
277 bubble_view->AddChildView(ime_list_view);
278 286
279 // Adds IME buttons to the bubble if needed. 287 // Adds IME buttons to the bubble if needed.
280 LoginStatus login = 288 LoginStatus login =
281 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); 289 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus();
282 if (login != LoginStatus::NOT_LOGGED_IN && login != LoginStatus::LOCKED && 290 if (login != LoginStatus::NOT_LOGGED_IN && login != LoginStatus::LOCKED &&
283 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) 291 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen())
284 bubble_view->AddChildView(new ImeButtonsView(false, false, false, true)); 292 bubble_view->AddChildView(new ImeButtonsView(false, false, false, true));
285 293
286 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); 294 bubble_.reset(new TrayBubbleWrapper(this, bubble_view));
287 SetDrawBackgroundAsActive(true); 295 SetDrawBackgroundAsActive(true);
288 } 296 }
289 297
290 void ImeMenuTray::HideImeMenuBubble() { 298 void ImeMenuTray::HideImeMenuBubble() {
291 bubble_.reset(); 299 bubble_.reset();
300 ime_list_view_ = nullptr;
292 SetDrawBackgroundAsActive(false); 301 SetDrawBackgroundAsActive(false);
293 } 302 }
294 303
295 } // namespace ash 304 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_menu_tray.h ('k') | ash/common/system/chromeos/ime_menu/ime_menu_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698