OLD | NEW |
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 // This file is for non-chromeos (win & linux) functions, such as | 5 // This file is for non-chromeos (win & linux) functions, such as |
6 // chrome.input.ime.activate, chrome.input.ime.createWindow and | 6 // chrome.input.ime.activate, chrome.input.ime.createWindow and |
7 // chrome.input.ime.onSelectionChanged. | 7 // chrome.input.ime.onSelectionChanged. |
8 // TODO(azurewei): May refactor the code structure by using delegate or | 8 // TODO(azurewei): May refactor the code structure by using delegate or |
9 // redesign the API to remove this platform-specific file in the future. | 9 // redesign the API to remove this platform-specific file in the future. |
10 | 10 |
11 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" | 11 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/values.h" |
15 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/input_method/input_method_engine.h" | 20 #include "chrome/browser/ui/input_method/input_method_engine.h" |
19 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/extensions/api/input_ime.h" | 22 #include "chrome/common/extensions/api/input_ime.h" |
21 #include "extensions/browser/extension_prefs.h" | 23 #include "extensions/browser/extension_prefs.h" |
22 #include "ui/base/ime/ime_bridge.h" | 24 #include "ui/base/ime/ime_bridge.h" |
23 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
24 | 26 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 extension(), render_frame_host(), | 373 extension(), render_frame_host(), |
372 options.url.get() ? *options.url : url::kAboutBlankURL, | 374 options.url.get() ? *options.url : url::kAboutBlankURL, |
373 options.window_type == input_ime::WINDOW_TYPE_FOLLOWCURSOR | 375 options.window_type == input_ime::WINDOW_TYPE_FOLLOWCURSOR |
374 ? ui::ImeWindow::FOLLOW_CURSOR | 376 ? ui::ImeWindow::FOLLOW_CURSOR |
375 : ui::ImeWindow::NORMAL, | 377 : ui::ImeWindow::NORMAL, |
376 bounds, &error); | 378 bounds, &error); |
377 if (!frame_id) | 379 if (!frame_id) |
378 return RespondNow(Error(error)); | 380 return RespondNow(Error(error)); |
379 | 381 |
380 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 382 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
381 result->Set("frameId", new base::Value(frame_id)); | 383 result->Set("frameId", base::MakeUnique<base::Value>(frame_id)); |
382 | 384 |
383 return RespondNow(OneArgument(std::move(result))); | 385 return RespondNow(OneArgument(std::move(result))); |
384 } | 386 } |
385 | 387 |
386 ExtensionFunction::ResponseAction InputImeShowWindowFunction::Run() { | 388 ExtensionFunction::ResponseAction InputImeShowWindowFunction::Run() { |
387 if (!IsInputImeEnabled()) | 389 if (!IsInputImeEnabled()) |
388 return RespondNow(Error(kErrorAPIDisabled)); | 390 return RespondNow(Error(kErrorAPIDisabled)); |
389 | 391 |
390 InputMethodEngine* engine = | 392 InputMethodEngine* engine = |
391 GetActiveEngine(browser_context(), extension_id()); | 393 GetActiveEngine(browser_context(), extension_id()); |
(...skipping 17 matching lines...) Expand all Loading... |
409 return RespondNow(Error(kErrorNoActiveEngine)); | 411 return RespondNow(Error(kErrorNoActiveEngine)); |
410 | 412 |
411 std::unique_ptr<api::input_ime::HideWindow::Params> params( | 413 std::unique_ptr<api::input_ime::HideWindow::Params> params( |
412 api::input_ime::HideWindow::Params::Create(*args_)); | 414 api::input_ime::HideWindow::Params::Create(*args_)); |
413 EXTENSION_FUNCTION_VALIDATE(params.get()); | 415 EXTENSION_FUNCTION_VALIDATE(params.get()); |
414 engine->HideImeWindow(params->window_id); | 416 engine->HideImeWindow(params->window_id); |
415 return RespondNow(NoArguments()); | 417 return RespondNow(NoArguments()); |
416 } | 418 } |
417 | 419 |
418 } // namespace extensions | 420 } // namespace extensions |
OLD | NEW |