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

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

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const IMEEngineHandlerInterface::InputContext& context) override { 90 const IMEEngineHandlerInterface::InputContext& context) override {
91 if (extension_id_.empty() || 91 if (extension_id_.empty() ||
92 !HasListener(input_ime::OnInputContextUpdate::kEventName)) 92 !HasListener(input_ime::OnInputContextUpdate::kEventName))
93 return; 93 return;
94 94
95 input_ime::InputContext context_value; 95 input_ime::InputContext context_value;
96 context_value.context_id = context.id; 96 context_value.context_id = context.id;
97 context_value.type = 97 context_value.type =
98 input_ime::ParseInputContextType(ConvertInputContextType(context)); 98 input_ime::ParseInputContextType(ConvertInputContextType(context));
99 99
100 scoped_ptr<base::ListValue> args( 100 std::unique_ptr<base::ListValue> args(
101 input_ime::OnInputContextUpdate::Create(context_value)); 101 input_ime::OnInputContextUpdate::Create(context_value));
102 102
103 DispatchEventToExtension( 103 DispatchEventToExtension(
104 extensions::events::INPUT_IME_ON_INPUT_CONTEXT_UPDATE, 104 extensions::events::INPUT_IME_ON_INPUT_CONTEXT_UPDATE,
105 input_ime::OnInputContextUpdate::kEventName, std::move(args)); 105 input_ime::OnInputContextUpdate::kEventName, std::move(args));
106 } 106 }
107 107
108 void OnCandidateClicked( 108 void OnCandidateClicked(
109 const std::string& component_id, 109 const std::string& component_id,
110 int candidate_id, 110 int candidate_id,
(...skipping 12 matching lines...) Expand all
123 button_enum = input_ime::MOUSE_BUTTON_RIGHT; 123 button_enum = input_ime::MOUSE_BUTTON_RIGHT;
124 break; 124 break;
125 125
126 case InputMethodEngineBase::MOUSE_BUTTON_LEFT: 126 case InputMethodEngineBase::MOUSE_BUTTON_LEFT:
127 // Default to left. 127 // Default to left.
128 default: 128 default:
129 button_enum = input_ime::MOUSE_BUTTON_LEFT; 129 button_enum = input_ime::MOUSE_BUTTON_LEFT;
130 break; 130 break;
131 } 131 }
132 132
133 scoped_ptr<base::ListValue> args(input_ime::OnCandidateClicked::Create( 133 std::unique_ptr<base::ListValue> args(input_ime::OnCandidateClicked::Create(
134 component_id, candidate_id, button_enum)); 134 component_id, candidate_id, button_enum));
135 135
136 DispatchEventToExtension(extensions::events::INPUT_IME_ON_CANDIDATE_CLICKED, 136 DispatchEventToExtension(extensions::events::INPUT_IME_ON_CANDIDATE_CLICKED,
137 input_ime::OnCandidateClicked::kEventName, 137 input_ime::OnCandidateClicked::kEventName,
138 std::move(args)); 138 std::move(args));
139 } 139 }
140 140
141 void OnMenuItemActivated(const std::string& component_id, 141 void OnMenuItemActivated(const std::string& component_id,
142 const std::string& menu_id) override { 142 const std::string& menu_id) override {
143 if (extension_id_.empty() || 143 if (extension_id_.empty() ||
144 !HasListener(input_ime::OnMenuItemActivated::kEventName)) 144 !HasListener(input_ime::OnMenuItemActivated::kEventName))
145 return; 145 return;
146 146
147 scoped_ptr<base::ListValue> args( 147 std::unique_ptr<base::ListValue> args(
148 input_ime::OnMenuItemActivated::Create(component_id, menu_id)); 148 input_ime::OnMenuItemActivated::Create(component_id, menu_id));
149 149
150 DispatchEventToExtension( 150 DispatchEventToExtension(
151 extensions::events::INPUT_IME_ON_MENU_ITEM_ACTIVATED, 151 extensions::events::INPUT_IME_ON_MENU_ITEM_ACTIVATED,
152 input_ime::OnMenuItemActivated::kEventName, std::move(args)); 152 input_ime::OnMenuItemActivated::kEventName, std::move(args));
153 } 153 }
154 154
155 void OnCompositionBoundsChanged( 155 void OnCompositionBoundsChanged(
156 const std::vector<gfx::Rect>& bounds) override { 156 const std::vector<gfx::Rect>& bounds) override {
157 if (extension_id_.empty() || 157 if (extension_id_.empty() ||
158 !HasListener(OnCompositionBoundsChanged::kEventName)) 158 !HasListener(OnCompositionBoundsChanged::kEventName))
159 return; 159 return;
160 160
161 // Note: this is a private API event. 161 // Note: this is a private API event.
162 base::ListValue* bounds_list = new base::ListValue(); 162 base::ListValue* bounds_list = new base::ListValue();
163 for (size_t i = 0; i < bounds.size(); ++i) { 163 for (size_t i = 0; i < bounds.size(); ++i) {
164 base::DictionaryValue* bounds_value = new base::DictionaryValue(); 164 base::DictionaryValue* bounds_value = new base::DictionaryValue();
165 bounds_value->SetInteger("x", bounds[i].x()); 165 bounds_value->SetInteger("x", bounds[i].x());
166 bounds_value->SetInteger("y", bounds[i].y()); 166 bounds_value->SetInteger("y", bounds[i].y());
167 bounds_value->SetInteger("w", bounds[i].width()); 167 bounds_value->SetInteger("w", bounds[i].width());
168 bounds_value->SetInteger("h", bounds[i].height()); 168 bounds_value->SetInteger("h", bounds[i].height());
169 bounds_list->Append(bounds_value); 169 bounds_list->Append(bounds_value);
170 } 170 }
171 171
172 if (bounds_list->GetSize() <= 0) 172 if (bounds_list->GetSize() <= 0)
173 return; 173 return;
174 scoped_ptr<base::ListValue> args(new base::ListValue()); 174 std::unique_ptr<base::ListValue> args(new base::ListValue());
175 175
176 // The old extension code uses the first parameter to get the bounds of the 176 // The old extension code uses the first parameter to get the bounds of the
177 // first composition character, so for backward compatibility, add it here. 177 // first composition character, so for backward compatibility, add it here.
178 base::Value* first_value = NULL; 178 base::Value* first_value = NULL;
179 if (bounds_list->Get(0, &first_value)) 179 if (bounds_list->Get(0, &first_value))
180 args->Append(first_value->DeepCopy()); 180 args->Append(first_value->DeepCopy());
181 args->Append(bounds_list); 181 args->Append(bounds_list);
182 182
183 DispatchEventToExtension( 183 DispatchEventToExtension(
184 extensions::events::INPUT_METHOD_PRIVATE_ON_COMPOSITION_BOUNDS_CHANGED, 184 extensions::events::INPUT_METHOD_PRIVATE_ON_COMPOSITION_BOUNDS_CHANGED,
185 OnCompositionBoundsChanged::kEventName, std::move(args)); 185 OnCompositionBoundsChanged::kEventName, std::move(args));
186 } 186 }
187 187
188 private: 188 private:
189 // ui::ImeObserver overrides. 189 // ui::ImeObserver overrides.
190 void DispatchEventToExtension( 190 void DispatchEventToExtension(
191 extensions::events::HistogramValue histogram_value, 191 extensions::events::HistogramValue histogram_value,
192 const std::string& event_name, 192 const std::string& event_name,
193 scoped_ptr<base::ListValue> args) override { 193 std::unique_ptr<base::ListValue> args) override {
194 if (event_name != input_ime::OnActivate::kEventName) { 194 if (event_name != input_ime::OnActivate::kEventName) {
195 // For suspended IME extension (e.g. XKB extension), don't awake it by IME 195 // For suspended IME extension (e.g. XKB extension), don't awake it by IME
196 // events except onActivate. The IME extension should be awake by other 196 // events except onActivate. The IME extension should be awake by other
197 // events (e.g. runtime.onMessage) from its other pages. 197 // events (e.g. runtime.onMessage) from its other pages.
198 // This is to save memory for steady state Chrome OS on which the users 198 // This is to save memory for steady state Chrome OS on which the users
199 // don't want any IME features. 199 // don't want any IME features.
200 extensions::ExtensionSystem* extension_system = 200 extensions::ExtensionSystem* extension_system =
201 extensions::ExtensionSystem::Get(profile_); 201 extensions::ExtensionSystem::Get(profile_);
202 if (extension_system) { 202 if (extension_system) {
203 const extensions::Extension* extension = 203 const extensions::Extension* extension =
204 extension_system->extension_service()->GetExtensionById( 204 extension_system->extension_service()->GetExtensionById(
205 extension_id_, false /* include_disabled */); 205 extension_id_, false /* include_disabled */);
206 if (!extension) 206 if (!extension)
207 return; 207 return;
208 extensions::ProcessManager* process_manager = 208 extensions::ProcessManager* process_manager =
209 extensions::ProcessManager::Get(profile_); 209 extensions::ProcessManager::Get(profile_);
210 if (extensions::BackgroundInfo::HasBackgroundPage(extension) && 210 if (extensions::BackgroundInfo::HasBackgroundPage(extension) &&
211 !process_manager->GetBackgroundHostForExtension(extension_id_)) { 211 !process_manager->GetBackgroundHostForExtension(extension_id_)) {
212 return; 212 return;
213 } 213 }
214 } 214 }
215 } 215 }
216 216
217 scoped_ptr<extensions::Event> event( 217 std::unique_ptr<extensions::Event> event(
218 new extensions::Event(histogram_value, event_name, std::move(args))); 218 new extensions::Event(histogram_value, event_name, std::move(args)));
219 event->restrict_to_browser_context = profile_; 219 event->restrict_to_browser_context = profile_;
220 extensions::EventRouter::Get(profile_) 220 extensions::EventRouter::Get(profile_)
221 ->DispatchEventToExtension(extension_id_, std::move(event)); 221 ->DispatchEventToExtension(extension_id_, std::move(event));
222 } 222 }
223 223
224 // The component IME extensions need to know the current screen type (e.g. 224 // The component IME extensions need to know the current screen type (e.g.
225 // lock screen, login screen, etc.) so that its on-screen keyboard page 225 // lock screen, login screen, etc.) so that its on-screen keyboard page
226 // won't open new windows/pages. See crbug.com/395621. 226 // won't open new windows/pages. See crbug.com/395621.
227 std::string GetCurrentScreenType() override { 227 std::string GetCurrentScreenType() override {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 309 }
310 310
311 Profile* profile = GetProfile(); 311 Profile* profile = GetProfile();
312 312
313 if (chromeos::input_method::InputMethodManager::Get()->GetUISessionState() == 313 if (chromeos::input_method::InputMethodManager::Get()->GetUISessionState() ==
314 chromeos::input_method::InputMethodManager::STATE_LOGIN_SCREEN && 314 chromeos::input_method::InputMethodManager::STATE_LOGIN_SCREEN &&
315 profile->HasOffTheRecordProfile()) { 315 profile->HasOffTheRecordProfile()) {
316 profile = profile->GetOffTheRecordProfile(); 316 profile = profile->GetOffTheRecordProfile();
317 } 317 }
318 318
319 scoped_ptr<InputMethodEngineBase::Observer> observer( 319 std::unique_ptr<InputMethodEngineBase::Observer> observer(
320 new ImeObserverChromeOS(extension_id, profile)); 320 new ImeObserverChromeOS(extension_id, profile));
321 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine(); 321 chromeos::InputMethodEngine* engine = new chromeos::InputMethodEngine();
322 engine->Initialize(std::move(observer), extension_id.c_str(), profile); 322 engine->Initialize(std::move(observer), extension_id.c_str(), profile);
323 engine_map_[extension_id] = engine; 323 engine_map_[extension_id] = engine;
324 chromeos::UserSessionManager::GetInstance() 324 chromeos::UserSessionManager::GetInstance()
325 ->GetDefaultIMEState(profile) 325 ->GetDefaultIMEState(profile)
326 ->AddInputMethodExtension(extension_id, descriptors, engine); 326 ->AddInputMethodExtension(extension_id, descriptors, engine);
327 327
328 return true; 328 return true;
329 } 329 }
(...skipping 27 matching lines...) Expand all
357 } 357 }
358 358
359 bool InputImeClearCompositionFunction::RunSync() { 359 bool InputImeClearCompositionFunction::RunSync() {
360 InputMethodEngine* engine = GetActiveEngine( 360 InputMethodEngine* engine = GetActiveEngine(
361 Profile::FromBrowserContext(browser_context()), extension_id()); 361 Profile::FromBrowserContext(browser_context()), extension_id());
362 if (!engine) { 362 if (!engine) {
363 SetResult(new base::FundamentalValue(false)); 363 SetResult(new base::FundamentalValue(false));
364 return true; 364 return true;
365 } 365 }
366 366
367 scoped_ptr<ClearComposition::Params> parent_params( 367 std::unique_ptr<ClearComposition::Params> parent_params(
368 ClearComposition::Params::Create(*args_)); 368 ClearComposition::Params::Create(*args_));
369 const ClearComposition::Params::Parameters& params = 369 const ClearComposition::Params::Parameters& params =
370 parent_params->parameters; 370 parent_params->parameters;
371 371
372 SetResult(new base::FundamentalValue( 372 SetResult(new base::FundamentalValue(
373 engine->ClearComposition(params.context_id, &error_))); 373 engine->ClearComposition(params.context_id, &error_)));
374 return true; 374 return true;
375 } 375 }
376 376
377 bool InputImeHideInputViewFunction::RunAsync() { 377 bool InputImeHideInputViewFunction::RunAsync() {
378 InputMethodEngine* engine = GetActiveEngine( 378 InputMethodEngine* engine = GetActiveEngine(
379 Profile::FromBrowserContext(browser_context()), extension_id()); 379 Profile::FromBrowserContext(browser_context()), extension_id());
380 if (!engine) { 380 if (!engine) {
381 return true; 381 return true;
382 } 382 }
383 engine->HideInputView(); 383 engine->HideInputView();
384 return true; 384 return true;
385 } 385 }
386 386
387 bool InputImeSetCandidateWindowPropertiesFunction::RunSync() { 387 bool InputImeSetCandidateWindowPropertiesFunction::RunSync() {
388 scoped_ptr<SetCandidateWindowProperties::Params> parent_params( 388 std::unique_ptr<SetCandidateWindowProperties::Params> parent_params(
389 SetCandidateWindowProperties::Params::Create(*args_)); 389 SetCandidateWindowProperties::Params::Create(*args_));
390 const SetCandidateWindowProperties::Params::Parameters& 390 const SetCandidateWindowProperties::Params::Parameters&
391 params = parent_params->parameters; 391 params = parent_params->parameters;
392 392
393 InputImeEventRouter* event_router = 393 InputImeEventRouter* event_router =
394 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); 394 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));
395 InputMethodEngine* engine = 395 InputMethodEngine* engine =
396 event_router ? event_router->GetEngine(extension_id(), params.engine_id) 396 event_router ? event_router->GetEngine(extension_id(), params.engine_id)
397 : nullptr; 397 : nullptr;
398 if (!engine) { 398 if (!engine) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 457 }
458 458
459 bool InputImeSetCandidatesFunction::RunSync() { 459 bool InputImeSetCandidatesFunction::RunSync() {
460 InputMethodEngine* engine = GetActiveEngine( 460 InputMethodEngine* engine = GetActiveEngine(
461 Profile::FromBrowserContext(browser_context()), extension_id()); 461 Profile::FromBrowserContext(browser_context()), extension_id());
462 if (!engine) { 462 if (!engine) {
463 SetResult(new base::FundamentalValue(false)); 463 SetResult(new base::FundamentalValue(false));
464 return true; 464 return true;
465 } 465 }
466 466
467 scoped_ptr<SetCandidates::Params> parent_params( 467 std::unique_ptr<SetCandidates::Params> parent_params(
468 SetCandidates::Params::Create(*args_)); 468 SetCandidates::Params::Create(*args_));
469 const SetCandidates::Params::Parameters& params = 469 const SetCandidates::Params::Parameters& params =
470 parent_params->parameters; 470 parent_params->parameters;
471 471
472 std::vector<InputMethodEngine::Candidate> candidates_out; 472 std::vector<InputMethodEngine::Candidate> candidates_out;
473 for (const auto& candidate_in : params.candidates) { 473 for (const auto& candidate_in : params.candidates) {
474 candidates_out.push_back(InputMethodEngine::Candidate()); 474 candidates_out.push_back(InputMethodEngine::Candidate());
475 candidates_out.back().value = candidate_in.candidate; 475 candidates_out.back().value = candidate_in.candidate;
476 candidates_out.back().id = candidate_in.id; 476 candidates_out.back().id = candidate_in.id;
477 if (candidate_in.label) 477 if (candidate_in.label)
(...skipping 12 matching lines...) Expand all
490 } 490 }
491 491
492 bool InputImeSetCursorPositionFunction::RunSync() { 492 bool InputImeSetCursorPositionFunction::RunSync() {
493 InputMethodEngine* engine = GetActiveEngine( 493 InputMethodEngine* engine = GetActiveEngine(
494 Profile::FromBrowserContext(browser_context()), extension_id()); 494 Profile::FromBrowserContext(browser_context()), extension_id());
495 if (!engine) { 495 if (!engine) {
496 SetResult(new base::FundamentalValue(false)); 496 SetResult(new base::FundamentalValue(false));
497 return true; 497 return true;
498 } 498 }
499 499
500 scoped_ptr<SetCursorPosition::Params> parent_params( 500 std::unique_ptr<SetCursorPosition::Params> parent_params(
501 SetCursorPosition::Params::Create(*args_)); 501 SetCursorPosition::Params::Create(*args_));
502 const SetCursorPosition::Params::Parameters& params = 502 const SetCursorPosition::Params::Parameters& params =
503 parent_params->parameters; 503 parent_params->parameters;
504 504
505 SetResult(new base::FundamentalValue( 505 SetResult(new base::FundamentalValue(
506 engine->SetCursorPosition(params.context_id, params.candidate_id, 506 engine->SetCursorPosition(params.context_id, params.candidate_id,
507 &error_))); 507 &error_)));
508 return true; 508 return true;
509 } 509 }
510 510
511 bool InputImeSetMenuItemsFunction::RunSync() { 511 bool InputImeSetMenuItemsFunction::RunSync() {
512 scoped_ptr<SetMenuItems::Params> parent_params( 512 std::unique_ptr<SetMenuItems::Params> parent_params(
513 SetMenuItems::Params::Create(*args_)); 513 SetMenuItems::Params::Create(*args_));
514 const SetMenuItems::Params::Parameters& params = 514 const SetMenuItems::Params::Parameters& params =
515 parent_params->parameters; 515 parent_params->parameters;
516 516
517 InputImeEventRouter* event_router = 517 InputImeEventRouter* event_router =
518 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); 518 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));
519 InputMethodEngine* engine = 519 InputMethodEngine* engine =
520 event_router ? event_router->GetEngine(extension_id(), params.engine_id) 520 event_router ? event_router->GetEngine(extension_id(), params.engine_id)
521 : nullptr; 521 : nullptr;
522 if (!engine) { 522 if (!engine) {
523 error_ = kErrorEngineNotAvailable; 523 error_ = kErrorEngineNotAvailable;
524 return false; 524 return false;
525 } 525 }
526 526
527 std::vector<chromeos::input_method::InputMethodManager::MenuItem> items_out; 527 std::vector<chromeos::input_method::InputMethodManager::MenuItem> items_out;
528 for (const input_ime::MenuItem& item_in : params.items) { 528 for (const input_ime::MenuItem& item_in : params.items) {
529 items_out.push_back(chromeos::input_method::InputMethodManager::MenuItem()); 529 items_out.push_back(chromeos::input_method::InputMethodManager::MenuItem());
530 SetMenuItemToMenu(item_in, &items_out.back()); 530 SetMenuItemToMenu(item_in, &items_out.back());
531 } 531 }
532 532
533 if (!engine->SetMenuItems(items_out)) 533 if (!engine->SetMenuItems(items_out))
534 error_ = kErrorSetMenuItemsFail; 534 error_ = kErrorSetMenuItemsFail;
535 return true; 535 return true;
536 } 536 }
537 537
538 bool InputImeUpdateMenuItemsFunction::RunSync() { 538 bool InputImeUpdateMenuItemsFunction::RunSync() {
539 scoped_ptr<UpdateMenuItems::Params> parent_params( 539 std::unique_ptr<UpdateMenuItems::Params> parent_params(
540 UpdateMenuItems::Params::Create(*args_)); 540 UpdateMenuItems::Params::Create(*args_));
541 const UpdateMenuItems::Params::Parameters& params = 541 const UpdateMenuItems::Params::Parameters& params =
542 parent_params->parameters; 542 parent_params->parameters;
543 543
544 InputImeEventRouter* event_router = 544 InputImeEventRouter* event_router =
545 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); 545 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));
546 InputMethodEngine* engine = 546 InputMethodEngine* engine =
547 event_router ? event_router->GetEngine(extension_id(), params.engine_id) 547 event_router ? event_router->GetEngine(extension_id(), params.engine_id)
548 : nullptr; 548 : nullptr;
549 if (!engine) { 549 if (!engine) {
550 error_ = kErrorEngineNotAvailable; 550 error_ = kErrorEngineNotAvailable;
551 return false; 551 return false;
552 } 552 }
553 553
554 std::vector<chromeos::input_method::InputMethodManager::MenuItem> items_out; 554 std::vector<chromeos::input_method::InputMethodManager::MenuItem> items_out;
555 for (const input_ime::MenuItem& item_in : params.items) { 555 for (const input_ime::MenuItem& item_in : params.items) {
556 items_out.push_back(chromeos::input_method::InputMethodManager::MenuItem()); 556 items_out.push_back(chromeos::input_method::InputMethodManager::MenuItem());
557 SetMenuItemToMenu(item_in, &items_out.back()); 557 SetMenuItemToMenu(item_in, &items_out.back());
558 } 558 }
559 559
560 if (!engine->UpdateMenuItems(items_out)) 560 if (!engine->UpdateMenuItems(items_out))
561 error_ = kErrorUpdateMenuItemsFail; 561 error_ = kErrorUpdateMenuItemsFail;
562 return true; 562 return true;
563 } 563 }
564 564
565 bool InputImeDeleteSurroundingTextFunction::RunSync() { 565 bool InputImeDeleteSurroundingTextFunction::RunSync() {
566 scoped_ptr<DeleteSurroundingText::Params> parent_params( 566 std::unique_ptr<DeleteSurroundingText::Params> parent_params(
567 DeleteSurroundingText::Params::Create(*args_)); 567 DeleteSurroundingText::Params::Create(*args_));
568 const DeleteSurroundingText::Params::Parameters& params = 568 const DeleteSurroundingText::Params::Parameters& params =
569 parent_params->parameters; 569 parent_params->parameters;
570 570
571 InputImeEventRouter* event_router = 571 InputImeEventRouter* event_router =
572 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); 572 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));
573 InputMethodEngine* engine = 573 InputMethodEngine* engine =
574 event_router ? event_router->GetEngine(extension_id(), params.engine_id) 574 event_router ? event_router->GetEngine(extension_id(), params.engine_id)
575 : nullptr; 575 : nullptr;
576 if (!engine) { 576 if (!engine) {
(...skipping 13 matching lines...) Expand all
590 ->GetActiveIMEState() 590 ->GetActiveIMEState()
591 ->GetCurrentInputMethod(); 591 ->GetCurrentInputMethod();
592 std::string active_extension_id = 592 std::string active_extension_id =
593 chromeos::extension_ime_util::GetExtensionIDFromInputMethodID( 593 chromeos::extension_ime_util::GetExtensionIDFromInputMethodID(
594 current_input_method.id()); 594 current_input_method.id());
595 InputMethodEngine* engine = GetActiveEngine( 595 InputMethodEngine* engine = GetActiveEngine(
596 Profile::FromBrowserContext(browser_context()), active_extension_id); 596 Profile::FromBrowserContext(browser_context()), active_extension_id);
597 if (!engine) 597 if (!engine)
598 return RespondNow(Error(kErrorEngineNotAvailable)); 598 return RespondNow(Error(kErrorEngineNotAvailable));
599 599
600 scoped_ptr<NotifyImeMenuItemActivated::Params> params( 600 std::unique_ptr<NotifyImeMenuItemActivated::Params> params(
601 NotifyImeMenuItemActivated::Params::Create(*args_)); 601 NotifyImeMenuItemActivated::Params::Create(*args_));
602 if (params->engine_id != engine->GetActiveComponentId()) 602 if (params->engine_id != engine->GetActiveComponentId())
603 return RespondNow(Error(kErrorEngineNotActive)); 603 return RespondNow(Error(kErrorEngineNotActive));
604 engine->PropertyActivate(params->name); 604 engine->PropertyActivate(params->name);
605 return RespondNow(NoArguments()); 605 return RespondNow(NoArguments());
606 } 606 }
607 607
608 void InputImeAPI::OnExtensionLoaded(content::BrowserContext* browser_context, 608 void InputImeAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
609 const Extension* extension) { 609 const Extension* extension) {
610 const std::vector<InputComponentInfo>* input_components = 610 const std::vector<InputComponentInfo>* input_components =
(...skipping 24 matching lines...) Expand all
635 return; 635 return;
636 InputMethodEngine* engine = 636 InputMethodEngine* engine =
637 GetActiveEngine(Profile::FromBrowserContext(details.browser_context), 637 GetActiveEngine(Profile::FromBrowserContext(details.browser_context),
638 details.extension_id); 638 details.extension_id);
639 // Notifies the IME extension for IME ready with onActivate/onFocus events. 639 // Notifies the IME extension for IME ready with onActivate/onFocus events.
640 if (engine) 640 if (engine)
641 engine->Enable(engine->GetActiveComponentId()); 641 engine->Enable(engine->GetActiveComponentId());
642 } 642 }
643 643
644 } // namespace extensions 644 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698