OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_ |
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "chrome/browser/permissions/permission_util.h" | 13 #include "chrome/browser/permissions/permission_util.h" |
14 #include "content/public/browser/permission_type.h" | 14 #include "content/public/browser/permission_type.h" |
15 #include "content/public/browser/web_contents_observer.h" | |
16 | 15 |
17 using base::android::JavaParamRef; | 16 using base::android::JavaParamRef; |
18 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 class WebContents; | 20 class WebContents; |
22 } | 21 } |
23 | 22 |
24 class MediaStreamDevicesController; | 23 class MediaStreamDevicesController; |
25 class GURL; | 24 class GURL; |
26 class PermissionInfoBarDelegate; | 25 class PermissionInfoBarDelegate; |
27 class Profile; | 26 class Profile; |
| 27 class TabAndroid; |
28 | 28 |
29 // Delegate class for displaying a permission prompt as a modal dialog. Used as | 29 // Delegate class for displaying a permission prompt as a modal dialog. Used as |
30 // the native to Java interface to allow Java to communicate the user's | 30 // the native to Java interface to allow Java to communicate the user's |
31 // decision. | 31 // decision. |
32 // | 32 // |
33 // This class currently wraps a PermissionInfoBarDelegate. Future refactoring | 33 // This class currently wraps a PermissionInfoBarDelegate. Future refactoring |
34 // will consolidate PermissionInfoBarDelegate and its subclasses together into | 34 // will consolidate PermissionInfoBarDelegate and its subclasses together into |
35 // GroupedPermissionInfoBarDelegate, which will then source all of its data from | 35 // GroupedPermissionInfoBarDelegate, which will then source all of its data from |
36 // an underlying PermissionPromptAndroid object. At that time, this class will | 36 // an underlying PermissionPromptAndroid object. At that time, this class will |
37 // also change to wrap a PermissionPromptAndroid. | 37 // also change to wrap a PermissionPromptAndroid. |
38 class PermissionDialogDelegate : content::WebContentsObserver { | 38 class PermissionDialogDelegate { |
39 public: | 39 public: |
40 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>; | 40 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>; |
41 | 41 |
42 // Creates a modal dialog for |type|. | 42 // Creates a modal dialog for |type|. |
43 static void Create(content::WebContents* web_contents, | 43 static void Create(content::WebContents* web_contents, |
44 content::PermissionType type, | 44 content::PermissionType type, |
45 const GURL& requesting_frame, | 45 const GURL& requesting_frame, |
46 bool user_gesture, | 46 bool user_gesture, |
47 Profile* profile, | 47 Profile* profile, |
48 const PermissionSetCallback& callback); | 48 const PermissionSetCallback& callback); |
(...skipping 16 matching lines...) Expand all Loading... |
65 void Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist); | 65 void Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist); |
66 void Dismissed(JNIEnv* env, const JavaParamRef<jobject>& obj); | 66 void Dismissed(JNIEnv* env, const JavaParamRef<jobject>& obj); |
67 void LinkClicked(JNIEnv* env, const JavaParamRef<jobject>& obj); | 67 void LinkClicked(JNIEnv* env, const JavaParamRef<jobject>& obj); |
68 | 68 |
69 // Frees this object and the wrapped PermissionInfoBarDelegate. Called from | 69 // Frees this object and the wrapped PermissionInfoBarDelegate. Called from |
70 // Java once the permission dialog has been responded to. | 70 // Java once the permission dialog has been responded to. |
71 void Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj); | 71 void Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj); |
72 | 72 |
73 private: | 73 private: |
74 PermissionDialogDelegate( | 74 PermissionDialogDelegate( |
75 content::WebContents* web_contents, | 75 TabAndroid* tab, |
76 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_); | 76 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_); |
77 ~PermissionDialogDelegate() override; | 77 ~PermissionDialogDelegate(); |
78 | 78 |
79 ScopedJavaLocalRef<jobject> CreateJavaDelegate(JNIEnv* env); | 79 ScopedJavaLocalRef<jobject> CreateJavaDelegate(JNIEnv* env); |
80 | 80 |
| 81 TabAndroid* tab_; |
| 82 |
81 // The InfoBarDelegate which this class is wrapping. | 83 // The InfoBarDelegate which this class is wrapping. |
82 // TODO(dominickn,lshang) replace this with PermissionPromptAndroid as the | 84 // TODO(dominickn,lshang) replace this with PermissionPromptAndroid as the |
83 // permission prompt refactoring continues. | 85 // permission prompt refactoring continues. |
84 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_; | 86 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_; |
85 | 87 |
86 DISALLOW_COPY_AND_ASSIGN(PermissionDialogDelegate); | 88 DISALLOW_COPY_AND_ASSIGN(PermissionDialogDelegate); |
87 }; | 89 }; |
88 | 90 |
89 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_ | 91 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_ |
OLD | NEW |