Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / notifications / notification_permission_infobar_delegate.cc
blob01970d29373a4a6a62080972878d22ab888c1778
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
3 // found in the LICENSE file.
5 #include "chrome/browser/notifications/notification_permission_infobar_delegate.h"
7 #include "chrome/browser/infobars/infobar_service.h"
8 #include "chrome/grit/generated_resources.h"
9 #include "components/infobars/core/infobar.h"
10 #include "components/url_formatter/url_formatter.h"
11 #include "grit/theme_resources.h"
12 #include "net/base/escape.h"
13 #include "ui/base/l10n/l10n_util.h"
15 // static
16 infobars::InfoBar* NotificationPermissionInfobarDelegate::Create(
17 InfoBarService* infobar_service,
18 PermissionQueueController* controller,
19 const PermissionRequestID& id,
20 const GURL& requesting_frame,
21 const std::string& display_languages) {
22 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
23 scoped_ptr<ConfirmInfoBarDelegate>(
24 new NotificationPermissionInfobarDelegate(controller, id,
25 requesting_frame,
26 display_languages))));
29 NotificationPermissionInfobarDelegate::NotificationPermissionInfobarDelegate(
30 PermissionQueueController* controller,
31 const PermissionRequestID& id,
32 const GURL& requesting_frame,
33 const std::string& display_languages)
34 : PermissionInfobarDelegate(controller, id, requesting_frame,
35 CONTENT_SETTINGS_TYPE_NOTIFICATIONS),
36 requesting_frame_(requesting_frame),
37 display_languages_(display_languages) {}
39 NotificationPermissionInfobarDelegate::~NotificationPermissionInfobarDelegate()
42 int NotificationPermissionInfobarDelegate::GetIconId() const {
43 return IDR_INFOBAR_DESKTOP_NOTIFICATIONS;
46 base::string16 NotificationPermissionInfobarDelegate::GetMessageText() const {
47 return l10n_util::GetStringFUTF16(
48 IDS_NOTIFICATION_PERMISSIONS,
49 url_formatter::FormatUrl(
50 requesting_frame_.GetOrigin(), display_languages_,
51 url_formatter::kFormatUrlOmitUsernamePassword |
52 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname,
53 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));