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

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

Issue 2446063002: Implement a modal permission dialog on Android gated by a feature. (Closed)
Patch Set: Rebase 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_
7
8 #include <memory>
9
10 #include "base/android/scoped_java_ref.h"
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "chrome/browser/permissions/permission_util.h"
14 #include "content/public/browser/permission_type.h"
15 #include "content/public/browser/web_contents_observer.h"
16
17 using base::android::JavaParamRef;
18 using base::android::ScopedJavaLocalRef;
19
20 namespace content {
21 class WebContents;
22 }
23
24 class GURL;
25 class PermissionInfoBarDelegate;
26 class Profile;
27
28 // 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 // decision.
31 //
32 // This class currently wraps a PermissionInfoBarDelegate. Future refactoring
33 // will consolidate PermissionInfoBarDelegate and its subclasses together into
34 // GroupedPermissionInfoBarDelegate, which will then source all of its data from
35 // an underlying PermissionPromptAndroid object. At that time, this class will
36 // also change to wrap a PermissionPromptAndroid.
37 class PermissionDialogDelegate : content::WebContentsObserver {
38 public:
39 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>;
40
41 // Creates a modal dialog for |type|.
42 static void Create(content::PermissionType type,
43 content::WebContents* web_contents,
44 const GURL& requesting_frame,
45 bool user_gesture,
46 Profile* profile,
47 const PermissionSetCallback& callback);
48
49 // JNI methods.
50 static bool RegisterPermissionDialogDelegate(JNIEnv* env);
51 ScopedJavaLocalRef<jobject> CreateJavaDelegate(JNIEnv* env);
52 void Accept(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist);
53 void Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean persist);
54 void Dismissed(JNIEnv* env, const JavaParamRef<jobject>& obj);
55 void LinkClicked(JNIEnv* env, const JavaParamRef<jobject>& obj);
56
57 // Frees this object and the wrapped PermissionInfoBarDelegate. Called from
58 // Java once the permission dialog has been responded to.
59 void Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj);
60
61 private:
62 PermissionDialogDelegate(
63 content::WebContents* web_contents,
64 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_);
65 ~PermissionDialogDelegate() override;
66
67 // The InfoBarDelegate which this class is wrapping.
68 // TODO(dominickn,lshang) replace this with PermissionPromptAndroid as the
69 // permission prompt refactoring continues.
70 std::unique_ptr<PermissionInfoBarDelegate> infobar_delegate_;
71
72 DISALLOW_COPY_AND_ASSIGN(PermissionDialogDelegate);
73 };
74
75 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_DIALOG_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698