Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: chrome/browser/media/media_stream_devices_controller.h

Issue 10537099: add "always allow" option to the mediastream infobar and allow user to allow/not allow acces to devi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use only content settings, added a device controller, addressed all the comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/callback.h"
12 #include "chrome/browser/media/media_stream_devices_controller.h"
13 #include "content/public/browser/content_browser_client.h"
14 #include "content/public/common/media_stream_request.h"
15
16
17 class ContentSettingsPattern;
18 class GURL;
19 class Profile;
20
21 class MediaStreamDevicesController {
22 public:
23 MediaStreamDevicesController(Profile* profile,
24 const content::MediaStreamRequest* request,
25 const content::MediaResponseCallback& callback);
26
27 virtual ~MediaStreamDevicesController();
28
29 // Public method to be called before creating the MediaStreamInfoBarDelegate.
30 // This function will check the content settings exceptions and take the
31 // corresponding action on exception which matches the request.
32 bool DismissInfoBarAndTakeActionOnSettings();
33
34 // Public methods to be called by MediaStreamInfoBarDelegate;
35 bool has_audio() const { return has_audio_; }
36 bool has_video() const { return has_video_; }
37 content::MediaStreamDevices GetAudioDevices() const;
38 content::MediaStreamDevices GetVideoDevices() const;
39 const GURL& GetSecurityOrigin() const;
40 void Accept(const std::string& audio_id, const std::string& video_id,
41 bool always_allow);
42 void Deny();
43
44 private:
45 // Finds a device in the current request with the specified |id| and |type|,
46 // adds it to the |devices| array and also return the name of the device.
47 void AddDeviceWithId(content::MediaStreamDeviceType type,
48 const std::string& id,
49 content::MediaStreamDevices* devices,
50 std::string* device_name);
51
52 // Returns true if request's origin is from internal objects like
53 // chrome://URLs, otherwise returns false.
54 bool IsInternalContent();
55
56 // Returns true if the media section in content settings is set to
57 // |CONTENT_SETTING_BLOCK|, otherwise returns false.
58 bool IsMediaDeviceBlocked();
59
60 // Grants "always allow" exception for the origin to use the selected devices.
61 void AlwaysAllowOriginAndDevices(const std::string& audio_device,
62 const std::string& video_device);
63
64 // Gets the respective "always allowed" devices for the origin in |request_|.
65 // |audio_id| and |video_id| will be empty if there is no "always allowed"
66 // device for the origin, or any of the devices is not listed on the devices
67 // list in |request_|.
68 void GetAlwaysAllowedDevices(std::string* audio_id,
69 std::string* video_id);
70
71 std::string GetDeviceIdByName(content::MediaStreamDeviceType type,
72 const std::string& name);
73
74 std::string GetFirstDevice(content::MediaStreamDeviceType type);
75
76 bool has_audio_;
77 bool has_video_;
78
79 Profile* profile_;
Bernhard Bauer 2012/06/18 17:38:14 Could you add a comment that the owner of this cla
no longer working on chromium 2012/06/19 12:23:16 Done.
80
81 // The original request for access to devices.
82 const content::MediaStreamRequest* request_;
83
84 // The callback that needs to be Run to notify WebRTC of whether access to
85 // audio/video devices was granted or not.
86 content::MediaResponseCallback callback_;
Ivan Korotkov 2012/06/14 17:14:12 Please rename to something more meaningful, like r
no longer working on chromium 2012/06/15 16:52:07 Since there is only one type of callback used by t
87 };
88
89 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698