Fix the duplicatedly commited composition text when switching IME.
[chromium-blink-merge.git] / chrome / browser / chromeos / device / input_service_proxy.h
blobfaf7bb16fd935fc71872f0346b8483ab66d1b6c6
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h"
14 #include "base/task_runner.h"
15 #include "base/threading/thread_checker.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "device/hid/input_service_linux.h"
19 namespace chromeos {
21 // Proxy to device::InputServiceLinux. Should be created and used on the UI
22 // thread.
23 class InputServiceProxy {
24 public:
25 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo;
27 class Observer {
28 public:
29 virtual ~Observer() {}
30 virtual void OnInputDeviceAdded(const InputDeviceInfo& info) = 0;
31 virtual void OnInputDeviceRemoved(const std::string& id) = 0;
34 typedef base::Callback<void(const std::vector<InputDeviceInfo>& devices)>
35 GetDevicesCallback;
36 typedef base::Callback<void(bool success, const InputDeviceInfo& info)>
37 GetDeviceInfoCallback;
39 InputServiceProxy();
40 ~InputServiceProxy();
42 void AddObserver(Observer* observer);
43 void RemoveObserver(Observer* observer);
45 void GetDevices(const GetDevicesCallback& callback);
46 void GetDeviceInfo(const std::string& id,
47 const GetDeviceInfoCallback& callback);
49 // Should be called once before any InputServiceProxy instance is created.
50 static void SetThreadIdForTesting(content::BrowserThread::ID thread_id);
52 private:
53 static content::BrowserThread::ID thread_identifier_;
55 class ServiceObserver;
57 void OnDeviceAdded(const device::InputServiceLinux::InputDeviceInfo& info);
58 void OnDeviceRemoved(const std::string& id);
60 base::ObserverList<Observer> observers_;
61 scoped_ptr<ServiceObserver> service_observer_;
63 base::ThreadChecker thread_checker_;
65 scoped_refptr<base::TaskRunner> task_runner_;
67 base::WeakPtrFactory<InputServiceProxy> weak_factory_;
69 DISALLOW_COPY_AND_ASSIGN(InputServiceProxy);
72 } // namespace chromeos
74 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_