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

Side by Side 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 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/incognito_denied_infobar_delegate.h"
6
7 #include "chrome/browser/android/android_theme_resources.h"
8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "components/infobars/core/infobar.h"
11 #include "components/url_formatter/elide_url.h"
12 #include "grit/theme_resources.h"
13 #include "ui/base/l10n/l10n_util.h"
14
15 // static
16 infobars::InfoBar* IncognitoDeniedInfobarDelegate::Create(
17 InfoBarService* infobar_service,
18 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.
19 const std::string& display_languages,
20 const base::Callback<void(bool, bool)>& callback) {
21 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
22 scoped_ptr<ConfirmInfoBarDelegate>(
23 new IncognitoDeniedInfobarDelegate(requesting_frame,
24 display_languages, callback))));
25 }
26
27 IncognitoDeniedInfobarDelegate::~IncognitoDeniedInfobarDelegate() {
28 }
29
30 IncognitoDeniedInfobarDelegate::IncognitoDeniedInfobarDelegate(
31 const GURL& requesting_frame,
32 const std::string& display_languages,
33 const base::Callback<void(bool, bool)>& callback)
34 : requesting_frame_(requesting_frame),
35 display_languages_(display_languages),
36 callback_(callback) {
37 }
38
39 infobars::InfoBarDelegate::Type
40 IncognitoDeniedInfobarDelegate::GetInfoBarType() const {
41 return PAGE_ACTION_TYPE;
42 }
43
44 int IncognitoDeniedInfobarDelegate::GetIconId() const {
45 // Keep this consistent with NotificationPermissionInfobarDelegate::GetIconId.
46 return IDR_INFOBAR_DESKTOP_NOTIFICATIONS;
47 }
48
49 base::string16 IncognitoDeniedInfobarDelegate::GetMessageText() const {
50 return l10n_util::GetStringFUTF16(
51 IDS_NOTIFICATION_PERMISSIONS_INCOGNITO,
52 url_formatter::FormatUrlForSecurityDisplay(requesting_frame_.GetOrigin(),
53 display_languages_));
54 }
55
56 int IncognitoDeniedInfobarDelegate::GetButtons() const {
57 return BUTTON_NONE;
58 }
59
60 void IncognitoDeniedInfobarDelegate::InfoBarDismissed() {
61 SetPermission(true, false);
62 }
63
64 void IncognitoDeniedInfobarDelegate::SetPermission(bool update_content_setting,
65 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
66 callback_.Run(update_content_setting, allowed);
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698