Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / media / protected_media_identifier_infobar_delegate.cc
blob780324ae60079b579753a3fb9e0aa919bbe18141
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/media/protected_media_identifier_infobar_delegate.h"
7 #include "chrome/browser/infobars/infobar_service.h"
8 #include "chrome/common/url_constants.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/components_strings.h"
13 #include "grit/theme_resources.h"
14 #include "ui/base/l10n/l10n_util.h"
16 // static
17 infobars::InfoBar* ProtectedMediaIdentifierInfoBarDelegate::Create(
18 InfoBarService* infobar_service,
19 const GURL& requesting_frame,
20 const std::string& display_languages,
21 const PermissionSetCallback& callback) {
22 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
23 scoped_ptr<ConfirmInfoBarDelegate>(
24 new ProtectedMediaIdentifierInfoBarDelegate(
25 requesting_frame, display_languages, callback))));
28 ProtectedMediaIdentifierInfoBarDelegate::
29 ProtectedMediaIdentifierInfoBarDelegate(
30 const GURL& requesting_frame,
31 const std::string& display_languages,
32 const PermissionSetCallback& callback)
33 : PermissionInfobarDelegate(
34 requesting_frame,
35 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER,
36 callback),
37 requesting_frame_(requesting_frame),
38 display_languages_(display_languages) {
41 ProtectedMediaIdentifierInfoBarDelegate::
42 ~ProtectedMediaIdentifierInfoBarDelegate() {
45 int ProtectedMediaIdentifierInfoBarDelegate::GetIconId() const {
46 return IDR_INFOBAR_PROTECTED_MEDIA_IDENTIFIER;
49 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetMessageText() const {
50 return l10n_util::GetStringFUTF16(
51 IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION,
52 url_formatter::FormatUrl(requesting_frame_.GetOrigin(),
53 display_languages_));
56 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetLinkText() const {
57 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
60 bool ProtectedMediaIdentifierInfoBarDelegate::LinkClicked(
61 WindowOpenDisposition disposition) {
62 InfoBarService::WebContentsFromInfoBar(infobar())
63 ->OpenURL(content::OpenURLParams(
64 GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL),
65 content::Referrer(),
66 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
67 ui::PAGE_TRANSITION_LINK, false));
68 return false; // Do not dismiss the info bar.