OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/notification_permission_infobar_delegate.
h" | 5 #include "chrome/browser/notifications/notification_permission_infobar_delegate.
h" |
6 | 6 |
7 #include "chrome/browser/android/android_theme_resources.h" | 7 #include "chrome/browser/android/android_theme_resources.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
11 #include "components/url_formatter/elide_url.h" | 11 #include "components/url_formatter/elide_url.h" |
12 #include "net/base/escape.h" | 12 #include "grit/theme_resources.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 | 14 |
15 // static | 15 // static |
16 infobars::InfoBar* NotificationPermissionInfobarDelegate::Create( | 16 infobars::InfoBar* NotificationPermissionInfobarDelegate::Create( |
17 InfoBarService* infobar_service, | 17 InfoBarService* infobar_service, |
18 const GURL& requesting_frame, | 18 const GURL& requesting_frame, |
19 const std::string& display_languages, | 19 const std::string& display_languages, |
20 const base::Callback<void(bool, bool)>& callback) { | 20 const base::Callback<void(bool, bool)>& callback) { |
21 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( | 21 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
22 scoped_ptr<ConfirmInfoBarDelegate>( | 22 scoped_ptr<ConfirmInfoBarDelegate>( |
23 new NotificationPermissionInfobarDelegate(requesting_frame, | 23 new NotificationPermissionInfobarDelegate(requesting_frame, |
24 display_languages, | 24 display_languages, |
25 callback)))); | 25 callback)))); |
26 } | 26 } |
27 | 27 |
28 NotificationPermissionInfobarDelegate::NotificationPermissionInfobarDelegate( | 28 NotificationPermissionInfobarDelegate::NotificationPermissionInfobarDelegate( |
29 const GURL& requesting_frame, | 29 const GURL& requesting_frame, |
30 const std::string& display_languages, | 30 const std::string& display_languages, |
31 const base::Callback<void(bool, bool)>& callback) | 31 const base::Callback<void(bool, bool)>& callback) |
32 : PermissionInfobarDelegate(requesting_frame, | 32 : PermissionInfobarDelegate(requesting_frame, |
33 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 33 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
34 callback), | 34 callback), |
35 requesting_frame_(requesting_frame), | 35 requesting_frame_(requesting_frame), |
36 display_languages_(display_languages) {} | 36 display_languages_(display_languages) {} |
37 | 37 |
38 NotificationPermissionInfobarDelegate::~NotificationPermissionInfobarDelegate() | 38 NotificationPermissionInfobarDelegate::~NotificationPermissionInfobarDelegate() |
39 {} | 39 {} |
40 | 40 |
41 int NotificationPermissionInfobarDelegate::GetIconId() const { | 41 int NotificationPermissionInfobarDelegate::GetIconId() const { |
42 return IDR_ANDROID_INFOBAR_NOTIFICATIONS; | 42 // Keep this consistent with IncognitoDeniedInfoBarDelegate::GetIconId. |
| 43 return IDR_INFOBAR_DESKTOP_NOTIFICATIONS; |
43 } | 44 } |
44 | 45 |
45 base::string16 NotificationPermissionInfobarDelegate::GetMessageText() const { | 46 base::string16 NotificationPermissionInfobarDelegate::GetMessageText() const { |
46 return l10n_util::GetStringFUTF16( | 47 return l10n_util::GetStringFUTF16( |
47 IDS_NOTIFICATION_PERMISSIONS, | 48 IDS_NOTIFICATION_PERMISSIONS, |
48 url_formatter::FormatUrlForSecurityDisplay(requesting_frame_.GetOrigin(), | 49 url_formatter::FormatUrlForSecurityDisplay(requesting_frame_.GetOrigin(), |
49 display_languages_)); | 50 display_languages_)); |
50 } | 51 } |
OLD | NEW |