• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 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 "chrome/browser/chromeos/input_method/accessibility.h"
6 
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/accessibility/accessibility_events.h"
11 #include "chrome/browser/chromeos/input_method/input_method_util.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chromeos/chromeos_switches.h"
14 
15 namespace chromeos {
16 namespace input_method {
17 
Accessibility(InputMethodManager * imm)18 Accessibility::Accessibility(InputMethodManager* imm)
19     : imm_(imm) {
20   DCHECK(imm_);
21   imm_->AddObserver(this);
22 }
23 
~Accessibility()24 Accessibility::~Accessibility() {
25   DCHECK(imm_);
26   imm_->RemoveObserver(this);
27 }
28 
InputMethodChanged(InputMethodManager * imm,bool show_message)29 void Accessibility::InputMethodChanged(InputMethodManager* imm,
30                                        bool show_message) {
31   DCHECK_EQ(imm, imm_);
32   if (!show_message)
33     return;
34 
35   // When Mode indicator is disabled, the previous IME massage and its
36   // spoken feedback is used.  In that case, this module does not
37   // provide a redundant spoken feedback.
38   //
39   // TODO(komatsu): When this is permanently enabled by defalut,
40   // delete command_line.h and chromeos_switches.h from the header
41   // files.
42   if (CommandLine::ForCurrentProcess()->HasSwitch(
43           switches::kDisableIMEModeIndicator))
44     return;
45 
46   // Get the medium name of the changed input method (e.g. US, INTL, etc.)
47   const InputMethodDescriptor descriptor = imm_->GetCurrentInputMethod();
48   const std::string medium_name = UTF16ToUTF8(
49       imm_->GetInputMethodUtil()->GetInputMethodMediumName(descriptor));
50 
51   AccessibilityAlertInfo event(ProfileManager::GetDefaultProfile(),
52                                medium_name);
53   SendControlAccessibilityNotification(
54       ui::AccessibilityTypes::EVENT_ALERT, &event);
55 }
56 
InputMethodPropertyChanged(InputMethodManager * imm)57 void Accessibility::InputMethodPropertyChanged(InputMethodManager* imm) {
58   // Do nothing.
59 }
60 
61 }  // namespace input_method
62 }  // namespace chromeos
63