OLD | NEW |
(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_origin, |
| 19 const std::string& display_languages, |
| 20 const base::Closure& callback) { |
| 21 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
| 22 scoped_ptr<ConfirmInfoBarDelegate>( |
| 23 new IncognitoDeniedInfobarDelegate(requesting_origin, |
| 24 display_languages, callback)))); |
| 25 } |
| 26 |
| 27 IncognitoDeniedInfobarDelegate::~IncognitoDeniedInfobarDelegate() { |
| 28 } |
| 29 |
| 30 IncognitoDeniedInfobarDelegate::IncognitoDeniedInfobarDelegate( |
| 31 const GURL& requesting_origin, |
| 32 const std::string& display_languages, |
| 33 const base::Closure& callback) |
| 34 : requesting_origin_(requesting_origin), |
| 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_origin_, |
| 53 display_languages_)); |
| 54 } |
| 55 |
| 56 int IncognitoDeniedInfobarDelegate::GetButtons() const { |
| 57 return BUTTON_NONE; |
| 58 } |
| 59 |
| 60 void IncognitoDeniedInfobarDelegate::InfoBarDismissed() { |
| 61 callback_.Run(); |
| 62 } |
OLD | NEW |