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

Unified Diff: chrome/browser/permissions/permission_infobar_delegate.h

Issue 2226633002: Add a feature to display a persistence toggle for permission prompts on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits, verbal change to make it geolocation-only Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/permissions/permission_infobar_delegate.h
diff --git a/chrome/browser/permissions/permission_infobar_delegate.h b/chrome/browser/permissions/permission_infobar_delegate.h
index a605229d6f487d4658f1584b1ebe1b051b3b7fbc..53dd55aa18248006a181ac614a222328a10293c8 100644
--- a/chrome/browser/permissions/permission_infobar_delegate.h
+++ b/chrome/browser/permissions/permission_infobar_delegate.h
@@ -5,12 +5,14 @@
#ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_
#define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_
+#include <memory>
+
+#include "base/callback.h"
#include "base/macros.h"
-#include "chrome/browser/infobars/infobar_service.h"
+#include "chrome/browser/permissions/permission_util.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "content/public/browser/permission_type.h"
-#include "content/public/browser/web_contents.h"
class NavigationDetails;
class Profile;
@@ -22,9 +24,22 @@ class Profile;
class PermissionInfobarDelegate : public ConfirmInfoBarDelegate {
public:
- using PermissionSetCallback = base::Callback<void(bool, bool)>;
+ using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>;
+
+ ~PermissionInfobarDelegate() override;
ContentSettingsType content_setting() const { return content_settings_type_; }
+ // Returns true if the infobar should display a toggle to allow users to
+ // opt-out of persisting their accept/deny decision.
+ bool ShouldShowPersistenceToggle() const;
+
+ // Sets whether or not a decided permission should be persisted to content
+ // settings.
+ void set_persist(bool persist) { persist_ = persist; }
+
+ // ConfirmInfoBarDelegate:
+ base::string16 GetMessageText() const override;
+
protected:
PermissionInfobarDelegate(const GURL& requesting_origin,
content::PermissionType permission_type,
@@ -32,7 +47,6 @@ class PermissionInfobarDelegate : public ConfirmInfoBarDelegate {
bool user_gesture,
Profile* profile,
const PermissionSetCallback& callback);
- ~PermissionInfobarDelegate() override;
virtual int GetMessageResourceId() const = 0;
@@ -42,21 +56,25 @@ class PermissionInfobarDelegate : public ConfirmInfoBarDelegate {
void InfoBarDismissed() override;
PermissionInfobarDelegate* AsPermissionInfobarDelegate() override;
base::string16 GetButtonLabel(InfoBarButton button) const override;
- base::string16 GetMessageText() const override;
bool Accept() override;
bool Cancel() override;
- void SetPermission(bool update_content_setting, bool allowed);
+ void SetPermission(bool update_content_setting, PermissionAction decision);
GURL requesting_origin_;
- bool action_taken_;
content::PermissionType permission_type_;
ContentSettingsType content_settings_type_;
- bool user_gesture_;
Profile* const profile_;
const PermissionSetCallback callback_;
+ bool action_taken_;
+ bool user_gesture_;
+ bool persist_;
DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate);
};
+// Implemented in platform-specific code.
+std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar(
+ std::unique_ptr<PermissionInfobarDelegate> delegate);
+
#endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698