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/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 engine_id_(engine_id) { | 104 engine_id_(engine_id) { |
105 } | 105 } |
106 | 106 |
107 virtual ~ImeObserver() {} | 107 virtual ~ImeObserver() {} |
108 | 108 |
109 virtual void OnActivate(const std::string& engine_id) OVERRIDE { | 109 virtual void OnActivate(const std::string& engine_id) OVERRIDE { |
110 if (profile_ == NULL || extension_id_.empty()) | 110 if (profile_ == NULL || extension_id_.empty()) |
111 return; | 111 return; |
112 | 112 |
113 scoped_ptr<base::ListValue> args(new base::ListValue()); | 113 scoped_ptr<base::ListValue> args(new base::ListValue()); |
114 args->Append(Value::CreateStringValue(engine_id)); | 114 args->Append(new base::StringValue(engine_id)); |
115 | 115 |
116 DispatchEventToExtension(profile_, extension_id_, | 116 DispatchEventToExtension(profile_, extension_id_, |
117 events::kOnActivate, args.Pass()); | 117 events::kOnActivate, args.Pass()); |
118 } | 118 } |
119 | 119 |
120 virtual void OnDeactivated(const std::string& engine_id) OVERRIDE { | 120 virtual void OnDeactivated(const std::string& engine_id) OVERRIDE { |
121 if (profile_ == NULL || extension_id_.empty()) | 121 if (profile_ == NULL || extension_id_.empty()) |
122 return; | 122 return; |
123 | 123 |
124 scoped_ptr<base::ListValue> args(new base::ListValue()); | 124 scoped_ptr<base::ListValue> args(new base::ListValue()); |
125 args->Append(Value::CreateStringValue(engine_id)); | 125 args->Append(new base::StringValue(engine_id)); |
126 | 126 |
127 DispatchEventToExtension(profile_, extension_id_, | 127 DispatchEventToExtension(profile_, extension_id_, |
128 events::kOnDeactivated, args.Pass()); | 128 events::kOnDeactivated, args.Pass()); |
129 } | 129 } |
130 | 130 |
131 virtual void OnFocus( | 131 virtual void OnFocus( |
132 const InputMethodEngine::InputContext& context) OVERRIDE { | 132 const InputMethodEngine::InputContext& context) OVERRIDE { |
133 if (profile_ == NULL || extension_id_.empty()) | 133 if (profile_ == NULL || extension_id_.empty()) |
134 return; | 134 return; |
135 | 135 |
136 base::DictionaryValue* dict = new base::DictionaryValue(); | 136 base::DictionaryValue* dict = new base::DictionaryValue(); |
137 dict->SetInteger("contextID", context.id); | 137 dict->SetInteger("contextID", context.id); |
138 dict->SetString("type", context.type); | 138 dict->SetString("type", context.type); |
139 | 139 |
140 scoped_ptr<base::ListValue> args(new base::ListValue()); | 140 scoped_ptr<base::ListValue> args(new base::ListValue()); |
141 args->Append(dict); | 141 args->Append(dict); |
142 | 142 |
143 DispatchEventToExtension(profile_, extension_id_, | 143 DispatchEventToExtension(profile_, extension_id_, |
144 events::kOnFocus, args.Pass()); | 144 events::kOnFocus, args.Pass()); |
145 } | 145 } |
146 | 146 |
147 virtual void OnBlur(int context_id) OVERRIDE { | 147 virtual void OnBlur(int context_id) OVERRIDE { |
148 if (profile_ == NULL || extension_id_.empty()) | 148 if (profile_ == NULL || extension_id_.empty()) |
149 return; | 149 return; |
150 | 150 |
151 scoped_ptr<base::ListValue> args(new base::ListValue()); | 151 scoped_ptr<base::ListValue> args(new base::ListValue()); |
152 args->Append(Value::CreateIntegerValue(context_id)); | 152 args->Append(new base::FundamentalValue(context_id)); |
153 | 153 |
154 DispatchEventToExtension(profile_, extension_id_, | 154 DispatchEventToExtension(profile_, extension_id_, |
155 events::kOnBlur, args.Pass()); | 155 events::kOnBlur, args.Pass()); |
156 } | 156 } |
157 | 157 |
158 virtual void OnInputContextUpdate( | 158 virtual void OnInputContextUpdate( |
159 const InputMethodEngine::InputContext& context) OVERRIDE { | 159 const InputMethodEngine::InputContext& context) OVERRIDE { |
160 if (profile_ == NULL || extension_id_.empty()) | 160 if (profile_ == NULL || extension_id_.empty()) |
161 return; | 161 return; |
162 | 162 |
(...skipping 23 matching lines...) Expand all Loading... |
186 dict->SetString("type", event.type); | 186 dict->SetString("type", event.type); |
187 dict->SetString("requestId", request_id); | 187 dict->SetString("requestId", request_id); |
188 dict->SetString("key", event.key); | 188 dict->SetString("key", event.key); |
189 dict->SetString("code", event.code); | 189 dict->SetString("code", event.code); |
190 dict->SetBoolean("altKey", event.alt_key); | 190 dict->SetBoolean("altKey", event.alt_key); |
191 dict->SetBoolean("ctrlKey", event.ctrl_key); | 191 dict->SetBoolean("ctrlKey", event.ctrl_key); |
192 dict->SetBoolean("shiftKey", event.shift_key); | 192 dict->SetBoolean("shiftKey", event.shift_key); |
193 dict->SetBoolean("capsLock", event.caps_lock); | 193 dict->SetBoolean("capsLock", event.caps_lock); |
194 | 194 |
195 scoped_ptr<base::ListValue> args(new base::ListValue()); | 195 scoped_ptr<base::ListValue> args(new base::ListValue()); |
196 args->Append(Value::CreateStringValue(engine_id)); | 196 args->Append(new base::StringValue(engine_id)); |
197 args->Append(dict); | 197 args->Append(dict); |
198 | 198 |
199 DispatchEventToExtension(profile_, extension_id_, | 199 DispatchEventToExtension(profile_, extension_id_, |
200 events::kOnKeyEvent, args.Pass()); | 200 events::kOnKeyEvent, args.Pass()); |
201 } | 201 } |
202 | 202 |
203 virtual void OnCandidateClicked( | 203 virtual void OnCandidateClicked( |
204 const std::string& engine_id, | 204 const std::string& engine_id, |
205 int candidate_id, | 205 int candidate_id, |
206 chromeos::InputMethodEngine::MouseButtonEvent button) OVERRIDE { | 206 chromeos::InputMethodEngine::MouseButtonEvent button) OVERRIDE { |
207 if (profile_ == NULL || extension_id_.empty()) | 207 if (profile_ == NULL || extension_id_.empty()) |
208 return; | 208 return; |
209 | 209 |
210 scoped_ptr<base::ListValue> args(new base::ListValue()); | 210 scoped_ptr<base::ListValue> args(new base::ListValue()); |
211 args->Append(Value::CreateStringValue(engine_id)); | 211 args->Append(new base::StringValue(engine_id)); |
212 args->Append(Value::CreateIntegerValue(candidate_id)); | 212 args->Append(new base::FundamentalValue(candidate_id)); |
213 switch (button) { | 213 switch (button) { |
214 case chromeos::InputMethodEngine::MOUSE_BUTTON_MIDDLE: | 214 case chromeos::InputMethodEngine::MOUSE_BUTTON_MIDDLE: |
215 args->Append(Value::CreateStringValue("middle")); | 215 args->Append(new base::StringValue("middle")); |
216 break; | 216 break; |
217 | 217 |
218 case chromeos::InputMethodEngine::MOUSE_BUTTON_RIGHT: | 218 case chromeos::InputMethodEngine::MOUSE_BUTTON_RIGHT: |
219 args->Append(Value::CreateStringValue("right")); | 219 args->Append(new base::StringValue("right")); |
220 break; | 220 break; |
221 | 221 |
222 case chromeos::InputMethodEngine::MOUSE_BUTTON_LEFT: | 222 case chromeos::InputMethodEngine::MOUSE_BUTTON_LEFT: |
223 // Default to left. | 223 // Default to left. |
224 default: | 224 default: |
225 args->Append(Value::CreateStringValue("left")); | 225 args->Append(new base::StringValue("left")); |
226 break; | 226 break; |
227 } | 227 } |
228 | 228 |
229 DispatchEventToExtension(profile_, extension_id_, | 229 DispatchEventToExtension(profile_, extension_id_, |
230 events::kOnCandidateClicked, args.Pass()); | 230 events::kOnCandidateClicked, args.Pass()); |
231 } | 231 } |
232 | 232 |
233 virtual void OnMenuItemActivated(const std::string& engine_id, | 233 virtual void OnMenuItemActivated(const std::string& engine_id, |
234 const std::string& menu_id) OVERRIDE { | 234 const std::string& menu_id) OVERRIDE { |
235 if (profile_ == NULL || extension_id_.empty()) | 235 if (profile_ == NULL || extension_id_.empty()) |
236 return; | 236 return; |
237 | 237 |
238 scoped_ptr<base::ListValue> args(new base::ListValue()); | 238 scoped_ptr<base::ListValue> args(new base::ListValue()); |
239 args->Append(Value::CreateStringValue(engine_id)); | 239 args->Append(new base::StringValue(engine_id)); |
240 args->Append(Value::CreateStringValue(menu_id)); | 240 args->Append(new base::StringValue(menu_id)); |
241 | 241 |
242 DispatchEventToExtension(profile_, extension_id_, | 242 DispatchEventToExtension(profile_, extension_id_, |
243 events::kOnMenuItemActivated, args.Pass()); | 243 events::kOnMenuItemActivated, args.Pass()); |
244 } | 244 } |
245 | 245 |
246 virtual void OnSurroundingTextChanged(const std::string& engine_id, | 246 virtual void OnSurroundingTextChanged(const std::string& engine_id, |
247 const std::string& text, | 247 const std::string& text, |
248 int cursor_pos, | 248 int cursor_pos, |
249 int anchor_pos) OVERRIDE { | 249 int anchor_pos) OVERRIDE { |
250 if (profile_ == NULL || extension_id_.empty()) | 250 if (profile_ == NULL || extension_id_.empty()) |
251 return; | 251 return; |
252 base::DictionaryValue* dict = new base::DictionaryValue(); | 252 base::DictionaryValue* dict = new base::DictionaryValue(); |
253 dict->SetString("text", text); | 253 dict->SetString("text", text); |
254 dict->SetInteger("focus", cursor_pos); | 254 dict->SetInteger("focus", cursor_pos); |
255 dict->SetInteger("anchor", anchor_pos); | 255 dict->SetInteger("anchor", anchor_pos); |
256 | 256 |
257 scoped_ptr<ListValue> args(new base::ListValue); | 257 scoped_ptr<ListValue> args(new base::ListValue); |
258 args->Append(Value::CreateStringValue(engine_id)); | 258 args->Append(new base::StringValue(engine_id)); |
259 args->Append(dict); | 259 args->Append(dict); |
260 | 260 |
261 DispatchEventToExtension(profile_, extension_id_, | 261 DispatchEventToExtension(profile_, extension_id_, |
262 events::kOnSurroundingTextChanged, args.Pass()); | 262 events::kOnSurroundingTextChanged, args.Pass()); |
263 } | 263 } |
264 | 264 |
265 virtual void OnReset(const std::string& engine_id) OVERRIDE { | 265 virtual void OnReset(const std::string& engine_id) OVERRIDE { |
266 if (profile_ == NULL || extension_id_.empty()) | 266 if (profile_ == NULL || extension_id_.empty()) |
267 return; | 267 return; |
268 scoped_ptr<base::ListValue> args(new base::ListValue()); | 268 scoped_ptr<base::ListValue> args(new base::ListValue()); |
269 args->Append(Value::CreateStringValue(engine_id)); | 269 args->Append(new base::StringValue(engine_id)); |
270 | 270 |
271 DispatchEventToExtension(profile_, extension_id_, | 271 DispatchEventToExtension(profile_, extension_id_, |
272 events::kOnReset, args.Pass()); | 272 events::kOnReset, args.Pass()); |
273 } | 273 } |
274 | 274 |
275 private: | 275 private: |
276 Profile* profile_; | 276 Profile* profile_; |
277 std::string extension_id_; | 277 std::string extension_id_; |
278 std::string engine_id_; | 278 std::string engine_id_; |
279 | 279 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 InputImeEventRouter::InputImeEventRouter() | 429 InputImeEventRouter::InputImeEventRouter() |
430 : next_request_id_(1) { | 430 : next_request_id_(1) { |
431 } | 431 } |
432 | 432 |
433 InputImeEventRouter::~InputImeEventRouter() {} | 433 InputImeEventRouter::~InputImeEventRouter() {} |
434 | 434 |
435 bool InputImeSetCompositionFunction::RunImpl() { | 435 bool InputImeSetCompositionFunction::RunImpl() { |
436 chromeos::InputMethodEngine* engine = | 436 chromeos::InputMethodEngine* engine = |
437 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); | 437 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); |
438 if (!engine) { | 438 if (!engine) { |
439 SetResult(Value::CreateBooleanValue(false)); | 439 SetResult(new base::FundamentalValue(false)); |
440 return true; | 440 return true; |
441 } | 441 } |
442 | 442 |
443 scoped_ptr<SetComposition::Params> parent_params( | 443 scoped_ptr<SetComposition::Params> parent_params( |
444 SetComposition::Params::Create(*args_)); | 444 SetComposition::Params::Create(*args_)); |
445 const SetComposition::Params::Parameters& params = parent_params->parameters; | 445 const SetComposition::Params::Parameters& params = parent_params->parameters; |
446 std::vector<chromeos::InputMethodEngine::SegmentInfo> segments; | 446 std::vector<chromeos::InputMethodEngine::SegmentInfo> segments; |
447 if (params.segments) { | 447 if (params.segments) { |
448 const std::vector<linked_ptr< | 448 const std::vector<linked_ptr< |
449 SetComposition::Params::Parameters::SegmentsType> >& | 449 SetComposition::Params::Parameters::SegmentsType> >& |
(...skipping 14 matching lines...) Expand all Loading... |
464 chromeos::InputMethodEngine::SEGMENT_STYLE_DOUBLE_UNDERLINE; | 464 chromeos::InputMethodEngine::SEGMENT_STYLE_DOUBLE_UNDERLINE; |
465 } | 465 } |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 int selection_start = | 469 int selection_start = |
470 params.selection_start ? *params.selection_start : params.cursor; | 470 params.selection_start ? *params.selection_start : params.cursor; |
471 int selection_end = | 471 int selection_end = |
472 params.selection_end ? *params.selection_end : params.cursor; | 472 params.selection_end ? *params.selection_end : params.cursor; |
473 | 473 |
474 SetResult(Value::CreateBooleanValue( | 474 SetResult(new base::FundamentalValue( |
475 engine->SetComposition(params.context_id, params.text.c_str(), | 475 engine->SetComposition(params.context_id, params.text.c_str(), |
476 selection_start, selection_end, params.cursor, | 476 selection_start, selection_end, params.cursor, |
477 segments, &error_))); | 477 segments, &error_))); |
478 return true; | 478 return true; |
479 } | 479 } |
480 | 480 |
481 bool InputImeClearCompositionFunction::RunImpl() { | 481 bool InputImeClearCompositionFunction::RunImpl() { |
482 chromeos::InputMethodEngine* engine = | 482 chromeos::InputMethodEngine* engine = |
483 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); | 483 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); |
484 if (!engine) { | 484 if (!engine) { |
485 SetResult(Value::CreateBooleanValue(false)); | 485 SetResult(new base::FundamentalValue(false)); |
486 return true; | 486 return true; |
487 } | 487 } |
488 | 488 |
489 scoped_ptr<ClearComposition::Params> parent_params( | 489 scoped_ptr<ClearComposition::Params> parent_params( |
490 ClearComposition::Params::Create(*args_)); | 490 ClearComposition::Params::Create(*args_)); |
491 const ClearComposition::Params::Parameters& params = | 491 const ClearComposition::Params::Parameters& params = |
492 parent_params->parameters; | 492 parent_params->parameters; |
493 | 493 |
494 SetResult(Value::CreateBooleanValue( | 494 SetResult(new base::FundamentalValue( |
495 engine->ClearComposition(params.context_id, &error_))); | 495 engine->ClearComposition(params.context_id, &error_))); |
496 return true; | 496 return true; |
497 } | 497 } |
498 | 498 |
499 bool InputImeCommitTextFunction::RunImpl() { | 499 bool InputImeCommitTextFunction::RunImpl() { |
500 // TODO(zork): Support committing when not active. | 500 // TODO(zork): Support committing when not active. |
501 chromeos::InputMethodEngine* engine = | 501 chromeos::InputMethodEngine* engine = |
502 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); | 502 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); |
503 if (!engine) { | 503 if (!engine) { |
504 SetResult(Value::CreateBooleanValue(false)); | 504 SetResult(new base::FundamentalValue(false)); |
505 return true; | 505 return true; |
506 } | 506 } |
507 | 507 |
508 scoped_ptr<CommitText::Params> parent_params( | 508 scoped_ptr<CommitText::Params> parent_params( |
509 CommitText::Params::Create(*args_)); | 509 CommitText::Params::Create(*args_)); |
510 const CommitText::Params::Parameters& params = | 510 const CommitText::Params::Parameters& params = |
511 parent_params->parameters; | 511 parent_params->parameters; |
512 | 512 |
513 SetResult(Value::CreateBooleanValue( | 513 SetResult(new base::FundamentalValue( |
514 engine->CommitText(params.context_id, params.text.c_str(), &error_))); | 514 engine->CommitText(params.context_id, params.text.c_str(), &error_))); |
515 return true; | 515 return true; |
516 } | 516 } |
517 | 517 |
518 bool InputImeSetCandidateWindowPropertiesFunction::RunImpl() { | 518 bool InputImeSetCandidateWindowPropertiesFunction::RunImpl() { |
519 scoped_ptr<SetCandidateWindowProperties::Params> parent_params( | 519 scoped_ptr<SetCandidateWindowProperties::Params> parent_params( |
520 SetCandidateWindowProperties::Params::Create(*args_)); | 520 SetCandidateWindowProperties::Params::Create(*args_)); |
521 const SetCandidateWindowProperties::Params::Parameters& | 521 const SetCandidateWindowProperties::Params::Parameters& |
522 params = parent_params->parameters; | 522 params = parent_params->parameters; |
523 | 523 |
524 chromeos::InputMethodEngine* engine = | 524 chromeos::InputMethodEngine* engine = |
525 InputImeEventRouter::GetInstance()->GetEngine(extension_id(), | 525 InputImeEventRouter::GetInstance()->GetEngine(extension_id(), |
526 params.engine_id); | 526 params.engine_id); |
527 | 527 |
528 if (!engine) { | 528 if (!engine) { |
529 SetResult(Value::CreateBooleanValue(false)); | 529 SetResult(new base::FundamentalValue(false)); |
530 return true; | 530 return true; |
531 } | 531 } |
532 | 532 |
533 const SetCandidateWindowProperties::Params::Parameters::Properties& | 533 const SetCandidateWindowProperties::Params::Parameters::Properties& |
534 properties = params.properties; | 534 properties = params.properties; |
535 | 535 |
536 if (properties.visible && | 536 if (properties.visible && |
537 !engine->SetCandidateWindowVisible(*properties.visible, &error_)) { | 537 !engine->SetCandidateWindowVisible(*properties.visible, &error_)) { |
538 SetResult(Value::CreateBooleanValue(false)); | 538 SetResult(new base::FundamentalValue(false)); |
539 return true; | 539 return true; |
540 } | 540 } |
541 | 541 |
542 if (properties.cursor_visible) | 542 if (properties.cursor_visible) |
543 engine->SetCandidateWindowCursorVisible(*properties.cursor_visible); | 543 engine->SetCandidateWindowCursorVisible(*properties.cursor_visible); |
544 | 544 |
545 if (properties.vertical) | 545 if (properties.vertical) |
546 engine->SetCandidateWindowVertical(*properties.vertical); | 546 engine->SetCandidateWindowVertical(*properties.vertical); |
547 | 547 |
548 if (properties.page_size) | 548 if (properties.page_size) |
(...skipping 12 matching lines...) Expand all Loading... |
561 WINDOW_POSITION_COMPOSITION) { | 561 WINDOW_POSITION_COMPOSITION) { |
562 engine->SetCandidateWindowPosition( | 562 engine->SetCandidateWindowPosition( |
563 chromeos::InputMethodEngine::WINDOW_POS_COMPOSITTION); | 563 chromeos::InputMethodEngine::WINDOW_POS_COMPOSITTION); |
564 } else if (properties.window_position == | 564 } else if (properties.window_position == |
565 SetCandidateWindowProperties::Params::Parameters::Properties:: | 565 SetCandidateWindowProperties::Params::Parameters::Properties:: |
566 WINDOW_POSITION_CURSOR) { | 566 WINDOW_POSITION_CURSOR) { |
567 engine->SetCandidateWindowPosition( | 567 engine->SetCandidateWindowPosition( |
568 chromeos::InputMethodEngine::WINDOW_POS_CURSOR); | 568 chromeos::InputMethodEngine::WINDOW_POS_CURSOR); |
569 } | 569 } |
570 | 570 |
571 SetResult(Value::CreateBooleanValue(true)); | 571 SetResult(new base::FundamentalValue(true)); |
572 | 572 |
573 return true; | 573 return true; |
574 } | 574 } |
575 | 575 |
576 #if defined(OS_CHROMEOS) | 576 #if defined(OS_CHROMEOS) |
577 bool InputImeSetCandidatesFunction::RunImpl() { | 577 bool InputImeSetCandidatesFunction::RunImpl() { |
578 chromeos::InputMethodEngine* engine = | 578 chromeos::InputMethodEngine* engine = |
579 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); | 579 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); |
580 if (!engine) { | 580 if (!engine) { |
581 SetResult(Value::CreateBooleanValue(false)); | 581 SetResult(new base::FundamentalValue(false)); |
582 return true; | 582 return true; |
583 } | 583 } |
584 | 584 |
585 scoped_ptr<SetCandidates::Params> parent_params( | 585 scoped_ptr<SetCandidates::Params> parent_params( |
586 SetCandidates::Params::Create(*args_)); | 586 SetCandidates::Params::Create(*args_)); |
587 const SetCandidates::Params::Parameters& params = | 587 const SetCandidates::Params::Parameters& params = |
588 parent_params->parameters; | 588 parent_params->parameters; |
589 | 589 |
590 std::vector<chromeos::InputMethodEngine::Candidate> candidates_out; | 590 std::vector<chromeos::InputMethodEngine::Candidate> candidates_out; |
591 const std::vector<linked_ptr< | 591 const std::vector<linked_ptr< |
592 SetCandidates::Params::Parameters::CandidatesType> >& candidates_in = | 592 SetCandidates::Params::Parameters::CandidatesType> >& candidates_in = |
593 params.candidates; | 593 params.candidates; |
594 for (size_t i = 0; i < candidates_in.size(); ++i) { | 594 for (size_t i = 0; i < candidates_in.size(); ++i) { |
595 candidates_out.push_back(chromeos::InputMethodEngine::Candidate()); | 595 candidates_out.push_back(chromeos::InputMethodEngine::Candidate()); |
596 candidates_out.back().value = candidates_in[i]->candidate; | 596 candidates_out.back().value = candidates_in[i]->candidate; |
597 candidates_out.back().id = candidates_in[i]->id; | 597 candidates_out.back().id = candidates_in[i]->id; |
598 if (candidates_in[i]->label) | 598 if (candidates_in[i]->label) |
599 candidates_out.back().label = *candidates_in[i]->label; | 599 candidates_out.back().label = *candidates_in[i]->label; |
600 if (candidates_in[i]->annotation) | 600 if (candidates_in[i]->annotation) |
601 candidates_out.back().annotation = *candidates_in[i]->annotation; | 601 candidates_out.back().annotation = *candidates_in[i]->annotation; |
602 if (candidates_in[i]->usage) { | 602 if (candidates_in[i]->usage) { |
603 candidates_out.back().usage.title = candidates_in[i]->usage->title; | 603 candidates_out.back().usage.title = candidates_in[i]->usage->title; |
604 candidates_out.back().usage.body = candidates_in[i]->usage->body; | 604 candidates_out.back().usage.body = candidates_in[i]->usage->body; |
605 } | 605 } |
606 } | 606 } |
607 | 607 |
608 SetResult(Value::CreateBooleanValue( | 608 SetResult(new base::FundamentalValue( |
609 engine->SetCandidates(params.context_id, candidates_out, &error_))); | 609 engine->SetCandidates(params.context_id, candidates_out, &error_))); |
610 return true; | 610 return true; |
611 } | 611 } |
612 | 612 |
613 bool InputImeSetCursorPositionFunction::RunImpl() { | 613 bool InputImeSetCursorPositionFunction::RunImpl() { |
614 chromeos::InputMethodEngine* engine = | 614 chromeos::InputMethodEngine* engine = |
615 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); | 615 InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id()); |
616 if (!engine) { | 616 if (!engine) { |
617 SetResult(Value::CreateBooleanValue(false)); | 617 SetResult(new base::FundamentalValue(false)); |
618 return true; | 618 return true; |
619 } | 619 } |
620 | 620 |
621 scoped_ptr<SetCursorPosition::Params> parent_params( | 621 scoped_ptr<SetCursorPosition::Params> parent_params( |
622 SetCursorPosition::Params::Create(*args_)); | 622 SetCursorPosition::Params::Create(*args_)); |
623 const SetCursorPosition::Params::Parameters& params = | 623 const SetCursorPosition::Params::Parameters& params = |
624 parent_params->parameters; | 624 parent_params->parameters; |
625 | 625 |
626 SetResult(Value::CreateBooleanValue( | 626 SetResult(new base::FundamentalValue( |
627 engine->SetCursorPosition(params.context_id, params.candidate_id, | 627 engine->SetCursorPosition(params.context_id, params.candidate_id, |
628 &error_))); | 628 &error_))); |
629 return true; | 629 return true; |
630 } | 630 } |
631 | 631 |
632 bool InputImeSetMenuItemsFunction::RunImpl() { | 632 bool InputImeSetMenuItemsFunction::RunImpl() { |
633 scoped_ptr<SetMenuItems::Params> parent_params( | 633 scoped_ptr<SetMenuItems::Params> parent_params( |
634 SetMenuItems::Params::Create(*args_)); | 634 SetMenuItems::Params::Create(*args_)); |
635 const SetMenuItems::Params::Parameters& params = | 635 const SetMenuItems::Params::Parameters& params = |
636 parent_params->parameters; | 636 parent_params->parameters; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 if (input_components->size() > 0) | 758 if (input_components->size() > 0) |
759 input_ime_event_router()->UnregisterAllImes(profile_, extension->id()); | 759 input_ime_event_router()->UnregisterAllImes(profile_, extension->id()); |
760 } | 760 } |
761 } | 761 } |
762 | 762 |
763 InputImeEventRouter* InputImeAPI::input_ime_event_router() { | 763 InputImeEventRouter* InputImeAPI::input_ime_event_router() { |
764 return InputImeEventRouter::GetInstance(); | 764 return InputImeEventRouter::GetInstance(); |
765 } | 765 } |
766 | 766 |
767 } // namespace extensions | 767 } // namespace extensions |
OLD | NEW |