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

Unified Diff: chrome/browser/notifications/incognito_denied_infobar_delegate.h

Issue 1441143006: Disable Notifications in Incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@innoinherit
Patch Set: Address nits Created 5 years 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/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..d0c8691c4c1801bab84a57121e80f4221db3e5a6
--- /dev/null
+++ b/chrome/browser/notifications/incognito_denied_infobar_delegate.h
@@ -0,0 +1,54 @@
+// 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.
+class IncognitoDeniedInfobarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ // 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_origin,
+ const std::string& display_languages,
+ const base::Closure& dismiss_callback);
+
+ private:
+ IncognitoDeniedInfobarDelegate(const GURL& requesting_origin,
+ const std::string& display_languages,
+ const base::Closure& dismiss_callback);
+ ~IncognitoDeniedInfobarDelegate() override;
+
+ // ConfirmInfoBarDelegate:
+ Type GetInfoBarType() const override;
+ int GetIconId() const override;
+ base::string16 GetMessageText() const override;
+ int GetButtons() const override;
+ void InfoBarDismissed() override;
+
+ GURL requesting_origin_;
+ std::string display_languages_;
+ base::Closure callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(IncognitoDeniedInfobarDelegate);
+};
+
+#endif // CHROME_BROWSER_NOTIFICATIONS_INCOGNITO_DENIED_INFOBAR_DELEGATE_H_
« no previous file with comments | « chrome/browser/android/resource_id.h ('k') | chrome/browser/notifications/incognito_denied_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698