Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Use security origin for media access permission requests
Browse files Browse the repository at this point in the history
  • Loading branch information
diracdeltas committed Nov 11, 2016
1 parent 591eb13 commit 9eae22d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions atom/browser/web_contents_permission_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ WebContentsPermissionHelper::~WebContentsPermissionHelper() {
void WebContentsPermissionHelper::RequestPermission(
content::PermissionType permission,
const base::Callback<void(bool)>& callback,
bool user_gesture) {
bool user_gesture, const GURL& security_origin) {
auto rfh = web_contents_->GetMainFrame();
auto permission_manager = static_cast<AtomPermissionManager*>(
web_contents_->GetBrowserContext()->GetPermissionManager());
auto origin = web_contents_->GetLastCommittedURL();
GURL origin;
if (security_origin.is_empty()) {
origin = web_contents_->GetLastCommittedURL();
} else {
origin = security_origin;
}
permission_manager->RequestPermission(
permission, rfh, origin,
base::Bind(&OnPermissionResponse, callback));
Expand All @@ -76,7 +81,8 @@ void WebContentsPermissionHelper::RequestMediaAccessPermission(
auto callback = base::Bind(&MediaAccessAllowed, request, response_callback);
// The permission type doesn't matter here, AUDIO_CAPTURE/VIDEO_CAPTURE
// are presented as same type in content_converter.h.
RequestPermission(content::PermissionType::AUDIO_CAPTURE, callback);
RequestPermission(content::PermissionType::AUDIO_CAPTURE, callback,
false, request.security_origin);
}

void WebContentsPermissionHelper::RequestWebNotificationPermission(
Expand Down
3 changes: 2 additions & 1 deletion atom/browser/web_contents_permission_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class WebContentsPermissionHelper
void RequestPermission(
content::PermissionType permission,
const base::Callback<void(bool)>& callback,
bool user_gesture = false);
bool user_gesture = false,
const GURL& security_origin = GURL());

content::WebContents* web_contents_;

Expand Down

0 comments on commit 9eae22d

Please sign in to comment.