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" | |
17 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/input_method/input_method_engine.h" | 18 #include "chrome/browser/ui/input_method/input_method_engine.h" |
21 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/extensions/api/input_ime.h" | 20 #include "chrome/common/extensions/api/input_ime.h" |
23 #include "extensions/browser/extension_prefs.h" | 21 #include "extensions/browser/extension_prefs.h" |
24 #include "ui/base/ime/ime_bridge.h" | 22 #include "ui/base/ime/ime_bridge.h" |
25 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
26 | 24 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 extension(), render_frame_host(), | 371 extension(), render_frame_host(), |
374 options.url.get() ? *options.url : url::kAboutBlankURL, | 372 options.url.get() ? *options.url : url::kAboutBlankURL, |
375 options.window_type == input_ime::WINDOW_TYPE_FOLLOWCURSOR | 373 options.window_type == input_ime::WINDOW_TYPE_FOLLOWCURSOR |
376 ? ui::ImeWindow::FOLLOW_CURSOR | 374 ? ui::ImeWindow::FOLLOW_CURSOR |
377 : ui::ImeWindow::NORMAL, | 375 : ui::ImeWindow::NORMAL, |
378 bounds, &error); | 376 bounds, &error); |
379 if (!frame_id) | 377 if (!frame_id) |
380 return RespondNow(Error(error)); | 378 return RespondNow(Error(error)); |
381 | 379 |
382 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 380 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
383 result->Set("frameId", base::MakeUnique<base::Value>(frame_id)); | 381 result->Set("frameId", new base::Value(frame_id)); |
384 | 382 |
385 return RespondNow(OneArgument(std::move(result))); | 383 return RespondNow(OneArgument(std::move(result))); |
386 } | 384 } |
387 | 385 |
388 ExtensionFunction::ResponseAction InputImeShowWindowFunction::Run() { | 386 ExtensionFunction::ResponseAction InputImeShowWindowFunction::Run() { |
389 if (!IsInputImeEnabled()) | 387 if (!IsInputImeEnabled()) |
390 return RespondNow(Error(kErrorAPIDisabled)); | 388 return RespondNow(Error(kErrorAPIDisabled)); |
391 | 389 |
392 InputMethodEngine* engine = | 390 InputMethodEngine* engine = |
393 GetActiveEngine(browser_context(), extension_id()); | 391 GetActiveEngine(browser_context(), extension_id()); |
(...skipping 17 matching lines...) Expand all Loading... |
411 return RespondNow(Error(kErrorNoActiveEngine)); | 409 return RespondNow(Error(kErrorNoActiveEngine)); |
412 | 410 |
413 std::unique_ptr<api::input_ime::HideWindow::Params> params( | 411 std::unique_ptr<api::input_ime::HideWindow::Params> params( |
414 api::input_ime::HideWindow::Params::Create(*args_)); | 412 api::input_ime::HideWindow::Params::Create(*args_)); |
415 EXTENSION_FUNCTION_VALIDATE(params.get()); | 413 EXTENSION_FUNCTION_VALIDATE(params.get()); |
416 engine->HideImeWindow(params->window_id); | 414 engine->HideImeWindow(params->window_id); |
417 return RespondNow(NoArguments()); | 415 return RespondNow(NoArguments()); |
418 } | 416 } |
419 | 417 |
420 } // namespace extensions | 418 } // namespace extensions |
OLD | NEW |