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

Unified 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: addressed comments from joaodasilva and bauerb, added support to Incognito mode. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/media_stream_devices_controller.h
diff --git a/chrome/browser/media/media_stream_devices_controller.h b/chrome/browser/media/media_stream_devices_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f6515f3f3bcd41081226c5f77f3b41cd4996a65
--- /dev/null
+++ b/chrome/browser/media/media_stream_devices_controller.h
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
+#define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
+#pragma once
+
+#include <string>
+
+#include "content/browser/renderer_host/render_view_host_delegate.h"
no longer working on chromium 2012/06/20 17:24:38 To joaodasilva: Done with cleaning up the #include
+
+class GURL;
+class Profile;
+
+class MediaStreamDevicesController {
+ public:
+ MediaStreamDevicesController(Profile* profile,
+ const content::MediaStreamRequest* request,
+ const content::MediaResponseCallback& callback);
+
+ virtual ~MediaStreamDevicesController();
+
+ // Public method to be called before creating the MediaStreamInfoBarDelegate.
+ // This function will check the content settings exceptions and take the
+ // corresponding action on exception which matches the request.
+ bool DismissInfoBarAndTakeActionOnSettings();
+
+ // Public methods to be called by MediaStreamInfoBarDelegate;
+ bool has_audio() const { return has_audio_; }
+ bool has_video() const { return has_video_; }
+ content::MediaStreamDevices GetAudioDevices() const;
+ content::MediaStreamDevices GetVideoDevices() const;
+ const GURL& GetSecurityOrigin() const;
+ void Accept(const std::string& audio_id,
+ const std::string& video_id,
+ bool always_allow);
+ void Deny();
+
+ private:
+ // Finds a device in the current request with the specified |id| and |type|,
+ // adds it to the |devices| array and also return the name of the device.
+ void AddDeviceWithId(content::MediaStreamDeviceType type,
+ const std::string& id,
+ content::MediaStreamDevices* devices,
+ std::string* device_name);
+
+ // Returns true if the media section in content settings is set to
+ // |CONTENT_SETTING_BLOCK|, otherwise returns false.
+ bool IsMediaDeviceBlocked();
+
+ // Returns true if request's origin is from internal objects like
+ // chrome://URLs, otherwise returns false.
+ bool ShouldAlwaysAllowOrigin();
+
+ // Grants "always allow" exception for the origin to use the selected devices.
+ void AlwaysAllowOriginAndDevices(const std::string& audio_device,
+ const std::string& video_device);
+
+ // Gets the respective "always allowed" devices for the origin in |request_|.
+ // |audio_id| and |video_id| will be empty if there is no "always allowed"
+ // device for the origin, or any of the devices is not listed on the devices
+ // list in |request_|.
+ void GetAlwaysAllowedDevices(std::string* audio_id,
+ std::string* video_id);
+
+ std::string GetDeviceIdByName(content::MediaStreamDeviceType type,
+ const std::string& name);
+
+ std::string GetFirstDeviceId(content::MediaStreamDeviceType type);
+
+ bool has_audio_;
+ bool has_video_;
+
+ // The owner of this class needs to make sure it does not outlive the profile.
+ Profile* profile_;
+
+ // The original request for access to devices.
+ const content::MediaStreamRequest* request_;
+
+ // The callback that needs to be Run to notify WebRTC of whether access to
+ // audio/video devices was granted or not.
+ content::MediaResponseCallback callback_;
+ DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
+};
+
+#endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698