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_
|
|
|
|
|
2016-01-30 11:19:18 +00:00
|
|
|
#include "atom/browser/atom_browser_context.h"
|
2016-01-23 13:29:47 +00:00
|
|
|
#include "base/callback.h"
|
2016-01-30 11:19:18 +00:00
|
|
|
#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;
|
|
|
|
|
|
|
|
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-01-23 13:29:47 +00:00
|
|
|
|
2016-01-30 11:19:18 +00:00
|
|
|
AtomBrowserContext* browser_context() const {
|
|
|
|
return static_cast<AtomBrowserContext*>(web_contents_->GetBrowserContext());
|
|
|
|
}
|
2016-01-23 13:29:47 +00:00
|
|
|
|
|
|
|
private:
|
2016-01-30 11:19:18 +00:00
|
|
|
explicit WebContentsPermissionHelper(content::WebContents* web_contents);
|
2016-01-23 13:29:47 +00:00
|
|
|
friend class content::WebContentsUserData<WebContentsPermissionHelper>;
|
|
|
|
|
2016-01-30 11:19:18 +00:00
|
|
|
void RequestPermission(
|
|
|
|
content::PermissionType permission,
|
|
|
|
const base::Callback<void(bool)>& callback);
|
2016-01-23 13:29:47 +00:00
|
|
|
|
2016-01-30 11:19:18 +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_
|