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

Side by Side Diff: chrome/browser/chromeos/extensions/input_method_api.cc

Issue 676593004: Adds experimental flag --enable-experimental-ime-features. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/extensions/input_method_api.h" 5 #include "chrome/browser/chromeos/extensions/input_method_api.h"
6 6
7 #include "base/command_line.h"
7 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 10 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
10 #include "chrome/browser/chromeos/input_method/input_method_util.h" 11 #include "chrome/browser/chromeos/input_method/input_method_util.h"
11 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" 12 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
13 #include "chromeos/chromeos_switches.h"
12 #include "chromeos/ime/extension_ime_util.h" 14 #include "chromeos/ime/extension_ime_util.h"
13 #include "chromeos/ime/input_method_descriptor.h" 15 #include "chromeos/ime/input_method_descriptor.h"
14 #include "chromeos/ime/input_method_manager.h" 16 #include "chromeos/ime/input_method_manager.h"
15 #include "extensions/browser/extension_function_registry.h" 17 #include "extensions/browser/extension_function_registry.h"
16 #include "extensions/browser/extension_system.h" 18 #include "extensions/browser/extension_system.h"
17 #include "extensions/common/value_builder.h" 19 #include "extensions/common/value_builder.h"
18 20
19 namespace { 21 namespace {
20 22
21 // Prefix, which is used by XKB. 23 // Prefix, which is used by XKB.
22 const char kXkbPrefix[] = "xkb:"; 24 const char kXkbPrefix[] = "xkb:";
23 25
24 } // namespace 26 } // namespace
25 27
26 namespace extensions { 28 namespace extensions {
27 29
30 ExtensionFunction::ResponseAction GetInputMethodConfigFunction::Run() {
31 #if !defined(OS_CHROMEOS)
32 EXTENSION_FUNCTION_VALIDATE(false);
33 #else
34 base::DictionaryValue* output = new base::DictionaryValue();
35 output->SetBoolean(
36 "isPhysicalKeyboardAutocorrectEnabled",
37 CommandLine::ForCurrentProcess()->HasSwitch(
38 chromeos::switches::kEnablePhysicalKeyboardAutocorrect));
39 return RespondNow(OneArgument(output));
40 #endif
41 }
42
28 ExtensionFunction::ResponseAction GetCurrentInputMethodFunction::Run() { 43 ExtensionFunction::ResponseAction GetCurrentInputMethodFunction::Run() {
29 #if !defined(OS_CHROMEOS) 44 #if !defined(OS_CHROMEOS)
30 EXTENSION_FUNCTION_VALIDATE(false); 45 EXTENSION_FUNCTION_VALIDATE(false);
31 #else 46 #else
32 chromeos::input_method::InputMethodManager* manager = 47 chromeos::input_method::InputMethodManager* manager =
33 chromeos::input_method::InputMethodManager::Get(); 48 chromeos::input_method::InputMethodManager::Get();
34 return RespondNow(OneArgument(new base::StringValue( 49 return RespondNow(OneArgument(new base::StringValue(
35 manager->GetActiveIMEState()->GetCurrentInputMethod().id()))); 50 manager->GetActiveIMEState()->GetCurrentInputMethod().id())));
36 #endif 51 #endif
37 } 52 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 99
85 // static 100 // static
86 const char InputMethodAPI::kOnInputMethodChanged[] = 101 const char InputMethodAPI::kOnInputMethodChanged[] =
87 "inputMethodPrivate.onChanged"; 102 "inputMethodPrivate.onChanged";
88 103
89 InputMethodAPI::InputMethodAPI(content::BrowserContext* context) 104 InputMethodAPI::InputMethodAPI(content::BrowserContext* context)
90 : context_(context) { 105 : context_(context) {
91 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged); 106 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged);
92 ExtensionFunctionRegistry* registry = 107 ExtensionFunctionRegistry* registry =
93 ExtensionFunctionRegistry::GetInstance(); 108 ExtensionFunctionRegistry::GetInstance();
109 registry->RegisterFunction<GetInputMethodConfigFunction>();
94 registry->RegisterFunction<GetCurrentInputMethodFunction>(); 110 registry->RegisterFunction<GetCurrentInputMethodFunction>();
95 registry->RegisterFunction<SetCurrentInputMethodFunction>(); 111 registry->RegisterFunction<SetCurrentInputMethodFunction>();
96 registry->RegisterFunction<GetInputMethodsFunction>(); 112 registry->RegisterFunction<GetInputMethodsFunction>();
97 } 113 }
98 114
99 InputMethodAPI::~InputMethodAPI() { 115 InputMethodAPI::~InputMethodAPI() {
100 } 116 }
101 117
102 // static 118 // static
103 std::string InputMethodAPI::GetInputMethodForXkb(const std::string& xkb_id) { 119 std::string InputMethodAPI::GetInputMethodForXkb(const std::string& xkb_id) {
(...skipping 21 matching lines...) Expand all
125 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> > 141 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> >
126 g_factory = LAZY_INSTANCE_INITIALIZER; 142 g_factory = LAZY_INSTANCE_INITIALIZER;
127 143
128 // static 144 // static
129 BrowserContextKeyedAPIFactory<InputMethodAPI>* 145 BrowserContextKeyedAPIFactory<InputMethodAPI>*
130 InputMethodAPI::GetFactoryInstance() { 146 InputMethodAPI::GetFactoryInstance() {
131 return g_factory.Pointer(); 147 return g_factory.Pointer();
132 } 148 }
133 149
134 } // namespace extensions 150 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698