OLD | NEW |
---|---|
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/extensions/api/input_ime/input_ime_api.h" | 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | |
10 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/common/extensions/api/input_ime.h" | 14 #include "chrome/common/extensions/api/input_ime.h" |
13 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" | 15 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" |
14 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
15 #include "extensions/browser/extension_function_registry.h" | 17 #include "extensions/browser/extension_function_registry.h" |
16 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
18 #include "extensions/common/manifest_handlers/background_info.h" | 20 #include "extensions/common/manifest_handlers/background_info.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 const InputMethodEngineInterface::InputContext& context) OVERRIDE { | 139 const InputMethodEngineInterface::InputContext& context) OVERRIDE { |
138 if (profile_ == NULL || extension_id_.empty()) | 140 if (profile_ == NULL || extension_id_.empty()) |
139 return; | 141 return; |
140 | 142 |
141 input_ime::InputContext context_value; | 143 input_ime::InputContext context_value; |
142 context_value.context_id = context.id; | 144 context_value.context_id = context.id; |
143 context_value.type = input_ime::InputContext::ParseType(context.type); | 145 context_value.type = input_ime::InputContext::ParseType(context.type); |
144 | 146 |
145 scoped_ptr<base::ListValue> args(input_ime::OnFocus::Create(context_value)); | 147 scoped_ptr<base::ListValue> args(input_ime::OnFocus::Create(context_value)); |
146 | 148 |
149 // The component IME extensions need to know the current screen type (e.g. | |
150 // lock screen, login screen, etc.) so that its on-screen keyboard page | |
151 // won't open new windows/pages. See crbug.com/395621. | |
152 base::DictionaryValue* val = NULL; | |
153 if (args->GetDictionary(0, &val)) { | |
154 std::string screen_type; | |
155 if (!UserManager::Get()->IsUserLoggedIn()) { | |
156 screen_type = "login"; | |
157 } else if (chromeos::ScreenLocker::default_screen_locker() && | |
158 chromeos::ScreenLocker::default_screen_locker()->locked()) { | |
159 screen_type = "lock"; | |
160 } | |
Nikita (slow)
2014/07/25 09:23:24
You should add another type here "multi-profiles l
Shu Chen
2014/07/25 09:41:06
Thanks, I will create another cl to support it.
| |
161 if (!screen_type.empty()) | |
162 val->SetStringWithoutPathExpansion("screen", screen_type); | |
163 } | |
164 | |
147 DispatchEventToExtension(profile_, extension_id_, | 165 DispatchEventToExtension(profile_, extension_id_, |
148 input_ime::OnFocus::kEventName, args.Pass()); | 166 input_ime::OnFocus::kEventName, args.Pass()); |
149 } | 167 } |
150 | 168 |
151 virtual void OnBlur(int context_id) OVERRIDE { | 169 virtual void OnBlur(int context_id) OVERRIDE { |
152 if (profile_ == NULL || extension_id_.empty()) | 170 if (profile_ == NULL || extension_id_.empty()) |
153 return; | 171 return; |
154 | 172 |
155 scoped_ptr<base::ListValue> args(input_ime::OnBlur::Create(context_id)); | 173 scoped_ptr<base::ListValue> args(input_ime::OnBlur::Create(context_id)); |
156 | 174 |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 input_ime_event_router()->GetActiveEngine(details.extension_id); | 879 input_ime_event_router()->GetActiveEngine(details.extension_id); |
862 if (engine) | 880 if (engine) |
863 engine->NotifyImeReady(); | 881 engine->NotifyImeReady(); |
864 } | 882 } |
865 | 883 |
866 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 884 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
867 return InputImeEventRouter::GetInstance(); | 885 return InputImeEventRouter::GetInstance(); |
868 } | 886 } |
869 | 887 |
870 } // namespace extensions | 888 } // namespace extensions |
OLD | NEW |