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 <utility> |
| 14 |
13 #include "base/command_line.h" | 15 #include "base/command_line.h" |
14 #include "base/macros.h" | 16 #include "base/macros.h" |
15 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 bool IsInputImeEnabled() { | 21 bool IsInputImeEnabled() { |
20 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 22 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
21 switches::kEnableInputImeAPI); | 23 switches::kEnableInputImeAPI); |
22 } | 24 } |
23 | 25 |
24 class ImeObserverNonChromeOS : public ui::ImeObserver { | 26 class ImeObserverNonChromeOS : public ui::ImeObserver { |
25 public: | 27 public: |
26 ImeObserverNonChromeOS(const std::string& extension_id, Profile* profile) | 28 ImeObserverNonChromeOS(const std::string& extension_id, Profile* profile) |
27 : ImeObserver(extension_id, profile) {} | 29 : ImeObserver(extension_id, profile) {} |
28 | 30 |
29 ~ImeObserverNonChromeOS() override {} | 31 ~ImeObserverNonChromeOS() override {} |
30 | 32 |
31 private: | 33 private: |
32 // ImeObserver overrides. | 34 // ImeObserver overrides. |
33 void DispatchEventToExtension( | 35 void DispatchEventToExtension( |
34 extensions::events::HistogramValue histogram_value, | 36 extensions::events::HistogramValue histogram_value, |
35 const std::string& event_name, | 37 const std::string& event_name, |
36 scoped_ptr<base::ListValue> args) override { | 38 scoped_ptr<base::ListValue> args) override { |
37 if (!IsInputImeEnabled()) { | 39 if (!IsInputImeEnabled()) { |
38 return; | 40 return; |
39 } | 41 } |
40 | 42 |
41 scoped_ptr<extensions::Event> event( | 43 scoped_ptr<extensions::Event> event( |
42 new extensions::Event(histogram_value, event_name, args.Pass())); | 44 new extensions::Event(histogram_value, event_name, std::move(args))); |
43 event->restrict_to_browser_context = profile_; | 45 event->restrict_to_browser_context = profile_; |
44 extensions::EventRouter::Get(profile_) | 46 extensions::EventRouter::Get(profile_) |
45 ->DispatchEventToExtension(extension_id_, event.Pass()); | 47 ->DispatchEventToExtension(extension_id_, std::move(event)); |
46 } | 48 } |
47 | 49 |
48 DISALLOW_COPY_AND_ASSIGN(ImeObserverNonChromeOS); | 50 DISALLOW_COPY_AND_ASSIGN(ImeObserverNonChromeOS); |
49 }; | 51 }; |
50 | 52 |
51 } // namespace | 53 } // namespace |
52 | 54 |
53 namespace extensions { | 55 namespace extensions { |
54 | 56 |
55 bool InputImeEventRouter::RegisterImeExtension( | 57 bool InputImeEventRouter::RegisterImeExtension( |
56 const std::string& extension_id, | 58 const std::string& extension_id, |
57 const std::vector<extensions::InputComponentInfo>& input_components) { | 59 const std::vector<extensions::InputComponentInfo>& input_components) { |
58 return false; | 60 return false; |
59 } | 61 } |
60 | 62 |
61 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) {} | 63 void InputImeEventRouter::UnregisterAllImes(const std::string& extension_id) {} |
62 | 64 |
63 } // namespace extensions | 65 } // namespace extensions |
OLD | NEW |