Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/logging.h" | |
| 6 #include "base/strings/utf_string_conversions.h" | |
| 7 #include "chrome/browser/chromeos/input_method/input_method_util.h" | |
| 8 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h" | |
| 9 #include "chrome/browser/chromeos/input_method/mode_indicator_widget.h" | |
| 10 | |
| 11 namespace chromeos { | |
| 12 namespace input_method { | |
| 13 | |
| 14 namespace { | |
| 15 // Show mode indicator with the current ime's short name. | |
| 16 void ShowModeIndicator(InputMethodManager* manager, | |
| 17 ModeIndicatorWidget* mi_widget) { | |
| 18 DCHECK(manager); | |
|
Seigo Nonaka
2013/10/02 03:27:51
no need to check mi_widget as well?
Hiro Komatsu
2013/10/02 07:00:55
Done.
| |
| 19 | |
| 20 // Get the short name of the changed input method (e.g. US, JA, etc.) | |
| 21 const InputMethodDescriptor descriptor = manager->GetCurrentInputMethod(); | |
| 22 const std::string short_name = UTF16ToUTF8( | |
| 23 manager->GetInputMethodUtil()->GetInputMethodShortName(descriptor)); | |
| 24 mi_widget->SetLabelTextUtf8(short_name); | |
| 25 | |
| 26 // Show the widget and hide it after 750msec. | |
| 27 mi_widget->Show(); | |
| 28 const int kDelayMSec = 750; | |
| 29 mi_widget->DelayHide(kDelayMSec); | |
| 30 } | |
| 31 } // namespace | |
| 32 | |
| 33 ModeIndicatorController::ModeIndicatorController( | |
| 34 ModeIndicatorWidget *mi_widget) { | |
| 35 mi_widget_.reset(mi_widget); | |
| 36 } | |
| 37 | |
| 38 ModeIndicatorController::~ModeIndicatorController() { | |
| 39 } | |
| 40 | |
| 41 void ModeIndicatorController::SetCursorLocation( | |
| 42 const gfx::Rect& cursor_location) { | |
| 43 mi_widget_->SetCursorLocation(cursor_location); | |
| 44 } | |
| 45 | |
| 46 void ModeIndicatorController::InputMethodChanged(InputMethodManager* manager, | |
| 47 bool show_message) { | |
| 48 if (!show_message) | |
| 49 return; | |
| 50 | |
| 51 ShowModeIndicator(manager, mi_widget_.get()); | |
| 52 } | |
| 53 | |
| 54 void ModeIndicatorController::InputMethodPropertyChanged( | |
| 55 InputMethodManager* manager) { | |
| 56 // TODO(komatsu): This showing mode indicator may not be necessary. | |
|
Seigo Nonaka
2013/10/02 03:27:51
Eventually mode indicator also shows property righ
Hiro Komatsu
2013/10/02 07:00:55
Not sure so far. I removed this line and added th
| |
| 57 ShowModeIndicator(manager, mi_widget_.get()); | |
| 58 } | |
| 59 | |
| 60 } // namespace input_method | |
| 61 } // namespace chromeos | |
| OLD | NEW |