Fix build break
[chromium-blink-merge.git] / chrome / browser / media / media_stream_devices_controller.h
blobfcc7b77b55db32911d4e7ae10286252f3fb1827c
1 // Copyright (c) 2012 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_MEDIA_STREAM_DEVICES_CONTROLLER_H_
6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
8 #include <string>
10 #include "content/public/browser/web_contents_delegate.h"
12 class PrefRegistrySyncable;
13 class Profile;
14 class TabSpecificContentSettings;
16 class MediaStreamDevicesController {
17 public:
18 MediaStreamDevicesController(Profile* profile,
19 TabSpecificContentSettings* content_settings,
20 const content::MediaStreamRequest& request,
21 const content::MediaResponseCallback& callback);
23 virtual ~MediaStreamDevicesController();
25 // Registers the prefs backing the audio and video policies.
26 static void RegisterUserPrefs(PrefRegistrySyncable* registry);
28 // Public method to be called before creating the MediaStreamInfoBarDelegate.
29 // This function will check the content settings exceptions and take the
30 // corresponding action on exception which matches the request.
31 bool DismissInfoBarAndTakeActionOnSettings();
33 // Public methods to be called by MediaStreamInfoBarDelegate;
34 bool has_audio() const { return microphone_requested_; }
35 bool has_video() const { return webcam_requested_; }
36 const std::string& GetSecurityOriginSpec() const;
37 void Accept(bool update_content_setting);
38 void Deny(bool update_content_setting);
40 private:
41 enum DevicePolicy {
42 POLICY_NOT_SET,
43 ALWAYS_DENY,
44 ALWAYS_ALLOW,
47 // Called by GetAudioDevicePolicy and GetVideoDevicePolicy to check
48 // the currently set capture device policy.
49 DevicePolicy GetDevicePolicy(const char* policy_name) const;
51 // Returns true if the origin of the request has been granted the media
52 // access before, otherwise returns false.
53 bool IsRequestAllowedByDefault() const;
55 // Returns true if the media access for the origin of the request has been
56 // blocked before. Otherwise returns false.
57 bool IsRequestBlockedByDefault() const;
59 // Returns true if the media section in content settings is set to
60 // |CONTENT_SETTING_BLOCK|, otherwise returns false.
61 bool IsDefaultMediaAccessBlocked() const;
63 // Returns true if the origin is a secure scheme, otherwise returns false.
64 bool IsSchemeSecure() const;
66 // Returns true if request's origin is from internal objects like
67 // chrome://URLs, otherwise returns false.
68 bool ShouldAlwaysAllowOrigin() const;
70 // Sets the permission of the origin of the request. This is triggered when
71 // the users deny the request or allow the request for https sites.
72 void SetPermission(bool allowed) const;
74 // The owner of this class needs to make sure it does not outlive the profile.
75 Profile* profile_;
77 // Weak pointer to the tab specific content settings of the tab for which the
78 // MediaStreamDevicesController was created. The tab specific content
79 // settings are associated with a the web contents of the tab. The
80 // MediaStreamDeviceController must not outlive the web contents for which it
81 // was created.
82 TabSpecificContentSettings* content_settings_;
84 // The original request for access to devices.
85 const content::MediaStreamRequest request_;
87 // The callback that needs to be Run to notify WebRTC of whether access to
88 // audio/video devices was granted or not.
89 content::MediaResponseCallback callback_;
91 bool microphone_requested_;
92 bool webcam_requested_;
94 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
97 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_