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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_MEDIA_PERMISSION_BUBBLE_MEDIA_ACCESS_HANDLER_H_
6 #define CHROME_BROWSER_MEDIA_PERMISSION_BUBBLE_MEDIA_ACCESS_HANDLER_H_
11 #include "chrome/browser/media/media_access_handler.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
15 // MediaAccessHandler for permission bubble requests.
16 class PermissionBubbleMediaAccessHandler
17 : public MediaAccessHandler
,
18 public content::NotificationObserver
{
20 PermissionBubbleMediaAccessHandler();
21 ~PermissionBubbleMediaAccessHandler() override
;
23 // MediaAccessHandler implementation.
24 bool SupportsStreamType(const content::MediaStreamType type
,
25 const extensions::Extension
* extension
) override
;
26 bool CheckMediaAccessPermission(
27 content::WebContents
* web_contents
,
28 const GURL
& security_origin
,
29 content::MediaStreamType type
,
30 const extensions::Extension
* extension
) override
;
31 void HandleRequest(content::WebContents
* web_contents
,
32 const content::MediaStreamRequest
& request
,
33 const content::MediaResponseCallback
& callback
,
34 const extensions::Extension
* extension
) override
;
35 void UpdateMediaRequestState(int render_process_id
,
38 content::MediaStreamType stream_type
,
39 content::MediaRequestState state
) override
;
42 struct PendingAccessRequest
;
43 typedef std::deque
<PendingAccessRequest
> RequestsQueue
;
44 typedef std::map
<content::WebContents
*, RequestsQueue
> RequestsQueues
;
46 void ProcessQueuedAccessRequest(content::WebContents
* web_contents
);
47 void OnAccessRequestResponse(content::WebContents
* web_contents
,
48 const content::MediaStreamDevices
& devices
,
49 content::MediaStreamRequestResult result
,
50 scoped_ptr
<content::MediaStreamUI
> ui
);
52 // content::NotificationObserver implementation.
53 void Observe(int type
,
54 const content::NotificationSource
& source
,
55 const content::NotificationDetails
& details
) override
;
57 RequestsQueues pending_requests_
;
58 content::NotificationRegistrar notifications_registrar_
;
60 #endif // CHROME_BROWSER_MEDIA_PERMISSION_BUBBLE_MEDIA_ACCESS_HANDLER_H_