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 "net/base/escape.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, | |
20 const base::Callback<void(bool, bool)>& callback) { | 19 const base::Callback<void(bool, bool)>& callback) { |
21 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( | 20 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
22 scoped_ptr<ConfirmInfoBarDelegate>( | 21 scoped_ptr<ConfirmInfoBarDelegate>( |
23 new NotificationPermissionInfobarDelegate(requesting_frame, | 22 new NotificationPermissionInfobarDelegate(requesting_frame, |
24 display_languages, | |
25 callback)))); | 23 callback)))); |
26 } | 24 } |
27 | 25 |
28 NotificationPermissionInfobarDelegate::NotificationPermissionInfobarDelegate( | 26 NotificationPermissionInfobarDelegate::NotificationPermissionInfobarDelegate( |
29 const GURL& requesting_frame, | 27 const GURL& requesting_frame, |
30 const std::string& display_languages, | |
31 const base::Callback<void(bool, bool)>& callback) | 28 const base::Callback<void(bool, bool)>& callback) |
32 : PermissionInfobarDelegate(requesting_frame, | 29 : PermissionInfobarDelegate(requesting_frame, |
33 content::PermissionType::NOTIFICATIONS, | 30 content::PermissionType::NOTIFICATIONS, |
34 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 31 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
35 callback), | 32 callback), |
36 requesting_frame_(requesting_frame), | 33 requesting_frame_(requesting_frame) {} |
37 display_languages_(display_languages) {} | |
38 | 34 |
39 NotificationPermissionInfobarDelegate::~NotificationPermissionInfobarDelegate() | 35 NotificationPermissionInfobarDelegate::~NotificationPermissionInfobarDelegate() |
40 {} | 36 {} |
41 | 37 |
42 infobars::InfoBarDelegate::InfoBarIdentifier | 38 infobars::InfoBarDelegate::InfoBarIdentifier |
43 NotificationPermissionInfobarDelegate::GetIdentifier() const { | 39 NotificationPermissionInfobarDelegate::GetIdentifier() const { |
44 return NOTIFICATION_PERMISSION_INFOBAR_DELEGATE; | 40 return NOTIFICATION_PERMISSION_INFOBAR_DELEGATE; |
45 } | 41 } |
46 | 42 |
47 int NotificationPermissionInfobarDelegate::GetIconId() const { | 43 int NotificationPermissionInfobarDelegate::GetIconId() const { |
48 return IDR_ANDROID_INFOBAR_NOTIFICATIONS; | 44 return IDR_ANDROID_INFOBAR_NOTIFICATIONS; |
49 } | 45 } |
50 | 46 |
51 base::string16 NotificationPermissionInfobarDelegate::GetMessageText() const { | 47 base::string16 NotificationPermissionInfobarDelegate::GetMessageText() const { |
52 return l10n_util::GetStringFUTF16( | 48 return l10n_util::GetStringFUTF16( |
53 IDS_NOTIFICATION_PERMISSIONS, | 49 IDS_NOTIFICATION_PERMISSIONS, |
54 url_formatter::FormatUrlForSecurityDisplay(requesting_frame_.GetOrigin(), | 50 url_formatter::FormatUrlForSecurityDisplay( |
55 display_languages_)); | 51 requesting_frame_.GetOrigin())); |
56 } | 52 } |
OLD | NEW |