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

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

Issue 2250053002: Clean up the PermissionInfoBarDelegate hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-infobar-remember-decision
Patch Set: 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 53dd55aa18248006a181ac614a222328a10293c8..2b8527b3008763aa51530decf9e3b34f28785e7a 100644
--- a/chrome/browser/permissions/permission_infobar_delegate.h
+++ b/chrome/browser/permissions/permission_infobar_delegate.h
@@ -12,69 +12,44 @@
#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"
-
-class NavigationDetails;
-class Profile;
-
-// Base class for permission infobars, it implements the default behavior
-// so that the accept/deny buttons grant/deny the relevant permission.
-// A basic implementor only needs to implement the methods that
-// provide an icon and a message text to the infobar.
-class PermissionInfobarDelegate : public ConfirmInfoBarDelegate {
+#include "url/gurl.h"
+// Base class for permission infobars.
raymes 2016/08/17 03:20:43 nit: fill 80chars or new paragraph
dominickn 2016/08/17 03:29:38 Done.
+// Implementors should inherit from SinglePermissionInfoBarDelegate or
+// GroupedPermissionInfobarDelegate.
+class PermissionInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>;
-
- ~PermissionInfobarDelegate() override;
- ContentSettingsType content_setting() const { return content_settings_type_; }
+ ~PermissionInfoBarDelegate() override;
+ virtual ContentSettingsType GetContentSettingType(int index) const = 0;
raymes 2016/08/17 03:20:43 It seems like we only ever need the first content
dominickn 2016/08/17 03:29:38 The GroupedPermissionInfobarDelegate uses the inde
raymes 2016/08/17 03:44:41 Hmm it's unclear whether the one callsite which cu
// Returns true if the infobar should display a toggle to allow users to
// opt-out of persisting their accept/deny decision.
- bool ShouldShowPersistenceToggle() const;
+ virtual 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,
- ContentSettingsType content_settings_type,
- bool user_gesture,
- Profile* profile,
- const PermissionSetCallback& callback);
+ explicit PermissionInfoBarDelegate(const GURL& requesting_origin);
- virtual int GetMessageResourceId() const = 0;
+ const GURL& requesting_origin() const { return requesting_origin_; }
+ bool persist() const { return persist_; }
private:
// ConfirmInfoBarDelegate:
Type GetInfoBarType() const override;
- void InfoBarDismissed() override;
- PermissionInfobarDelegate* AsPermissionInfobarDelegate() override;
- base::string16 GetButtonLabel(InfoBarButton button) const override;
- bool Accept() override;
- bool Cancel() override;
-
- void SetPermission(bool update_content_setting, PermissionAction decision);
+ PermissionInfoBarDelegate* AsPermissionInfoBarDelegate() override;
GURL requesting_origin_;
- content::PermissionType permission_type_;
- ContentSettingsType content_settings_type_;
- Profile* const profile_;
- const PermissionSetCallback callback_;
- bool action_taken_;
- bool user_gesture_;
bool persist_;
- DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate);
+ DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarDelegate);
};
// Implemented in platform-specific code.
std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar(
- std::unique_ptr<PermissionInfobarDelegate> delegate);
+ std::unique_ptr<PermissionInfoBarDelegate> delegate);
#endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698