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

Side by Side 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: Tweaked based on the review comments. 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 unified diff | Download patch
OLDNEW
(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);
19 DCHECK(mi_widget);
20
21 // Get the short name of the changed input method (e.g. US, JA, etc.)
22 const InputMethodDescriptor descriptor = manager->GetCurrentInputMethod();
23 const std::string short_name = UTF16ToUTF8(
24 manager->GetInputMethodUtil()->GetInputMethodShortName(descriptor));
25 mi_widget->SetLabelTextUtf8(short_name);
26
27 // Show the widget and hide it after 750msec.
28 mi_widget->Show();
29 const int kDelayMSec = 750;
30 mi_widget->DelayHide(kDelayMSec);
31 }
32 } // namespace
33
34 ModeIndicatorController::ModeIndicatorController(
35 ModeIndicatorWidget *mi_widget) {
36 mi_widget_.reset(mi_widget);
37 }
38
39 ModeIndicatorController::~ModeIndicatorController() {
40 }
41
42 void ModeIndicatorController::SetCursorLocation(
43 const gfx::Rect& cursor_location) {
44 mi_widget_->SetCursorLocation(cursor_location);
45 }
46
47 void ModeIndicatorController::InputMethodChanged(InputMethodManager* manager,
48 bool show_message) {
49 if (!show_message)
50 return;
51
52 ShowModeIndicator(manager, mi_widget_.get());
53 }
54
55 void ModeIndicatorController::InputMethodPropertyChanged(
56 InputMethodManager* manager) {
57 // Do nothing.
58 }
59
60 } // namespace input_method
61 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/mode_indicator_controller.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698