add spec for new permissions
This commit is contained in:
parent
2a278ceb8f
commit
f7556de9fb
12 changed files with 61 additions and 10 deletions
|
@ -1177,7 +1177,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
|
||||
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
|
||||
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
|
||||
.SetMethod("setPermissionRequestHandler",
|
||||
.SetMethod("_setPermissionRequestHandler",
|
||||
&WebContents::SetPermissionRequestHandler)
|
||||
.SetProperty("session", &WebContents::Session)
|
||||
.SetProperty("devToolsWebContents", &WebContents::DevToolsWebContents)
|
||||
|
|
|
@ -65,10 +65,10 @@ std::string RemoveWhitespace(const std::string& str) {
|
|||
AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||
bool in_memory)
|
||||
: brightray::BrowserContext(partition, in_memory),
|
||||
permission_manager_(new AtomPermissionManager),
|
||||
cert_verifier_(nullptr),
|
||||
job_factory_(new AtomURLRequestJobFactory),
|
||||
network_delegate_(new AtomNetworkDelegate),
|
||||
permission_manager_(new AtomPermissionManager),
|
||||
allow_ntlm_everywhere_(false) {
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "atom/browser/atom_permission_manager.h"
|
||||
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/permission_type.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
@ -53,8 +54,14 @@ int AtomPermissionManager::RequestPermission(
|
|||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const ResponseCallback& callback) {
|
||||
auto request_handler =
|
||||
request_handler_map_.find(render_frame_host->GetProcess()->GetID());
|
||||
int process_id = render_frame_host->GetProcess()->GetID();
|
||||
auto request_handler = request_handler_map_.find(process_id);
|
||||
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(process_id);
|
||||
}
|
||||
|
||||
if (request_handler != request_handler_map_.end()) {
|
||||
pending_requests_[++request_id_] = callback;
|
||||
request_handler->second.Run(permission, callback);
|
||||
|
@ -83,7 +90,7 @@ content::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
|||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) {
|
||||
return content::PERMISSION_STATUS_DENIED;
|
||||
return content::PERMISSION_STATUS_GRANTED;
|
||||
}
|
||||
|
||||
void AtomPermissionManager::RegisterPermissionUsage(
|
||||
|
|
|
@ -24,7 +24,9 @@ class AtomPermissionManager : public content::PermissionManager {
|
|||
base::Callback<void(content::PermissionType,
|
||||
const ResponseCallback&)>;
|
||||
|
||||
// Handler to dispatch permission requests in JS.
|
||||
void SetPermissionRequestHandler(int id, const RequestHandler& handler);
|
||||
|
||||
void RequestPermission(
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
|
|
|
@ -136,7 +136,9 @@ var createGuest = function(embedder, params) {
|
|||
this.setAllowTransparency(params.allowtransparency);
|
||||
}
|
||||
guest.allowPopups = params.allowpopups;
|
||||
this.setPermissionRequestHandler((permission, callback) => {
|
||||
|
||||
// Dispatches permission request event.
|
||||
this._setPermissionRequestHandler((permission, callback) => {
|
||||
if (!pendingRequestsMap[this.viewInstanceId])
|
||||
pendingRequestsMap[this.viewInstanceId] = {};
|
||||
pendingRequestsMap[this.viewInstanceId][permission] = callback;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#define ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "base/callback.h"
|
||||
#include "content/public/browser/permission_type.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue