electron/atom/browser/web_contents_permission_helper.h

57 lines
1.8 KiB
C
Raw Normal View History

2016-01-23 13:29:47 +00:00
// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
#define ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
#include "content/public/browser/permission_type.h"
2016-01-23 13:29:47 +00:00
#include "content/public/browser/web_contents_user_data.h"
#include "content/public/common/media_stream_request.h"
namespace atom {
// Applies the permission requested for WebContents.
class WebContentsPermissionHelper
: public content::WebContentsUserData<WebContentsPermissionHelper> {
public:
~WebContentsPermissionHelper() override;
2016-02-01 09:43:49 +00:00
enum class PermissionType {
POINTER_LOCK = static_cast<int>(content::PermissionType::NUM) + 1,
FULLSCREEN,
OPEN_EXTERNAL,
2016-02-01 09:43:49 +00:00
};
2016-02-01 10:03:38 +00:00
void RequestFullscreenPermission(
const base::Callback<void(bool)>& callback);
2016-01-23 13:29:47 +00:00
void RequestMediaAccessPermission(
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback);
2016-01-25 16:37:15 +00:00
void RequestWebNotificationPermission(
const base::Callback<void(bool)>& callback);
2016-02-01 09:43:49 +00:00
void RequestPointerLockPermission(bool user_gesture);
void RequestOpenExternalPermission(
const base::Callback<void(bool)>& callback,
bool user_gesture,
const GURL& url);
2016-01-23 13:29:47 +00:00
private:
explicit WebContentsPermissionHelper(content::WebContents* web_contents);
2016-01-23 13:29:47 +00:00
friend class content::WebContentsUserData<WebContentsPermissionHelper>;
void RequestPermission(
content::PermissionType permission,
2016-02-01 09:43:49 +00:00
const base::Callback<void(bool)>& callback,
2017-12-20 01:49:49 +00:00
bool user_gesture = false,
const base::DictionaryValue* details = nullptr);
2016-01-23 13:29:47 +00:00
content::WebContents* web_contents_;
2016-01-23 13:29:47 +00:00
DISALLOW_COPY_AND_ASSIGN(WebContentsPermissionHelper);
};
} // namespace atom
#endif // ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_