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

Unified Diff: content/browser/renderer_host/media/media_stream_device_settings.cc

Issue 10542092: Refactor the content interface for RequestMediaAccessPermission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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: content/browser/renderer_host/media/media_stream_device_settings.cc
diff --git a/content/browser/renderer_host/media/media_stream_device_settings.cc b/content/browser/renderer_host/media/media_stream_device_settings.cc
index 39d66e7a5b2693abfd124a9638a65eb6eed3e67f..294e092685f89c1b504f40961538757fb0d23586 100644
--- a/content/browser/renderer_host/media/media_stream_device_settings.cc
+++ b/content/browser/renderer_host/media/media_stream_device_settings.cc
@@ -10,6 +10,8 @@
#include "base/callback.h"
#include "base/stl_util.h"
#include "content/browser/renderer_host/media/media_stream_settings_requester.h"
+#include "content/browser/renderer_host/render_view_host_delegate.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/media/media_stream_options.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
@@ -106,6 +108,28 @@ class MediaStreamDeviceSettingsRequest : public MediaStreamRequest {
bool posted_task;
};
+namespace {
+
+// Sends the request to the appropriate WebContents.
+void DoDeviceRequest(
+ const MediaStreamDeviceSettingsRequest* request,
+ const content::MediaResponseCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // Send the permission request to the web contents.
+ content::RenderViewHostImpl* host =
+ content::RenderViewHostImpl::FromID(request->render_process_id,
+ request->render_view_id);
+
+ // Tab may have gone away.
+ if (!host || !host->GetDelegate())
+ callback.Run(content::MediaStreamDevices());
+
+ host->GetDelegate()->RequestMediaAccessPermission(request, callback);
+}
+
+} // namespace
+
MediaStreamDeviceSettings::MediaStreamDeviceSettings(
SettingsRequester* requester)
: requester_(requester),
@@ -322,19 +346,15 @@ void MediaStreamDeviceSettings::PostRequestToUi(const std::string& label) {
}
}
- // Send the permission request to the content client.
scoped_refptr<ResponseCallbackHelper> helper =
new ResponseCallbackHelper(AsWeakPtr());
content::MediaResponseCallback callback =
base::Bind(&ResponseCallbackHelper::PostResponse,
helper.get(), label);
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(
- &content::ContentBrowserClient::RequestMediaAccessPermission,
- base::Unretained(content::GetContentClient()->browser()),
- request, callback));
-
+ base::Bind(&DoDeviceRequest, request, callback));
}
} // namespace media_stream
« no previous file with comments | « chrome/browser/ui/media_stream_infobar_delegate.h ('k') | content/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698