Index: chrome/browser/notifications/incognito_denied_infobar_delegate.h |
diff --git a/chrome/browser/notifications/incognito_denied_infobar_delegate.h b/chrome/browser/notifications/incognito_denied_infobar_delegate.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4c6bbe9e74ca617d9bd795da1385ce36d2322789 |
--- /dev/null |
+++ b/chrome/browser/notifications/incognito_denied_infobar_delegate.h |
@@ -0,0 +1,59 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_NOTIFICATIONS_INCOGNITO_DENIED_INFOBAR_DELEGATE_H_ |
+#define CHROME_BROWSER_NOTIFICATIONS_INCOGNITO_DENIED_INFOBAR_DELEGATE_H_ |
+ |
+#include "base/callback.h" |
+#include "base/macros.h" |
+#include "components/infobars/core/confirm_infobar_delegate.h" |
+ |
+class InfoBarService; |
+class NavigationDetails; |
+ |
+// Specialised infobar that informs the user that notifications permission is |
+// not supported in incognito, then marks the permission as denied when the user |
+// dismisses the infobar. Together with the fact that notification permission |
+// grants are (unusually) not inherited from regular to incognito profiles |
+// (blocks are still inherited), this prevents websites from detecting whether |
+// the user is using incognito, even though notifications are completely |
+// disabled in incognito. |
+// TODO(johnme): Consider auto-dismissing the infobar after a timeout that is |
+// normally-distributed, to reduce user annoyance without revealing incognito. |
mlamouri (slow - plz ping)
2015/11/28 17:00:54
Given the likeliness that a user will ignore the i
|
+class IncognitoDeniedInfobarDelegate : public ConfirmInfoBarDelegate { |
+ public: |
+ using PermissionSetCallback = base::Callback<void(bool, bool)>; |
+ |
+ public: |
mlamouri (slow - plz ping)
2015/11/28 17:00:54
nit: redundant
johnme
2015/11/30 15:37:20
Done.
|
+ // Creates the infobar and delegate and adds the infobar to |infobar_service|. |
+ // Returns the infobar if it was successfully added. |
+ static infobars::InfoBar* Create( |
+ InfoBarService* infobar_service, |
+ const GURL& requesting_frame, |
+ const std::string& display_languages, |
+ const PermissionSetCallback& callback); |
+ |
+ private: |
+ IncognitoDeniedInfobarDelegate(const GURL& requesting_frame, |
+ const std::string& display_languages, |
+ const PermissionSetCallback& callback); |
+ ~IncognitoDeniedInfobarDelegate() override; |
+ |
+ // ConfirmInfoBarDelegate: |
+ Type GetInfoBarType() const override; |
+ int GetIconId() const override; |
+ base::string16 GetMessageText() const override; |
+ int GetButtons() const override; |
+ void InfoBarDismissed() override; |
+ |
+ void SetPermission(bool update_content_setting, bool allowed); |
+ |
+ GURL requesting_frame_; |
mlamouri (slow - plz ping)
2015/11/28 17:00:54
nit: requesitng_origin_ ?
johnme
2015/11/30 15:37:20
Done.
|
+ std::string display_languages_; |
+ const PermissionSetCallback callback_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(IncognitoDeniedInfobarDelegate); |
+}; |
+ |
+#endif // CHROME_BROWSER_NOTIFICATIONS_INCOGNITO_DENIED_INFOBAR_DELEGATE_H_ |