Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / permissions / permission_update_infobar_delegate_android.h
blob28767382dc35d33e32a119e88fc3f463a4902b34
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.
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID_H_
8 #include <jni.h>
9 #include <vector>
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"
17 namespace content {
18 class WebContents;
21 namespace ui {
22 class WindowAndroid;
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)>;
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);
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);
46 static bool RegisterPermissionUpdateInfoBarDelegate(JNIEnv* env);
48 void OnPermissionResult(
49 JNIEnv* env, jobject obj, jboolean all_permissions_granted);
51 private:
52 PermissionUpdateInfoBarDelegate(
53 content::WebContents* web_contents,
54 const std::vector<ContentSettingsType>& content_settings_types,
55 const PermissionUpdatedCallback& callback);
56 ~PermissionUpdateInfoBarDelegate() override;
58 // PermissionInfoBarDelegate:
59 int GetIconId() const override;
60 base::string16 GetMessageText() const override;
62 // ConfirmInfoBarDelegate:
63 int GetButtons() const override;
64 base::string16 GetButtonLabel(InfoBarButton button) const override;
65 bool Accept() override;
66 bool Cancel() override;
68 base::android::ScopedJavaGlobalRef<jobject> java_delegate_;
69 std::vector<ContentSettingsType> content_settings_types_;
70 const PermissionUpdatedCallback callback_;
71 ui::WindowAndroid* window_android_;
73 DISALLOW_COPY_AND_ASSIGN(PermissionUpdateInfoBarDelegate);
76 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID_H_