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

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: Code review. Created 6 years, 3 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()->embedder_web_contents()->GetDelegate())
Fady Samuel 2014/09/24 19:27:03 Please check for attached() first (this means we d
Henrik Grunell 2014/09/24 19:40:18 Done.
200 return false;
199 return web_view_guest() 201 return web_view_guest()
200 ->embedder_web_contents() 202 ->embedder_web_contents()
201 ->GetDelegate() 203 ->GetDelegate()
202 ->CheckMediaAccessPermission( 204 ->CheckMediaAccessPermission(
203 web_view_guest()->embedder_web_contents(), security_origin, type); 205 web_view_guest()->embedder_web_contents(), security_origin, type);
204 } 206 }
205 207
206 void WebViewPermissionHelper::OnMediaPermissionResponse( 208 void WebViewPermissionHelper::OnMediaPermissionResponse(
207 const content::MediaStreamRequest& request, 209 const content::MediaStreamRequest& request,
208 const content::MediaResponseCallback& callback, 210 const content::MediaResponseCallback& callback,
209 bool allow, 211 bool allow,
210 const std::string& user_input) { 212 const std::string& user_input) {
211 if (!allow || !web_view_guest()->attached()) { 213 if (!allow) {
212 // Deny the request. 214 callback.Run(content::MediaStreamDevices(),
215 content::MEDIA_DEVICE_PERMISSION_DENIED,
216 scoped_ptr<content::MediaStreamUI>());
217 return;
218 }
219 if (!web_view_guest()->attached() ||
220 !web_view_guest()->embedder_web_contents()->GetDelegate()) {
213 callback.Run(content::MediaStreamDevices(), 221 callback.Run(content::MediaStreamDevices(),
214 content::MEDIA_DEVICE_INVALID_STATE, 222 content::MEDIA_DEVICE_INVALID_STATE,
215 scoped_ptr<content::MediaStreamUI>()); 223 scoped_ptr<content::MediaStreamUI>());
216 return; 224 return;
217 } 225 }
218 if (!web_view_guest()->embedder_web_contents()->GetDelegate())
219 return;
220 226
221 web_view_guest() 227 web_view_guest()
222 ->embedder_web_contents() 228 ->embedder_web_contents()
223 ->GetDelegate() 229 ->GetDelegate()
224 ->RequestMediaAccessPermission( 230 ->RequestMediaAccessPermission(
225 web_view_guest()->embedder_web_contents(), request, callback); 231 web_view_guest()->embedder_web_contents(), request, callback);
226 } 232 }
227 233
228 void WebViewPermissionHelper::CanDownload( 234 void WebViewPermissionHelper::CanDownload(
229 content::RenderViewHost* render_view_host, 235 content::RenderViewHost* render_view_host,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 bool allowed_by_default) 385 bool allowed_by_default)
380 : callback(callback), 386 : callback(callback),
381 permission_type(permission_type), 387 permission_type(permission_type),
382 allowed_by_default(allowed_by_default) { 388 allowed_by_default(allowed_by_default) {
383 } 389 }
384 390
385 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { 391 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() {
386 } 392 }
387 393
388 } // namespace extensions 394 } // 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