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

Unified Diff: chrome/browser/chromeos/input_method/mode_indicator_controller.cc

Issue 25670002: Create ModeIndicatorController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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
Index: chrome/browser/chromeos/input_method/mode_indicator_controller.cc
diff --git a/chrome/browser/chromeos/input_method/mode_indicator_controller.cc b/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c5c820ebe8568ec7695797dc0df75b4cb08e0510
--- /dev/null
+++ b/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/chromeos/input_method/input_method_util.h"
+#include "chrome/browser/chromeos/input_method/mode_indicator_controller.h"
+#include "chrome/browser/chromeos/input_method/mode_indicator_widget.h"
+
+namespace chromeos {
+namespace input_method {
+
+namespace {
+// Show mode indicator with the current ime's short name.
+void ShowModeIndicator(InputMethodManager* manager,
+ ModeIndicatorWidget* mi_widget) {
+ 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.
+
+ // Get the short name of the changed input method (e.g. US, JA, etc.)
+ const InputMethodDescriptor descriptor = manager->GetCurrentInputMethod();
+ const std::string short_name = UTF16ToUTF8(
+ manager->GetInputMethodUtil()->GetInputMethodShortName(descriptor));
+ mi_widget->SetLabelTextUtf8(short_name);
+
+ // Show the widget and hide it after 750msec.
+ mi_widget->Show();
+ const int kDelayMSec = 750;
+ mi_widget->DelayHide(kDelayMSec);
+}
+} // namespace
+
+ModeIndicatorController::ModeIndicatorController(
+ ModeIndicatorWidget *mi_widget) {
+ mi_widget_.reset(mi_widget);
+}
+
+ModeIndicatorController::~ModeIndicatorController() {
+}
+
+void ModeIndicatorController::SetCursorLocation(
+ const gfx::Rect& cursor_location) {
+ mi_widget_->SetCursorLocation(cursor_location);
+}
+
+void ModeIndicatorController::InputMethodChanged(InputMethodManager* manager,
+ bool show_message) {
+ if (!show_message)
+ return;
+
+ ShowModeIndicator(manager, mi_widget_.get());
+}
+
+void ModeIndicatorController::InputMethodPropertyChanged(
+ InputMethodManager* manager) {
+ // 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
+ ShowModeIndicator(manager, mi_widget_.get());
+}
+
+} // namespace input_method
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698