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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_permission_helper.cc

Issue 586223002: Add new media request result MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 2 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
« no previous file with comments | « content/public/common/media_stream_request.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" 5 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
6 6
7 #include "content/public/browser/render_process_host.h" 7 #include "content/public/browser/render_process_host.h"
8 #include "content/public/browser/render_view_host.h" 8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/user_metrics.h" 9 #include "content/public/browser/user_metrics.h"
10 #include "extensions/browser/api/extensions_api_client.h" 10 #include "extensions/browser/api/extensions_api_client.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 weak_factory_.GetWeakPtr(), 189 weak_factory_.GetWeakPtr(),
190 request, 190 request,
191 callback), 191 callback),
192 false /* allowed_by_default */); 192 false /* allowed_by_default */);
193 } 193 }
194 194
195 bool WebViewPermissionHelper::CheckMediaAccessPermission( 195 bool WebViewPermissionHelper::CheckMediaAccessPermission(
196 content::WebContents* source, 196 content::WebContents* source,
197 const GURL& security_origin, 197 const GURL& security_origin,
198 content::MediaStreamType type) { 198 content::MediaStreamType type) {
199 if (!web_view_guest()->attached() ||
200 !web_view_guest()->embedder_web_contents()->GetDelegate()) {
201 return false;
202 }
199 return web_view_guest() 203 return web_view_guest()
200 ->embedder_web_contents() 204 ->embedder_web_contents()
201 ->GetDelegate() 205 ->GetDelegate()
202 ->CheckMediaAccessPermission( 206 ->CheckMediaAccessPermission(
203 web_view_guest()->embedder_web_contents(), security_origin, type); 207 web_view_guest()->embedder_web_contents(), security_origin, type);
204 } 208 }
205 209
206 void WebViewPermissionHelper::OnMediaPermissionResponse( 210 void WebViewPermissionHelper::OnMediaPermissionResponse(
207 const content::MediaStreamRequest& request, 211 const content::MediaStreamRequest& request,
208 const content::MediaResponseCallback& callback, 212 const content::MediaResponseCallback& callback,
209 bool allow, 213 bool allow,
210 const std::string& user_input) { 214 const std::string& user_input) {
211 if (!allow || !web_view_guest()->attached()) { 215 if (!allow) {
212 // Deny the request. 216 callback.Run(content::MediaStreamDevices(),
217 content::MEDIA_DEVICE_PERMISSION_DENIED,
218 scoped_ptr<content::MediaStreamUI>());
219 return;
220 }
221 if (!web_view_guest()->attached() ||
222 !web_view_guest()->embedder_web_contents()->GetDelegate()) {
213 callback.Run(content::MediaStreamDevices(), 223 callback.Run(content::MediaStreamDevices(),
214 content::MEDIA_DEVICE_INVALID_STATE, 224 content::MEDIA_DEVICE_INVALID_STATE,
215 scoped_ptr<content::MediaStreamUI>()); 225 scoped_ptr<content::MediaStreamUI>());
216 return; 226 return;
217 } 227 }
218 if (!web_view_guest()->embedder_web_contents()->GetDelegate())
219 return;
220 228
221 web_view_guest() 229 web_view_guest()
222 ->embedder_web_contents() 230 ->embedder_web_contents()
223 ->GetDelegate() 231 ->GetDelegate()
224 ->RequestMediaAccessPermission( 232 ->RequestMediaAccessPermission(
225 web_view_guest()->embedder_web_contents(), request, callback); 233 web_view_guest()->embedder_web_contents(), request, callback);
226 } 234 }
227 235
228 void WebViewPermissionHelper::CanDownload( 236 void WebViewPermissionHelper::CanDownload(
229 content::RenderViewHost* render_view_host, 237 content::RenderViewHost* render_view_host,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 bool allowed_by_default) 387 bool allowed_by_default)
380 : callback(callback), 388 : callback(callback),
381 permission_type(permission_type), 389 permission_type(permission_type),
382 allowed_by_default(allowed_by_default) { 390 allowed_by_default(allowed_by_default) {
383 } 391 }
384 392
385 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { 393 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() {
386 } 394 }
387 395
388 } // namespace extensions 396 } // namespace extensions
OLDNEW
« no previous file with comments | « content/public/common/media_stream_request.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698