1 // Copyright 2013 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/storage/durable_storage_permission_infobar_delegate.h"
7 #include "base/strings/utf_string_conversions.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/url_formatter.h"
12 #include "grit/theme_resources.h"
13 #include "net/base/escape.h"
14 #include "ui/base/l10n/l10n_util.h"
17 infobars::InfoBar
* DurableStoragePermissionInfoBarDelegate::Create(
18 InfoBarService
* infobar_service
,
19 PermissionQueueController
* controller
,
20 const PermissionRequestID
& id
,
21 const GURL
& requesting_frame
,
22 const std::string
& display_languages
,
23 ContentSettingsType type
) {
24 return infobar_service
->AddInfoBar(
25 infobar_service
->CreateConfirmInfoBar(scoped_ptr
<ConfirmInfoBarDelegate
>(
26 new DurableStoragePermissionInfoBarDelegate(
27 controller
, id
, requesting_frame
, display_languages
, type
))));
30 DurableStoragePermissionInfoBarDelegate::
31 DurableStoragePermissionInfoBarDelegate(
32 PermissionQueueController
* controller
,
33 const PermissionRequestID
& id
,
34 const GURL
& requesting_frame
,
35 const std::string
& display_languages
,
36 ContentSettingsType type
)
37 : PermissionInfobarDelegate(controller
, id
, requesting_frame
, type
),
38 requesting_frame_(requesting_frame
),
39 display_languages_(display_languages
) {
42 base::string16
DurableStoragePermissionInfoBarDelegate::GetMessageText() const {
43 return l10n_util::GetStringFUTF16(
44 IDS_DURABLE_STORAGE_INFOBAR_QUESTION
,
45 url_formatter::FormatUrl(
46 requesting_frame_
.GetOrigin(), display_languages_
,
47 url_formatter::kFormatUrlOmitUsernamePassword
|
48 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname
,
49 net::UnescapeRule::SPACES
, NULL
, NULL
, NULL
));