Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / media / midi / usb_midi_device_android.h
blob7032cf7b22d4010edf9bc534237f7d9160356dc8
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 MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_
6 #define MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_
8 #include <jni.h>
9 #include <string>
10 #include <vector>
12 #include "base/android/scoped_java_ref.h"
13 #include "base/basictypes.h"
14 #include "base/callback.h"
15 #include "media/base/media_export.h"
16 #include "media/midi/usb_midi_device.h"
18 namespace media {
20 class MEDIA_EXPORT UsbMidiDeviceAndroid : public UsbMidiDevice {
21 public:
22 typedef base::android::ScopedJavaLocalRef<jobject> ObjectRef;
24 static scoped_ptr<Factory> CreateFactory();
26 UsbMidiDeviceAndroid(ObjectRef raw_device, UsbMidiDeviceDelegate* delegate);
27 ~UsbMidiDeviceAndroid() override;
29 // UsbMidiDevice implementation.
30 std::vector<uint8> GetDescriptors() override;
31 std::string GetManufacturer() override;
32 std::string GetProductName() override;
33 std::string GetDeviceVersion() override;
34 void Send(int endpoint_number, const std::vector<uint8>& data) override;
36 // Called by the Java world.
37 void OnData(JNIEnv* env,
38 jobject caller,
39 jint endpoint_number,
40 jbyteArray data);
42 static bool RegisterUsbMidiDevice(JNIEnv* env);
44 private:
45 void GetDescriptorsInternal();
46 void InitDeviceInfo();
47 std::vector<uint8> GetStringDescriptor(int index);
48 std::string GetString(int index, const std::string& backup);
50 // The actual device object.
51 base::android::ScopedJavaGlobalRef<jobject> raw_device_;
52 UsbMidiDeviceDelegate* delegate_;
54 std::vector<uint8> descriptors_;
55 std::string manufacturer_;
56 std::string product_;
57 std::string device_version_;
59 DISALLOW_IMPLICIT_CONSTRUCTORS(UsbMidiDeviceAndroid);
62 } // namespace media
64 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_