delegate to permission manager for other permissions
[platform/framework/web/crosswalk-tizen.git] / atom / browser / web_contents_permission_helper.h
1 // Copyright (c) 2016 GitHub, Inc.
2 // Use of this source code is governed by the MIT license that can be
3 // found in the LICENSE file.
4
5 #ifndef ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
6 #define ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
7
8 #include "atom/browser/atom_browser_context.h"
9 #include "base/callback.h"
10 #include "content/public/browser/permission_type.h"
11 #include "content/public/browser/web_contents_user_data.h"
12 #include "content/public/common/media_stream_request.h"
13
14 namespace atom {
15
16 // Applies the permission requested for WebContents.
17 class WebContentsPermissionHelper
18     : public content::WebContentsUserData<WebContentsPermissionHelper> {
19  public:
20   ~WebContentsPermissionHelper() override;
21
22   void RequestMediaAccessPermission(
23       const content::MediaStreamRequest& request,
24       const content::MediaResponseCallback& callback);
25   void RequestWebNotificationPermission(
26       const base::Callback<void(bool)>& callback);
27
28   AtomBrowserContext* browser_context() const {
29     return static_cast<AtomBrowserContext*>(web_contents_->GetBrowserContext());
30   }
31
32  private:
33   explicit WebContentsPermissionHelper(content::WebContents* web_contents);
34   friend class content::WebContentsUserData<WebContentsPermissionHelper>;
35
36   void RequestPermission(
37       content::PermissionType permission,
38       const base::Callback<void(bool)>& callback);
39
40   content::WebContents* web_contents_;
41
42   DISALLOW_COPY_AND_ASSIGN(WebContentsPermissionHelper);
43 };
44
45 }  // namespace atom
46
47 #endif  // ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_