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

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

Issue 2474843002: Add virtual keyboard item into opt-in IME menu. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_menu_tray.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/accessibility_delegate.h" 7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/ash_constants.h" 8 #include "ash/common/ash_constants.h"
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); 272 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView);
273 }; 273 };
274 274
275 } // namespace 275 } // namespace
276 276
277 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) 277 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf)
278 : TrayBackgroundView(wm_shelf), 278 : TrayBackgroundView(wm_shelf),
279 label_(new ImeMenuLabel()), 279 label_(new ImeMenuLabel()),
280 show_keyboard_(false), 280 show_keyboard_(false),
281 force_show_keyboard_(false), 281 force_show_keyboard_(false),
282 should_block_shelf_auto_hide_(false) { 282 should_block_shelf_auto_hide_(false),
283 keyboard_suppressed_(false) {
283 SetupLabelForTray(label_); 284 SetupLabelForTray(label_);
284 tray_container()->AddChildView(label_); 285 tray_container()->AddChildView(label_);
285 SetContentsBackground(); 286 SetContentsBackground();
286 WmShell::Get()->system_tray_notifier()->AddIMEObserver(this); 287 WmShell::Get()->system_tray_notifier()->AddIMEObserver(this);
287 } 288 }
288 289
289 ImeMenuTray::~ImeMenuTray() { 290 ImeMenuTray::~ImeMenuTray() {
290 if (bubble_) 291 if (bubble_)
291 bubble_->bubble_view()->reset_delegate(); 292 bubble_->bubble_view()->reset_delegate();
292 WmShell::Get()->system_tray_notifier()->RemoveIMEObserver(this); 293 WmShell::Get()->system_tray_notifier()->RemoveIMEObserver(this);
(...skipping 21 matching lines...) Expand all
314 views::Separator* separator = 315 views::Separator* separator =
315 new views::Separator(views::Separator::HORIZONTAL); 316 new views::Separator(views::Separator::HORIZONTAL);
316 separator->SetColor(kBorderLightColor); 317 separator->SetColor(kBorderLightColor);
317 separator->SetPreferredSize(kSeparatorWidth); 318 separator->SetPreferredSize(kSeparatorWidth);
318 separator->SetBorder(views::Border::CreateEmptyBorder( 319 separator->SetBorder(views::Border::CreateEmptyBorder(
319 0, 0, kMenuSeparatorVerticalPadding, 0)); 320 0, 0, kMenuSeparatorVerticalPadding, 0));
320 bubble_view->AddChildView(separator); 321 bubble_view->AddChildView(separator);
321 } 322 }
322 323
323 // Adds IME list to the bubble. 324 // Adds IME list to the bubble.
324 ime_list_view_ = 325 ime_list_view_ = new ImeListView(nullptr, ShouldShowKeyboardToggle(),
325 new ImeListView(nullptr, false, ImeListView::SHOW_SINGLE_IME); 326 ImeListView::SHOW_SINGLE_IME);
326 327
327 uint32_t current_height = ime_list_view_->scroll_content()->height(); 328 uint32_t current_height = ime_list_view_->scroll_content()->height();
328 const gfx::Range height_range = GetImeListViewRange(); 329 const gfx::Range height_range = GetImeListViewRange();
329 if (current_height > height_range.end()) { 330 if (current_height > height_range.end()) {
330 ime_list_view_->scroller()->SetFixedSize( 331 ime_list_view_->scroller()->SetFixedSize(
331 gfx::Size(kTrayPopupMaxWidth, height_range.end())); 332 gfx::Size(kTrayPopupMaxWidth, height_range.end()));
332 } else if (MaterialDesignController::IsSystemTrayMenuMaterial() && 333 } else if (MaterialDesignController::IsSystemTrayMenuMaterial() &&
333 current_height < height_range.start()) { 334 current_height < height_range.start()) {
334 ime_list_view_->scroller()->SetFixedSize( 335 ime_list_view_->scroller()->SetFixedSize(
335 gfx::Size(kTrayPopupMaxWidth, height_range.start())); 336 gfx::Size(kTrayPopupMaxWidth, height_range.start()));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (keyboard_controller) { 400 if (keyboard_controller) {
400 keyboard_controller->AddObserver(this); 401 keyboard_controller->AddObserver(this);
401 keyboard_controller->ShowKeyboard(false); 402 keyboard_controller->ShowKeyboard(false);
402 } 403 }
403 } 404 }
404 405
405 bool ImeMenuTray::ShouldBlockShelfAutoHide() const { 406 bool ImeMenuTray::ShouldBlockShelfAutoHide() const {
406 return should_block_shelf_auto_hide_; 407 return should_block_shelf_auto_hide_;
407 } 408 }
408 409
410 bool ImeMenuTray::ShouldShowKeyboardToggle() const {
411 return keyboard_suppressed_ &&
tdanderson 2016/11/03 21:17:20 I left the following comment in https://chromiumco
Azure Wei 2016/11/20 08:56:23 The method return true when the 'smart deploy togg
412 !WmShell::Get()->accessibility_delegate()->IsVirtualKeyboardEnabled();
413 }
414
409 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) { 415 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) {
410 TrayBackgroundView::SetShelfAlignment(alignment); 416 TrayBackgroundView::SetShelfAlignment(alignment);
411 if (!MaterialDesignController::IsShelfMaterial()) 417 if (!MaterialDesignController::IsShelfMaterial())
412 tray_container()->SetBorder(views::Border::NullBorder()); 418 tray_container()->SetBorder(views::Border::NullBorder());
413 } 419 }
414 420
415 base::string16 ImeMenuTray::GetAccessibleNameForTray() { 421 base::string16 ImeMenuTray::GetAccessibleNameForTray() {
416 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); 422 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
417 } 423 }
418 424
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 if (keyboard_controller) 533 if (keyboard_controller)
528 keyboard_controller->RemoveObserver(this); 534 keyboard_controller->RemoveObserver(this);
529 535
530 if (!force_show_keyboard_) 536 if (!force_show_keyboard_)
531 return; 537 return;
532 538
533 WmShell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false); 539 WmShell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false);
534 force_show_keyboard_ = false; 540 force_show_keyboard_ = false;
535 } 541 }
536 542
543 void ImeMenuTray::OnKeyboardSuppressionChanged(bool suppressed) {
544 if (suppressed != keyboard_suppressed_ && bubble_)
545 HideImeMenuBubble();
546 keyboard_suppressed_ = suppressed;
547 }
548
537 void ImeMenuTray::UpdateTrayLabel() { 549 void ImeMenuTray::UpdateTrayLabel() {
538 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 550 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
539 551
540 // Updates the tray label based on the current input method. 552 // Updates the tray label based on the current input method.
541 if (current_ime_.third_party) 553 if (current_ime_.third_party)
542 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 554 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
543 else 555 else
544 label_->SetText(current_ime_.short_name); 556 label_->SetText(current_ime_.short_name);
545 } 557 }
546 558
547 } // namespace ash 559 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_menu_tray.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698