2015-05-22 06:50:41 +00:00
|
|
|
// Copyright (c) 2015 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-CHROMIUM file.
|
|
|
|
|
2017-05-18 22:58:12 +00:00
|
|
|
#include "brightray/browser/permission_manager.h"
|
2015-05-22 06:50:41 +00:00
|
|
|
|
|
|
|
#include "base/callback.h"
|
2015-09-05 05:50:47 +00:00
|
|
|
#include "content/public/browser/child_process_security_policy.h"
|
2015-05-22 06:50:41 +00:00
|
|
|
#include "content/public/browser/permission_type.h"
|
2015-09-05 05:50:47 +00:00
|
|
|
#include "content/public/browser/render_frame_host.h"
|
|
|
|
#include "content/public/browser/render_process_host.h"
|
2015-05-22 06:50:41 +00:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2018-04-18 01:56:12 +00:00
|
|
|
PermissionManager::PermissionManager() {}
|
2015-05-22 06:50:41 +00:00
|
|
|
|
2018-04-18 01:56:12 +00:00
|
|
|
PermissionManager::~PermissionManager() {}
|
2015-05-22 06:50:41 +00:00
|
|
|
|
2015-12-07 11:55:01 +00:00
|
|
|
int PermissionManager::RequestPermission(
|
2015-05-22 06:50:41 +00:00
|
|
|
content::PermissionType permission,
|
2015-09-02 07:16:34 +00:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
2015-05-22 06:50:41 +00:00
|
|
|
const GURL& requesting_origin,
|
2017-01-13 08:52:45 +00:00
|
|
|
bool user_gesture,
|
2016-05-23 01:59:07 +00:00
|
|
|
const base::Callback<void(blink::mojom::PermissionStatus)>& callback) {
|
2015-09-05 05:50:47 +00:00
|
|
|
if (permission == content::PermissionType::MIDI_SYSEX) {
|
2018-04-18 01:56:12 +00:00
|
|
|
content::ChildProcessSecurityPolicy::GetInstance()
|
|
|
|
->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
2015-09-05 05:50:47 +00:00
|
|
|
}
|
2016-05-23 01:59:07 +00:00
|
|
|
callback.Run(blink::mojom::PermissionStatus::GRANTED);
|
2015-12-07 11:55:01 +00:00
|
|
|
return kNoPendingOperation;
|
2015-05-22 06:50:41 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 07:09:25 +00:00
|
|
|
int PermissionManager::RequestPermissions(
|
|
|
|
const std::vector<content::PermissionType>& permissions,
|
|
|
|
content::RenderFrameHost* render_frame_host,
|
|
|
|
const GURL& requesting_origin,
|
2017-01-13 08:52:45 +00:00
|
|
|
bool user_gesture,
|
2018-04-18 01:56:12 +00:00
|
|
|
const base::Callback<
|
|
|
|
void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
|
2016-05-23 01:59:07 +00:00
|
|
|
std::vector<blink::mojom::PermissionStatus> permissionStatuses;
|
2016-03-08 07:09:25 +00:00
|
|
|
|
|
|
|
for (auto permission : permissions) {
|
|
|
|
if (permission == content::PermissionType::MIDI_SYSEX) {
|
2018-04-18 01:56:12 +00:00
|
|
|
content::ChildProcessSecurityPolicy::GetInstance()
|
|
|
|
->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
2016-03-08 07:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 01:59:07 +00:00
|
|
|
permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
2016-03-08 07:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
callback.Run(permissionStatuses);
|
|
|
|
return kNoPendingOperation;
|
|
|
|
}
|
2016-03-08 08:51:16 +00:00
|
|
|
|
2018-04-18 01:56:12 +00:00
|
|
|
void PermissionManager::CancelPermissionRequest(int request_id) {}
|
2015-05-22 06:50:41 +00:00
|
|
|
|
2018-04-18 01:56:12 +00:00
|
|
|
void PermissionManager::ResetPermission(content::PermissionType permission,
|
|
|
|
const GURL& requesting_origin,
|
|
|
|
const GURL& embedding_origin) {}
|
2015-05-22 06:50:41 +00:00
|
|
|
|
2016-05-23 01:59:07 +00:00
|
|
|
blink::mojom::PermissionStatus PermissionManager::GetPermissionStatus(
|
2015-05-22 06:50:41 +00:00
|
|
|
content::PermissionType permission,
|
|
|
|
const GURL& requesting_origin,
|
|
|
|
const GURL& embedding_origin) {
|
2016-05-23 01:59:07 +00:00
|
|
|
return blink::mojom::PermissionStatus::GRANTED;
|
2015-05-22 06:50:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PermissionManager::SubscribePermissionStatusChange(
|
|
|
|
content::PermissionType permission,
|
|
|
|
const GURL& requesting_origin,
|
|
|
|
const GURL& embedding_origin,
|
2016-05-23 01:59:07 +00:00
|
|
|
const base::Callback<void(blink::mojom::PermissionStatus)>& callback) {
|
2015-05-22 06:50:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) {
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace brightray
|