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 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMULATOR_DEVICE_EMULATOR_MESSAGE_HANDLE
R_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMULATOR_DEVICE_EMULATOR_MESSAGE_HANDLE
R_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMULATOR_DEVICE_EMULATOR_MESSAGE_HANDLE
R_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMULATOR_DEVICE_EMULATOR_MESSAGE_HANDLE
R_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 9 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
10 #include "content/public/browser/web_ui_message_handler.h" | 10 #include "content/public/browser/web_ui_message_handler.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class ListValue; | 13 class ListValue; |
14 } // namespace base | 14 } // namespace base |
15 | 15 |
16 namespace dbus { | 16 namespace dbus { |
17 class ObjectPath; | 17 class ObjectPath; |
18 } // namespace dbus | 18 } // namespace dbus |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
22 class FakeBluetoothDeviceClient; | 22 class FakeBluetoothDeviceClient; |
| 23 class FakeCrasAudioClient; |
23 class FakePowerManagerClient; | 24 class FakePowerManagerClient; |
24 | 25 |
25 // Handler class for the Device Emulator page operations. | 26 // Handler class for the Device Emulator page operations. |
26 class DeviceEmulatorMessageHandler | 27 class DeviceEmulatorMessageHandler |
27 : public content::WebUIMessageHandler { | 28 : public content::WebUIMessageHandler { |
28 public: | 29 public: |
29 DeviceEmulatorMessageHandler(); | 30 DeviceEmulatorMessageHandler(); |
30 ~DeviceEmulatorMessageHandler() override; | 31 ~DeviceEmulatorMessageHandler() override; |
31 | 32 |
32 // Adds |this| as an observer to all necessary objects. | 33 // Adds |this| as an observer to all necessary objects. |
(...skipping 13 matching lines...) Expand all Loading... |
46 // Callback for the "requestBluetoothInfo" message. This asynchronously | 47 // Callback for the "requestBluetoothInfo" message. This asynchronously |
47 // requests for the devices which are already paired with the device. | 48 // requests for the devices which are already paired with the device. |
48 void HandleRequestBluetoothInfo(const base::ListValue* args); | 49 void HandleRequestBluetoothInfo(const base::ListValue* args); |
49 | 50 |
50 // Callback for the "requestBluetoothPair" message. This asynchronously | 51 // Callback for the "requestBluetoothPair" message. This asynchronously |
51 // requests for the system to pair a certain device. The device's data should | 52 // requests for the system to pair a certain device. The device's data should |
52 // be passed into |args| as a dictionary. If the device does not already | 53 // be passed into |args| as a dictionary. If the device does not already |
53 // exist, then it will be created and attached to the main adapter. | 54 // exist, then it will be created and attached to the main adapter. |
54 void HandleRequestBluetoothPair(const base::ListValue* args); | 55 void HandleRequestBluetoothPair(const base::ListValue* args); |
55 | 56 |
| 57 // Callback for the "requestAudioNodes" message. This asynchronously |
| 58 // requests the audio node that is current set to active. It is possible |
| 59 // that there can be multiple current active nodes. |
| 60 void HandleRequestAudioNodes(const base::ListValue* args); |
| 61 |
| 62 // Create a node and add the node to the current AudioNodeList in |
| 63 // |fake_cras_audio_client_|. |
| 64 void HandleInsertAudioNode(const base::ListValue* args); |
| 65 |
| 66 // Removes an AudioNode from the current list in |fake_cras_audio_client_|. |
| 67 // based on the node id. |
| 68 void HandleRemoveAudioNode(const base::ListValue* args); |
| 69 |
56 // Callbacks for JS update methods. All these methods work | 70 // Callbacks for JS update methods. All these methods work |
57 // asynchronously. | 71 // asynchronously. |
58 void UpdateBatteryPercent(const base::ListValue* args); | 72 void UpdateBatteryPercent(const base::ListValue* args); |
59 void UpdateBatteryState(const base::ListValue* args); | 73 void UpdateBatteryState(const base::ListValue* args); |
60 void UpdateExternalPower(const base::ListValue* args); | 74 void UpdateExternalPower(const base::ListValue* args); |
61 void UpdateTimeToEmpty(const base::ListValue* args); | 75 void UpdateTimeToEmpty(const base::ListValue* args); |
62 void UpdateTimeToFull(const base::ListValue* args); | 76 void UpdateTimeToFull(const base::ListValue* args); |
63 | 77 |
64 // content::WebUIMessageHandler: | 78 // content::WebUIMessageHandler: |
65 void RegisterMessages() override; | 79 void RegisterMessages() override; |
66 | 80 |
67 // Callback for the "requestPowerInfo" message. This asynchonously requests | 81 // Callback for the "requestPowerInfo" message. This asynchronously requests |
68 // for power settings such as battery percentage, external power, etc. to | 82 // for power settings such as battery percentage, external power, etc. to |
69 // update the view. | 83 // update the view. |
70 void RequestPowerInfo(const base::ListValue* args); | 84 void RequestPowerInfo(const base::ListValue* args); |
71 | 85 |
72 private: | 86 private: |
73 class BluetoothObserver; | 87 class BluetoothObserver; |
| 88 class CrasAudioObserver; |
74 class PowerObserver; | 89 class PowerObserver; |
75 | 90 |
76 // Creates a bluetooth device with the properties given in |args|. |args| | 91 // Creates a bluetooth device with the properties given in |args|. |args| |
77 // should contain a dictionary so that each dictionary value can be mapped | 92 // should contain a dictionary so that each dictionary value can be mapped |
78 // to its respective property upon creating the device. Returns the device | 93 // to its respective property upon creating the device. Returns the device |
79 // path. | 94 // path. |
80 std::string CreateBluetoothDeviceFromListValue(const base::ListValue* args); | 95 std::string CreateBluetoothDeviceFromListValue(const base::ListValue* args); |
81 | 96 |
82 // Builds a dictionary with each key representing a property of the device | 97 // Builds a dictionary with each key representing a property of the device |
83 // with path |object_path|. | 98 // with path |object_path|. |
84 scoped_ptr<base::DictionaryValue> GetDeviceInfo( | 99 scoped_ptr<base::DictionaryValue> GetDeviceInfo( |
85 const dbus::ObjectPath& object_path); | 100 const dbus::ObjectPath& object_path); |
86 | 101 |
| 102 FakeBluetoothDeviceClient* fake_bluetooth_device_client_; |
87 scoped_ptr<BluetoothObserver> bluetooth_observer_; | 103 scoped_ptr<BluetoothObserver> bluetooth_observer_; |
88 FakeBluetoothDeviceClient* fake_bluetooth_device_client_; | 104 |
| 105 FakeCrasAudioClient* fake_cras_audio_client_; |
| 106 scoped_ptr<CrasAudioObserver> cras_audio_observer_; |
| 107 |
89 FakePowerManagerClient* fake_power_manager_client_; | 108 FakePowerManagerClient* fake_power_manager_client_; |
90 scoped_ptr<PowerObserver> power_observer_; | 109 scoped_ptr<PowerObserver> power_observer_; |
91 | 110 |
92 DISALLOW_COPY_AND_ASSIGN(DeviceEmulatorMessageHandler); | 111 DISALLOW_COPY_AND_ASSIGN(DeviceEmulatorMessageHandler); |
93 }; | 112 }; |
94 | 113 |
95 } // namespace chromeos | 114 } // namespace chromeos |
96 | 115 |
97 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMULATOR_DEVICE_EMULATOR_MESSAGE_HAN
DLER_H_ | 116 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMULATOR_DEVICE_EMULATOR_MESSAGE_HAN
DLER_H_ |
OLD | NEW |