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

Side by Side Diff: chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc

Issue 1587913002: Use common generated file for inputMethodPrivate APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" 11 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
12 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 12 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
13 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 13 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
15 #include "chrome/browser/chromeos/profiles/profile_helper.h" 15 #include "chrome/browser/chromeos/profiles/profile_helper.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/common/extensions/api/input_ime.h" 18 #include "chrome/common/extensions/api/input_ime.h"
19 #include "chrome/common/extensions/api/input_method_private.h"
19 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
20 #include "extensions/common/manifest_handlers/background_info.h" 21 #include "extensions/common/manifest_handlers/background_info.h"
21 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" 22 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
22 #include "ui/base/ime/chromeos/extension_ime_util.h" 23 #include "ui/base/ime/chromeos/extension_ime_util.h"
23 #include "ui/base/ime/chromeos/input_method_manager.h" 24 #include "ui/base/ime/chromeos/input_method_manager.h"
24 #include "ui/base/ime/ime_engine_handler_interface.h" 25 #include "ui/base/ime/ime_engine_handler_interface.h"
25 26
26 namespace input_ime = extensions::api::input_ime; 27 namespace input_ime = extensions::api::input_ime;
27 namespace DeleteSurroundingText = 28 namespace DeleteSurroundingText =
28 extensions::api::input_ime::DeleteSurroundingText; 29 extensions::api::input_ime::DeleteSurroundingText;
29 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems; 30 namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems;
30 namespace SendKeyEvents = extensions::api::input_ime::SendKeyEvents; 31 namespace SendKeyEvents = extensions::api::input_ime::SendKeyEvents;
31 namespace HideInputView = extensions::api::input_ime::HideInputView; 32 namespace HideInputView = extensions::api::input_ime::HideInputView;
32 namespace SetMenuItems = extensions::api::input_ime::SetMenuItems; 33 namespace SetMenuItems = extensions::api::input_ime::SetMenuItems;
33 namespace SetCursorPosition = extensions::api::input_ime::SetCursorPosition; 34 namespace SetCursorPosition = extensions::api::input_ime::SetCursorPosition;
34 namespace SetCandidates = extensions::api::input_ime::SetCandidates; 35 namespace SetCandidates = extensions::api::input_ime::SetCandidates;
35 namespace SetCandidateWindowProperties = 36 namespace SetCandidateWindowProperties =
36 extensions::api::input_ime::SetCandidateWindowProperties; 37 extensions::api::input_ime::SetCandidateWindowProperties;
37 namespace CommitText = extensions::api::input_ime::CommitText; 38 namespace CommitText = extensions::api::input_ime::CommitText;
38 namespace ClearComposition = extensions::api::input_ime::ClearComposition; 39 namespace ClearComposition = extensions::api::input_ime::ClearComposition;
39 namespace SetComposition = extensions::api::input_ime::SetComposition; 40 namespace SetComposition = extensions::api::input_ime::SetComposition;
41 namespace OnCompositionBoundsChanged =
42 extensions::api::input_method_private::OnCompositionBoundsChanged;
40 using ui::IMEEngineHandlerInterface; 43 using ui::IMEEngineHandlerInterface;
41 44
42 namespace { 45 namespace {
43 const char kErrorEngineNotAvailable[] = "Engine is not available"; 46 const char kErrorEngineNotAvailable[] = "Engine is not available";
44 const char kErrorSetMenuItemsFail[] = "Could not create menu Items"; 47 const char kErrorSetMenuItemsFail[] = "Could not create menu Items";
45 const char kErrorUpdateMenuItemsFail[] = "Could not update menu Items"; 48 const char kErrorUpdateMenuItemsFail[] = "Could not update menu Items";
46 const char kOnCompositionBoundsChangedEventName[] =
47 "inputMethodPrivate.onCompositionBoundsChanged";
48 49
49 void SetMenuItemToMenu(const input_ime::MenuItem& input, 50 void SetMenuItemToMenu(const input_ime::MenuItem& input,
50 IMEEngineHandlerInterface::MenuItem* out) { 51 IMEEngineHandlerInterface::MenuItem* out) {
51 out->modified = 0; 52 out->modified = 0;
52 out->id = input.id; 53 out->id = input.id;
53 if (input.label) { 54 if (input.label) {
54 out->modified |= IMEEngineHandlerInterface::MENU_ITEM_MODIFIED_LABEL; 55 out->modified |= IMEEngineHandlerInterface::MENU_ITEM_MODIFIED_LABEL;
55 out->label = *input.label; 56 out->label = *input.label;
56 } 57 }
57 58
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 input_ime::OnMenuItemActivated::Create(component_id, menu_id)); 145 input_ime::OnMenuItemActivated::Create(component_id, menu_id));
145 146
146 DispatchEventToExtension( 147 DispatchEventToExtension(
147 extensions::events::INPUT_IME_ON_MENU_ITEM_ACTIVATED, 148 extensions::events::INPUT_IME_ON_MENU_ITEM_ACTIVATED,
148 input_ime::OnMenuItemActivated::kEventName, std::move(args)); 149 input_ime::OnMenuItemActivated::kEventName, std::move(args));
149 } 150 }
150 151
151 void OnCompositionBoundsChanged( 152 void OnCompositionBoundsChanged(
152 const std::vector<gfx::Rect>& bounds) override { 153 const std::vector<gfx::Rect>& bounds) override {
153 if (extension_id_.empty() || 154 if (extension_id_.empty() ||
154 !HasListener(kOnCompositionBoundsChangedEventName)) 155 !HasListener(OnCompositionBoundsChanged::kEventName))
155 return; 156 return;
156 157
157 // Note: this is a private API event. 158 // Note: this is a private API event.
158 base::ListValue* bounds_list = new base::ListValue(); 159 base::ListValue* bounds_list = new base::ListValue();
159 for (size_t i = 0; i < bounds.size(); ++i) { 160 for (size_t i = 0; i < bounds.size(); ++i) {
160 base::DictionaryValue* bounds_value = new base::DictionaryValue(); 161 base::DictionaryValue* bounds_value = new base::DictionaryValue();
161 bounds_value->SetInteger("x", bounds[i].x()); 162 bounds_value->SetInteger("x", bounds[i].x());
162 bounds_value->SetInteger("y", bounds[i].y()); 163 bounds_value->SetInteger("y", bounds[i].y());
163 bounds_value->SetInteger("w", bounds[i].width()); 164 bounds_value->SetInteger("w", bounds[i].width());
164 bounds_value->SetInteger("h", bounds[i].height()); 165 bounds_value->SetInteger("h", bounds[i].height());
165 bounds_list->Append(bounds_value); 166 bounds_list->Append(bounds_value);
166 } 167 }
167 168
168 if (bounds_list->GetSize() <= 0) 169 if (bounds_list->GetSize() <= 0)
169 return; 170 return;
170 scoped_ptr<base::ListValue> args(new base::ListValue()); 171 scoped_ptr<base::ListValue> args(new base::ListValue());
171 172
172 // The old extension code uses the first parameter to get the bounds of the 173 // The old extension code uses the first parameter to get the bounds of the
173 // first composition character, so for backward compatibility, add it here. 174 // first composition character, so for backward compatibility, add it here.
174 base::Value* first_value = NULL; 175 base::Value* first_value = NULL;
175 if (bounds_list->Get(0, &first_value)) 176 if (bounds_list->Get(0, &first_value))
176 args->Append(first_value->DeepCopy()); 177 args->Append(first_value->DeepCopy());
177 args->Append(bounds_list); 178 args->Append(bounds_list);
178 179
179 DispatchEventToExtension( 180 DispatchEventToExtension(
180 extensions::events::INPUT_METHOD_PRIVATE_ON_COMPOSITION_BOUNDS_CHANGED, 181 extensions::events::INPUT_METHOD_PRIVATE_ON_COMPOSITION_BOUNDS_CHANGED,
181 kOnCompositionBoundsChangedEventName, std::move(args)); 182 OnCompositionBoundsChanged::kEventName, std::move(args));
182 } 183 }
183 184
184 private: 185 private:
185 // ui::ImeObserver overrides. 186 // ui::ImeObserver overrides.
186 void DispatchEventToExtension( 187 void DispatchEventToExtension(
187 extensions::events::HistogramValue histogram_value, 188 extensions::events::HistogramValue histogram_value,
188 const std::string& event_name, 189 const std::string& event_name,
189 scoped_ptr<base::ListValue> args) override { 190 scoped_ptr<base::ListValue> args) override {
190 if (event_name != input_ime::OnActivate::kEventName) { 191 if (event_name != input_ime::OnActivate::kEventName) {
191 // For suspended IME extension (e.g. XKB extension), don't awake it by IME 192 // For suspended IME extension (e.g. XKB extension), don't awake it by IME
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 IMEEngineHandlerInterface* engine = 699 IMEEngineHandlerInterface* engine =
699 GetInputImeEventRouter( 700 GetInputImeEventRouter(
700 Profile::FromBrowserContext(details.browser_context)) 701 Profile::FromBrowserContext(details.browser_context))
701 ->GetActiveEngine(details.extension_id); 702 ->GetActiveEngine(details.extension_id);
702 // Notifies the IME extension for IME ready with onActivate/onFocus events. 703 // Notifies the IME extension for IME ready with onActivate/onFocus events.
703 if (engine) 704 if (engine)
704 engine->Enable(engine->GetActiveComponentId()); 705 engine->Enable(engine->GetActiveComponentId());
705 } 706 }
706 707
707 } // namespace extensions 708 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698