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

Side by Side Diff: ash/system/ime_menu/ime_list_view.cc

Issue 2925683002: Revert of chromeos: Remove some IME methods from ash::SystemTrayDelegate (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « ash/ime_control_delegate.h ('k') | ash/system/tray/system_tray_delegate.h » ('j') | 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/system/ime_menu/ime_list_view.h" 5 #include "ash/system/ime_menu/ime_list_view.h"
6 6
7 #include "ash/ime/ime_switch_type.h"
8 #include "ash/resources/grit/ash_resources.h" 7 #include "ash/resources/grit/ash_resources.h"
9 #include "ash/resources/vector_icons/vector_icons.h" 8 #include "ash/resources/vector_icons/vector_icons.h"
10 #include "ash/shell.h" 9 #include "ash/shell.h"
11 #include "ash/shell_port.h" 10 #include "ash/shell_port.h"
12 #include "ash/strings/grit/ash_strings.h" 11 #include "ash/strings/grit/ash_strings.h"
13 #include "ash/system/tray/actionable_view.h" 12 #include "ash/system/tray/actionable_view.h"
14 #include "ash/system/tray/ime_info.h" 13 #include "ash/system/tray/ime_info.h"
15 #include "ash/system/tray/system_menu_button.h" 14 #include "ash/system/tray/system_menu_button.h"
16 #include "ash/system/tray/system_tray_delegate.h" 15 #include "ash/system/tray/system_tray_delegate.h"
17 #include "ash/system/tray/tray_constants.h" 16 #include "ash/system/tray/tray_constants.h"
18 #include "ash/system/tray/tray_details_view.h" 17 #include "ash/system/tray/tray_details_view.h"
19 #include "ash/system/tray/tray_popup_header_button.h" 18 #include "ash/system/tray/tray_popup_header_button.h"
20 #include "ash/system/tray/tray_popup_item_style.h" 19 #include "ash/system/tray/tray_popup_item_style.h"
21 #include "ash/system/tray/tray_popup_utils.h" 20 #include "ash/system/tray/tray_popup_utils.h"
22 #include "ash/system/tray/tri_view.h" 21 #include "ash/system/tray/tri_view.h"
23 #include "base/metrics/histogram_macros.h"
24 #include "ui/accessibility/ax_node_data.h" 22 #include "ui/accessibility/ax_node_data.h"
25 #include "ui/base/ime/chromeos/input_method_manager.h"
26 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
28 #include "ui/gfx/color_palette.h" 25 #include "ui/gfx/color_palette.h"
29 #include "ui/gfx/paint_vector_icon.h" 26 #include "ui/gfx/paint_vector_icon.h"
30 #include "ui/keyboard/keyboard_util.h" 27 #include "ui/keyboard/keyboard_util.h"
31 #include "ui/views/background.h" 28 #include "ui/views/background.h"
32 #include "ui/views/controls/button/toggle_button.h" 29 #include "ui/views/controls/button/toggle_button.h"
33 #include "ui/views/controls/image_view.h" 30 #include "ui/views/controls/image_view.h"
34 #include "ui/views/controls/label.h" 31 #include "ui/views/controls/label.h"
35 #include "ui/views/controls/separator.h" 32 #include "ui/views/controls/separator.h"
36 #include "ui/views/layout/fill_layout.h" 33 #include "ui/views/layout/fill_layout.h"
37 #include "ui/views/painter.h" 34 #include "ui/views/painter.h"
38 #include "ui/views/view.h" 35 #include "ui/views/view.h"
39 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
40 37
41 using chromeos::input_method::InputMethodManager;
42
43 namespace ash { 38 namespace ash {
44 namespace { 39 namespace {
45 40
46 const int kMinFontSizeDelta = -10; 41 const int kMinFontSizeDelta = -10;
47 42
48 // Represents a row in the scrollable IME list; each row is either an IME or 43 // Represents a row in the scrollable IME list; each row is either an IME or
49 // an IME property. A checkmark icon is shown in the row if selected. 44 // an IME property. A checkmark icon is shown in the row if selected.
50 class ImeListItemView : public ActionableView { 45 class ImeListItemView : public ActionableView {
51 public: 46 public:
52 ImeListItemView(SystemTrayItem* owner, 47 ImeListItemView(SystemTrayItem* owner,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 283 }
289 284
290 void ImeListView::PrependKeyboardStatusRow() { 285 void ImeListView::PrependKeyboardStatusRow() {
291 DCHECK(!keyboard_status_row_); 286 DCHECK(!keyboard_status_row_);
292 keyboard_status_row_ = new KeyboardStatusRow; 287 keyboard_status_row_ = new KeyboardStatusRow;
293 keyboard_status_row_->Init(this); 288 keyboard_status_row_->Init(this);
294 scroll_content()->AddChildViewAt(keyboard_status_row_, 0); 289 scroll_content()->AddChildViewAt(keyboard_status_row_, 0);
295 } 290 }
296 291
297 void ImeListView::HandleViewClicked(views::View* view) { 292 void ImeListView::HandleViewClicked(views::View* view) {
293 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
298 std::map<views::View*, std::string>::const_iterator ime = ime_map_.find(view); 294 std::map<views::View*, std::string>::const_iterator ime = ime_map_.find(view);
299 if (ime != ime_map_.end()) { 295 if (ime != ime_map_.end()) {
300 ShellPort::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SWITCH_MODE); 296 ShellPort::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SWITCH_MODE);
301 std::string ime_id = ime->second; 297 std::string ime_id = ime->second;
302 last_selected_item_id_ = ime_id; 298 last_selected_item_id_ = ime_id;
303 InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod( 299 delegate->SwitchIME(ime_id);
304 ime_id, false /* show_message */);
305 UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeSwitch", ImeSwitchType::kTray,
306 ImeSwitchType::kCount);
307
308 } else { 300 } else {
309 std::map<views::View*, std::string>::const_iterator property = 301 std::map<views::View*, std::string>::const_iterator property =
310 property_map_.find(view); 302 property_map_.find(view);
311 if (property == property_map_.end()) 303 if (property == property_map_.end())
312 return; 304 return;
313 const std::string key = property->second; 305 const std::string key = property->second;
314 last_selected_item_id_ = key; 306 last_selected_item_id_ = key;
315 InputMethodManager::Get()->ActivateInputMethodMenuItem(key); 307 delegate->ActivateIMEProperty(key);
316 } 308 }
317 309
318 if (!should_focus_ime_after_selection_with_keyboard_ || 310 if (!should_focus_ime_after_selection_with_keyboard_ ||
319 !last_item_selected_with_keyboard_) { 311 !last_item_selected_with_keyboard_) {
320 CloseImeListView(); 312 CloseImeListView();
321 } 313 }
322 } 314 }
323 315
324 void ImeListView::HandleButtonPressed(views::Button* sender, 316 void ImeListView::HandleButtonPressed(views::Button* sender,
325 const ui::Event& event) { 317 const ui::Event& event) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ImeListViewTestApi::ImeListViewTestApi(ImeListView* ime_list_view) 355 ImeListViewTestApi::ImeListViewTestApi(ImeListView* ime_list_view)
364 : ime_list_view_(ime_list_view) {} 356 : ime_list_view_(ime_list_view) {}
365 357
366 ImeListViewTestApi::~ImeListViewTestApi() {} 358 ImeListViewTestApi::~ImeListViewTestApi() {}
367 359
368 views::View* ImeListViewTestApi::GetToggleView() const { 360 views::View* ImeListViewTestApi::GetToggleView() const {
369 return ime_list_view_->keyboard_status_row_->toggle(); 361 return ime_list_view_->keyboard_status_row_->toggle();
370 } 362 }
371 363
372 } // namespace ash 364 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ime_control_delegate.h ('k') | ash/system/tray/system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698