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

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

Issue 2360073002: [Extensions] Isolate ExtensionFunction results_ and error_ (Closed)
Patch Set: errorwithargs Created 4 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/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/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/common/extensions/api/input_ime.h" 9 #include "chrome/common/extensions/api/input_ime.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 segment_info.style = 311 segment_info.style =
312 InputMethodEngineBase::SEGMENT_STYLE_NO_UNDERLINE; 312 InputMethodEngineBase::SEGMENT_STYLE_NO_UNDERLINE;
313 } 313 }
314 segments.push_back(segment_info); 314 segments.push_back(segment_info);
315 } 315 }
316 } 316 }
317 int selection_start = 317 int selection_start =
318 params.selection_start ? *params.selection_start : params.cursor; 318 params.selection_start ? *params.selection_start : params.cursor;
319 int selection_end = 319 int selection_end =
320 params.selection_end ? *params.selection_end : params.cursor; 320 params.selection_end ? *params.selection_end : params.cursor;
321 std::string error;
321 success = engine->SetComposition(params.context_id, params.text.c_str(), 322 success = engine->SetComposition(params.context_id, params.text.c_str(),
322 selection_start, selection_end, 323 selection_start, selection_end,
323 params.cursor, segments, &error_); 324 params.cursor, segments, &error);
325 SetError(error);
324 } 326 }
325 std::unique_ptr<base::ListValue> output = 327 std::unique_ptr<base::ListValue> output =
326 SetComposition::Results::Create(success); 328 SetComposition::Results::Create(success);
327 return RespondNow(ArgumentList(std::move(output))); 329 return RespondNow(ArgumentList(std::move(output)));
328 } 330 }
329 331
330 ExtensionFunction::ResponseAction InputImeCommitTextFunction::Run() { 332 ExtensionFunction::ResponseAction InputImeCommitTextFunction::Run() {
331 bool success = false; 333 bool success = false;
332 InputImeEventRouter* event_router = 334 InputImeEventRouter* event_router =
333 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); 335 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));
334 InputMethodEngineBase* engine = 336 InputMethodEngineBase* engine =
335 event_router ? event_router->GetActiveEngine(extension_id()) : nullptr; 337 event_router ? event_router->GetActiveEngine(extension_id()) : nullptr;
336 if (engine) { 338 if (engine) {
337 std::unique_ptr<CommitText::Params> parent_params( 339 std::unique_ptr<CommitText::Params> parent_params(
338 CommitText::Params::Create(*args_)); 340 CommitText::Params::Create(*args_));
339 const CommitText::Params::Parameters& params = parent_params->parameters; 341 const CommitText::Params::Parameters& params = parent_params->parameters;
342 std::string error;
340 success = 343 success =
341 engine->CommitText(params.context_id, params.text.c_str(), &error_); 344 engine->CommitText(params.context_id, params.text.c_str(), &error);
345 SetError(error);
342 } 346 }
343 std::unique_ptr<base::ListValue> output = 347 std::unique_ptr<base::ListValue> output =
344 CommitText::Results::Create(success); 348 CommitText::Results::Create(success);
345 return RespondNow(ArgumentList(std::move(output))); 349 return RespondNow(ArgumentList(std::move(output)));
346 } 350 }
347 351
348 ExtensionFunction::ResponseAction InputImeSendKeyEventsFunction::Run() { 352 ExtensionFunction::ResponseAction InputImeSendKeyEventsFunction::Run() {
349 InputImeEventRouter* event_router = 353 InputImeEventRouter* event_router =
350 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); 354 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));
351 InputMethodEngineBase* engine = 355 InputMethodEngineBase* engine =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { 414 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) {
411 if (!profile) 415 if (!profile)
412 return nullptr; 416 return nullptr;
413 if (profile->HasOffTheRecordProfile()) 417 if (profile->HasOffTheRecordProfile())
414 profile = profile->GetOffTheRecordProfile(); 418 profile = profile->GetOffTheRecordProfile();
415 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( 419 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter(
416 profile); 420 profile);
417 } 421 }
418 422
419 } // namespace extensions 423 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698