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 namespace ui { |
| 22 class WindowAndroid; |
| 23 } |
| 24 |
| 25 // An infobar delegate to be used for requesting missing Android runtime |
| 26 // permissions for previously allowed ContentSettingsTypes. |
| 27 class PermissionUpdateInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 28 public: |
| 29 using PermissionUpdatedCallback = base::Callback<void(bool)>; |
| 30 |
| 31 // Creates an infobar to resolve conflicts in Android runtime permissions |
| 32 // and adds the infobar to |infobar_service|. Returns the infobar if it was |
| 33 // successfully added. |
| 34 static infobars::InfoBar* Create( |
| 35 content::WebContents* web_contents, |
| 36 const std::vector<ContentSettingsType>& content_settings_types, |
| 37 const PermissionUpdatedCallback& callback); |
| 38 |
| 39 // Return whether the runtime permissions currently granted to Chrome by |
| 40 // Android are compatible with ContentSettingTypes previously granted to a |
| 41 // site by the user. |
| 42 static bool ShouldShowPermissionInfobar( |
| 43 content::WebContents* web_contents, |
| 44 const std::vector<ContentSettingsType>& content_settings_types); |
| 45 |
| 46 static bool RegisterPermissionUpdateInfoBarDelegate(JNIEnv* env); |
| 47 |
| 48 void OnPermissionResult( |
| 49 JNIEnv* env, jobject obj, jboolean all_permissions_granted); |
| 50 |
| 51 private: |
| 52 PermissionUpdateInfoBarDelegate( |
| 53 content::WebContents* web_contents, |
| 54 const std::vector<ContentSettingsType>& content_settings_types, |
| 55 const PermissionUpdatedCallback& callback); |
| 56 ~PermissionUpdateInfoBarDelegate() override; |
| 57 |
| 58 // PermissionInfoBarDelegate: |
| 59 int GetIconID() const override; |
| 60 base::string16 GetMessageText() const override; |
| 61 |
| 62 // ConfirmInfoBarDelegate: |
| 63 int GetButtons() const override; |
| 64 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 65 bool Accept() override; |
| 66 bool Cancel() override; |
| 67 |
| 68 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; |
| 69 std::vector<ContentSettingsType> content_settings_types_; |
| 70 const PermissionUpdatedCallback callback_; |
| 71 ui::WindowAndroid* window_android_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(PermissionUpdateInfoBarDelegate); |
| 74 }; |
| 75 |
| 76 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID
_H_ |
OLD | NEW |