OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_UPDATE_INFOBAR_DELEGATE_ANDROID_H_ | |
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <vector> | |
10 | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "base/callback.h" | |
13 #include "base/strings/string16.h" | |
14 #include "components/content_settings/core/common/content_settings_types.h" | |
15 #include "components/infobars/core/confirm_infobar_delegate.h" | |
16 | |
17 namespace content { | |
18 class WebContents; | |
19 } | |
20 | |
21 // An infobar delegate to be used for requesting missing Android runtime | |
22 // permissions for previously allowed ContentSettingsTypes. | |
23 class PermissionUpdateInfoBarDelegate : public ConfirmInfoBarDelegate { | |
24 public: | |
25 using PermissionUpdatedCallback = base::Callback<void(bool)>; | |
26 | |
27 // Creates an infobar to resolve conflicts in Android runtime permissions | |
28 // and adds the infobar to |infobar_service|. Returns the infobar if it was | |
29 // successfully added. | |
30 static infobars::InfoBar* Create( | |
31 content::WebContents* web_contents, | |
32 const std::vector<ContentSettingsType>& content_settings_types, | |
33 const PermissionUpdatedCallback& callback); | |
34 | |
35 // Return whether a permission update infobar should be shown that will allow | |
36 // the user to correct the mismatch between the runtime permissions granted to | |
37 // Chrome and the previously granted ContentSettingTypes to a particular site. | |
gone
2015/07/17 17:41:40
// Return whether the runtime permissions currentl
Ted C
2015/07/17 20:37:18
Done.
| |
38 static bool ShouldShowPermissionInfobar( | |
39 content::WebContents* web_contents, | |
40 const std::vector<ContentSettingsType>& content_settings_types); | |
41 | |
42 static bool RegisterPermissionUpdateInfoBarDelegate(JNIEnv* env); | |
43 | |
44 void OnPermissionResult( | |
45 JNIEnv* env, jobject obj, jboolean all_permissions_granted); | |
46 | |
47 private: | |
48 PermissionUpdateInfoBarDelegate( | |
49 content::WebContents* web_contents, | |
50 const std::vector<ContentSettingsType>& content_settings_types, | |
51 const PermissionUpdatedCallback& callback); | |
52 ~PermissionUpdateInfoBarDelegate() override; | |
53 | |
54 // PermissionInfoBarDelegate: | |
55 int GetIconID() const override; | |
56 base::string16 GetMessageText() const override; | |
57 | |
58 // ConfirmInfoBarDelegate: | |
59 int GetButtons() const override; | |
60 base::string16 GetButtonLabel(InfoBarButton button) const; | |
61 bool Accept() override; | |
62 bool Cancel() override; | |
63 | |
64 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; | |
65 std::vector<ContentSettingsType> content_settings_types_; | |
66 const PermissionUpdatedCallback callback_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(PermissionUpdateInfoBarDelegate); | |
69 }; | |
70 | |
71 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID _H_ | |
OLD | NEW |