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

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

Issue 1441143006: Disable Notifications in Incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@innoinherit
Patch Set: Clean up DecidePermission override, and prevent Page Info Bubble enabling permission. Created 5 years, 1 month 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.cc
diff --git a/chrome/browser/notifications/incognito_denied_infobar_delegate.cc b/chrome/browser/notifications/incognito_denied_infobar_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..938463e92541fa96b90f5ffd58a42405492eda24
--- /dev/null
+++ b/chrome/browser/notifications/incognito_denied_infobar_delegate.cc
@@ -0,0 +1,67 @@
+// 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.
+
+#include "chrome/browser/notifications/incognito_denied_infobar_delegate.h"
+
+#include "chrome/browser/android/android_theme_resources.h"
+#include "chrome/browser/infobars/infobar_service.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/infobars/core/infobar.h"
+#include "components/url_formatter/elide_url.h"
+#include "grit/theme_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+// static
+infobars::InfoBar* IncognitoDeniedInfobarDelegate::Create(
+ InfoBarService* infobar_service,
+ const GURL& requesting_frame,
mlamouri (slow - plz ping) 2015/11/28 17:00:54 nit: requesting_origin
johnme 2015/11/30 15:37:20 Done.
+ const std::string& display_languages,
+ const base::Callback<void(bool, bool)>& callback) {
+ return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate>(
+ new IncognitoDeniedInfobarDelegate(requesting_frame,
+ display_languages, callback))));
+}
+
+IncognitoDeniedInfobarDelegate::~IncognitoDeniedInfobarDelegate() {
+}
+
+IncognitoDeniedInfobarDelegate::IncognitoDeniedInfobarDelegate(
+ const GURL& requesting_frame,
+ const std::string& display_languages,
+ const base::Callback<void(bool, bool)>& callback)
+ : requesting_frame_(requesting_frame),
+ display_languages_(display_languages),
+ callback_(callback) {
+}
+
+infobars::InfoBarDelegate::Type
+IncognitoDeniedInfobarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+int IncognitoDeniedInfobarDelegate::GetIconId() const {
+ // Keep this consistent with NotificationPermissionInfobarDelegate::GetIconId.
+ return IDR_INFOBAR_DESKTOP_NOTIFICATIONS;
+}
+
+base::string16 IncognitoDeniedInfobarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(
+ IDS_NOTIFICATION_PERMISSIONS_INCOGNITO,
+ url_formatter::FormatUrlForSecurityDisplay(requesting_frame_.GetOrigin(),
+ display_languages_));
+}
+
+int IncognitoDeniedInfobarDelegate::GetButtons() const {
+ return BUTTON_NONE;
+}
+
+void IncognitoDeniedInfobarDelegate::InfoBarDismissed() {
+ SetPermission(true, false);
+}
+
+void IncognitoDeniedInfobarDelegate::SetPermission(bool update_content_setting,
+ bool allowed) {
mlamouri (slow - plz ping) 2015/11/28 17:00:54 Why do you add a ::SetPermission() if the only usa
johnme 2015/11/30 15:37:20 It was to make it clearer. But I've realised I can
+ callback_.Run(update_content_setting, allowed);
+}

Powered by Google App Engine
This is Rietveld 408576698