Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/permissions/permission_dialog_delegate.h

Issue 2462963002: Implement modal permission prompts for media permissions on Android. (Closed)
Patch Set: Nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 15 #include "content/public/browser/web_contents_observer.h"
16 16
17 using base::android::JavaParamRef; 17 using base::android::JavaParamRef;
18 using base::android::ScopedJavaLocalRef; 18 using base::android::ScopedJavaLocalRef;
19 19
20 namespace content { 20 namespace content {
21 class WebContents; 21 class WebContents;
22 } 22 }
23 23
24 class MediaStreamDevicesController;
24 class GURL; 25 class GURL;
25 class PermissionInfoBarDelegate; 26 class PermissionInfoBarDelegate;
26 class Profile; 27 class Profile;
27 28
28 // 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
29 // 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
30 // decision. 31 // decision.
31 // 32 //
32 // This class currently wraps a PermissionInfoBarDelegate. Future refactoring 33 // This class currently wraps a PermissionInfoBarDelegate. Future refactoring
33 // will consolidate PermissionInfoBarDelegate and its subclasses together into 34 // will consolidate PermissionInfoBarDelegate and its subclasses together into
34 // GroupedPermissionInfoBarDelegate, which will then source all of its data from 35 // GroupedPermissionInfoBarDelegate, which will then source all of its data from
35 // an underlying PermissionPromptAndroid object. At that time, this class will 36 // an underlying PermissionPromptAndroid object. At that time, this class will
36 // also change to wrap a PermissionPromptAndroid. 37 // also change to wrap a PermissionPromptAndroid.
37 class PermissionDialogDelegate : content::WebContentsObserver { 38 class PermissionDialogDelegate : content::WebContentsObserver {
38 public: 39 public:
39 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>; 40 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>;
40 41
41 // Creates a modal dialog for |type|. 42 // Creates a modal dialog for |type|.
42 static void Create(content::WebContents* web_contents, 43 static void Create(content::WebContents* web_contents,
43 content::PermissionType type, 44 content::PermissionType type,
44 const GURL& requesting_frame, 45 const GURL& requesting_frame,
45 bool user_gesture, 46 bool user_gesture,
46 Profile* profile, 47 Profile* profile,
47 const PermissionSetCallback& callback); 48 const PermissionSetCallback& callback);
48 49
50 // Creates a modal dialog for a media stream permission request.
51 // TODO(dominickn): remove this when media stream requests are eventually
52 // folded in with other permission requests.
53 static void CreateMediaStreamDialog(
54 content::WebContents* web_contents,
55 std::unique_ptr<MediaStreamDevicesController> controller);
49 56
50 // Returns true if we should show the user a modal permission prompt rather 57 // Returns true if we should show the user a modal permission prompt rather
51 // than an infobar. 58 // than an infobar.
52 static bool ShouldShowDialog(bool has_user_gesture); 59 static bool ShouldShowDialog(bool has_user_gesture);
53 60
54 // JNI methods. 61 // JNI methods.
55 static bool RegisterPermissionDialogDelegate(JNIEnv* env); 62 static bool RegisterPermissionDialogDelegate(JNIEnv* env);
56 void Accept(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist); 63 void Accept(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist);
57 void Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist); 64 void Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist);
58 void Dismissed(JNIEnv* env, const JavaParamRef<jobject>& obj); 65 void Dismissed(JNIEnv* env, const JavaParamRef<jobject>& obj);
(...skipping 13 matching lines...) Expand all
72 79
73 // The InfoBarDelegate which this class is wrapping. 80 // The InfoBarDelegate which this class is wrapping.
74 // TODO(dominickn,lshang) replace this with PermissionPromptAndroid as the 81 // TODO(dominickn,lshang) replace this with PermissionPromptAndroid as the
75 // permission prompt refactoring continues. 82 // permission prompt refactoring continues.
76 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_; 83 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_;
77 84
78 DISALLOW_COPY_AND_ASSIGN(PermissionDialogDelegate); 85 DISALLOW_COPY_AND_ASSIGN(PermissionDialogDelegate);
79 }; 86 };
80 87
81 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_ 88 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698