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.
4 
5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICE_PERMISSION_CONTEXT_H_
6 #define CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICE_PERMISSION_CONTEXT_H_
7 
8 #include "base/macros.h"
9 #include "components/content_settings/core/common/content_settings_types.h"
10 #include "components/permissions/permission_context_base.h"
11 
12 // Common class which handles the mic and camera permissions.
13 class MediaStreamDevicePermissionContext
14     : public permissions::PermissionContextBase {
15  public:
16   MediaStreamDevicePermissionContext(content::BrowserContext* browser_context,
17                                      ContentSettingsType content_settings_type);
18   ~MediaStreamDevicePermissionContext() override;
19 
20   // PermissionContextBase:
21   void DecidePermission(
22       content::WebContents* web_contents,
23       const permissions::PermissionRequestID& id,
24       const GURL& requesting_origin,
25       const GURL& embedding_origin,
26       bool user_gesture,
27       permissions::BrowserPermissionCallback callback) override;
28 
29   // TODO(xhwang): GURL.GetOrigin() shouldn't be used as the origin. Need to
30   // refactor to use url::Origin. crbug.com/527149 is filed for this.
31   ContentSetting GetPermissionStatusInternal(
32       content::RenderFrameHost* render_frame_host,
33       const GURL& requesting_origin,
34       const GURL& embedding_origin) const override;
35 
36   void ResetPermission(const GURL& requesting_origin,
37                        const GURL& embedding_origin) override;
38 
39  private:
40   // PermissionContextBase:
41   bool IsRestrictedToSecureOrigins() const override;
42 
43   ContentSettingsType content_settings_type_;
44 
45   DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicePermissionContext);
46 };
47 
48 #endif  // CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICE_PERMISSION_CONTEXT_H_
49