- add sources.
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / media / device_request_message_filter.h
1 // Copyright 2013 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.
4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_DEVICE_REQUEST_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_DEVICE_REQUEST_MESSAGE_FILTER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/synchronization/lock.h"
12 #include "content/browser/renderer_host/media/media_stream_requester.h"
13 #include "content/common/content_export.h"
14 #include "content/public/browser/browser_message_filter.h"
15
16 namespace content {
17
18 class MediaStreamManager;
19 class ResourceContext;
20
21 // DeviceRequestMessageFilter used to delegate requests from the
22 // MediaStreamCenter.
23 class CONTENT_EXPORT DeviceRequestMessageFilter : public BrowserMessageFilter,
24                                                   public MediaStreamRequester {
25  public:
26   DeviceRequestMessageFilter(ResourceContext* resource_context,
27                              MediaStreamManager* media_stream_manager);
28
29   // MediaStreamRequester implementation.
30   // TODO(vrk): Replace MediaStreamRequester interface with a single callback so
31   // we don't have to override all these callbacks we don't care about.
32   // (crbug.com/249476)
33   virtual void StreamGenerated(
34       const std::string& label, const StreamDeviceInfoArray& audio_devices,
35       const StreamDeviceInfoArray& video_devices) OVERRIDE;
36   virtual void StreamGenerationFailed(const std::string& label) OVERRIDE;
37   virtual void StopGeneratedStream(int render_view_id,
38                                    const std::string& label) OVERRIDE;
39   virtual void DeviceOpened(const std::string& label,
40                             const StreamDeviceInfo& video_device) OVERRIDE;
41   // DevicesEnumerated() is the only callback we're interested in.
42   virtual void DevicesEnumerated(const std::string& label,
43                                  const StreamDeviceInfoArray& devices) OVERRIDE;
44
45   // BrowserMessageFilter implementation.
46   virtual bool OnMessageReceived(const IPC::Message& message,
47                                  bool* message_was_ok) OVERRIDE;
48   virtual void OnChannelClosing() OVERRIDE;
49
50  protected:
51   virtual ~DeviceRequestMessageFilter();
52
53  private:
54   void OnGetSources(int request_id, const GURL& security_origin);
55   void HmacDeviceIds(const GURL& origin,
56                      const StreamDeviceInfoArray& raw_devices,
57                      StreamDeviceInfoArray* devices_with_guids);
58
59   // Owned by ProfileIOData which is guaranteed to outlive DRMF.
60   ResourceContext* resource_context_;
61   MediaStreamManager* media_stream_manager_;
62
63   struct DeviceRequest;
64   typedef std::vector<DeviceRequest> DeviceRequestList;
65   // List of all requests.
66   DeviceRequestList requests_;
67
68   DISALLOW_COPY_AND_ASSIGN(DeviceRequestMessageFilter);
69 };
70
71 }  // namespace content
72
73 #endif  // CONTENT_BROWSER_RENDERER_HOST_MEDIA_DEVICE_REQUEST_MESSAGE_FILTER_H_