OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/media/protected_media_identifier_infobar_delegate.h" | 5 #include "chrome/browser/media/protected_media_identifier_infobar_delegate.h" |
6 | 6 |
7 #include "chrome/browser/content_settings/permission_queue_controller.h" | 7 #include "chrome/browser/content_settings/permission_queue_controller.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
9 #include "chrome/browser/permissions/permission_request_id.h" | 9 #include "chrome/browser/permissions/permission_request_id.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
12 #include "components/infobars/core/infobar.h" | 12 #include "components/infobars/core/infobar.h" |
| 13 #include "components/url_formatter/url_formatter.h" |
13 #include "grit/components_strings.h" | 14 #include "grit/components_strings.h" |
14 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
15 #include "net/base/net_util.h" | |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 | 17 |
18 // static | 18 // static |
19 infobars::InfoBar* ProtectedMediaIdentifierInfoBarDelegate::Create( | 19 infobars::InfoBar* ProtectedMediaIdentifierInfoBarDelegate::Create( |
20 InfoBarService* infobar_service, | 20 InfoBarService* infobar_service, |
21 PermissionQueueController* controller, | 21 PermissionQueueController* controller, |
22 const PermissionRequestID& id, | 22 const PermissionRequestID& id, |
23 const GURL& requesting_frame, | 23 const GURL& requesting_frame, |
24 const std::string& display_languages) { | 24 const std::string& display_languages) { |
25 return infobar_service->AddInfoBar( | 25 return infobar_service->AddInfoBar( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return IDR_INFOBAR_PROTECTED_MEDIA_IDENTIFIER; | 70 return IDR_INFOBAR_PROTECTED_MEDIA_IDENTIFIER; |
71 } | 71 } |
72 | 72 |
73 void ProtectedMediaIdentifierInfoBarDelegate::InfoBarDismissed() { | 73 void ProtectedMediaIdentifierInfoBarDelegate::InfoBarDismissed() { |
74 SetPermission(false, false); | 74 SetPermission(false, false); |
75 } | 75 } |
76 | 76 |
77 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetMessageText() const { | 77 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetMessageText() const { |
78 return l10n_util::GetStringFUTF16( | 78 return l10n_util::GetStringFUTF16( |
79 IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION, | 79 IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION, |
80 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_)); | 80 url_formatter::FormatUrl(requesting_frame_.GetOrigin(), |
| 81 display_languages_)); |
81 } | 82 } |
82 | 83 |
83 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetButtonLabel( | 84 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetButtonLabel( |
84 InfoBarButton button) const { | 85 InfoBarButton button) const { |
85 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 86 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
86 IDS_PROTECTED_MEDIA_IDENTIFIER_ALLOW_BUTTON : | 87 IDS_PROTECTED_MEDIA_IDENTIFIER_ALLOW_BUTTON : |
87 IDS_PROTECTED_MEDIA_IDENTIFIER_DENY_BUTTON); | 88 IDS_PROTECTED_MEDIA_IDENTIFIER_DENY_BUTTON); |
88 } | 89 } |
89 | 90 |
90 bool ProtectedMediaIdentifierInfoBarDelegate::Cancel() { | 91 bool ProtectedMediaIdentifierInfoBarDelegate::Cancel() { |
91 SetPermission(true, false); | 92 SetPermission(true, false); |
92 return true; | 93 return true; |
93 } | 94 } |
94 | 95 |
95 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetLinkText() const { | 96 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetLinkText() const { |
96 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 97 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
97 } | 98 } |
98 | 99 |
99 bool ProtectedMediaIdentifierInfoBarDelegate::LinkClicked( | 100 bool ProtectedMediaIdentifierInfoBarDelegate::LinkClicked( |
100 WindowOpenDisposition disposition) { | 101 WindowOpenDisposition disposition) { |
101 InfoBarService::WebContentsFromInfoBar(infobar()) | 102 InfoBarService::WebContentsFromInfoBar(infobar()) |
102 ->OpenURL(content::OpenURLParams( | 103 ->OpenURL(content::OpenURLParams( |
103 GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL), | 104 GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL), |
104 content::Referrer(), | 105 content::Referrer(), |
105 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 106 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
106 ui::PAGE_TRANSITION_LINK, false)); | 107 ui::PAGE_TRANSITION_LINK, false)); |
107 return false; // Do not dismiss the info bar. | 108 return false; // Do not dismiss the info bar. |
108 } | 109 } |
OLD | NEW |