Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: chrome/browser/media/protected_media_identifier_infobar_delegate.cc

Issue 1142153002: Simplify infobar expiry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android compile Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
11 #include "components/infobars/core/infobar.h" 11 #include "components/infobars/core/infobar.h"
12 #include "content/public/browser/navigation_entry.h"
13 #include "grit/components_strings.h" 12 #include "grit/components_strings.h"
14 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
15 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
16 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
17 16
18 // static 17 // static
19 infobars::InfoBar* ProtectedMediaIdentifierInfoBarDelegate::Create( 18 infobars::InfoBar* ProtectedMediaIdentifierInfoBarDelegate::Create(
20 InfoBarService* infobar_service, 19 InfoBarService* infobar_service,
21 PermissionQueueController* controller, 20 PermissionQueueController* controller,
22 const PermissionRequestID& id, 21 const PermissionRequestID& id,
23 const GURL& requesting_frame, 22 const GURL& requesting_frame,
24 const std::string& display_languages) { 23 const std::string& display_languages) {
25 const content::NavigationEntry* committed_entry =
26 infobar_service->web_contents()->GetController().GetLastCommittedEntry();
27 return infobar_service->AddInfoBar( 24 return infobar_service->AddInfoBar(
28 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( 25 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
29 new ProtectedMediaIdentifierInfoBarDelegate( 26 new ProtectedMediaIdentifierInfoBarDelegate(
30 controller, id, requesting_frame, 27 controller, id, requesting_frame, display_languages))));
31 committed_entry ? committed_entry->GetUniqueID() : 0,
32 display_languages))));
33 } 28 }
34 29
35 30
36 ProtectedMediaIdentifierInfoBarDelegate:: 31 ProtectedMediaIdentifierInfoBarDelegate::
37 ProtectedMediaIdentifierInfoBarDelegate( 32 ProtectedMediaIdentifierInfoBarDelegate(
38 PermissionQueueController* controller, 33 PermissionQueueController* controller,
39 const PermissionRequestID& id, 34 const PermissionRequestID& id,
40 const GURL& requesting_frame, 35 const GURL& requesting_frame,
41 int contents_unique_id,
42 const std::string& display_languages) 36 const std::string& display_languages)
43 : ConfirmInfoBarDelegate(), 37 : ConfirmInfoBarDelegate(),
44 controller_(controller), 38 controller_(controller),
45 id_(id), 39 id_(id),
46 requesting_frame_(requesting_frame), 40 requesting_frame_(requesting_frame),
47 contents_unique_id_(contents_unique_id),
48 display_languages_(display_languages) { 41 display_languages_(display_languages) {
49 } 42 }
50 43
51 ProtectedMediaIdentifierInfoBarDelegate:: 44 ProtectedMediaIdentifierInfoBarDelegate::
52 ~ProtectedMediaIdentifierInfoBarDelegate() { 45 ~ProtectedMediaIdentifierInfoBarDelegate() {
53 } 46 }
54 47
55 bool ProtectedMediaIdentifierInfoBarDelegate::Accept() { 48 bool ProtectedMediaIdentifierInfoBarDelegate::Accept() {
56 SetPermission(true, true); 49 SetPermission(true, true);
57 return true; 50 return true;
(...skipping 15 matching lines...) Expand all
73 } 66 }
74 67
75 int ProtectedMediaIdentifierInfoBarDelegate::GetIconID() const { 68 int ProtectedMediaIdentifierInfoBarDelegate::GetIconID() const {
76 return IDR_INFOBAR_PROTECTED_MEDIA_IDENTIFIER; 69 return IDR_INFOBAR_PROTECTED_MEDIA_IDENTIFIER;
77 } 70 }
78 71
79 void ProtectedMediaIdentifierInfoBarDelegate::InfoBarDismissed() { 72 void ProtectedMediaIdentifierInfoBarDelegate::InfoBarDismissed() {
80 SetPermission(false, false); 73 SetPermission(false, false);
81 } 74 }
82 75
83 bool ProtectedMediaIdentifierInfoBarDelegate::ShouldExpireInternal(
84 const NavigationDetails& details) const {
85 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but
86 // uses the unique ID we set in the constructor instead of that stored in the
87 // base class.
88 return (contents_unique_id_ != details.entry_id) || details.is_reload;
89 }
90
91 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetMessageText() const { 76 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetMessageText() const {
92 return l10n_util::GetStringFUTF16( 77 return l10n_util::GetStringFUTF16(
93 IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION, 78 IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION,
94 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_)); 79 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_));
95 } 80 }
96 81
97 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetButtonLabel( 82 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetButtonLabel(
98 InfoBarButton button) const { 83 InfoBarButton button) const {
99 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 84 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
100 IDS_PROTECTED_MEDIA_IDENTIFIER_ALLOW_BUTTON : 85 IDS_PROTECTED_MEDIA_IDENTIFIER_ALLOW_BUTTON :
101 IDS_PROTECTED_MEDIA_IDENTIFIER_DENY_BUTTON); 86 IDS_PROTECTED_MEDIA_IDENTIFIER_DENY_BUTTON);
102 } 87 }
103 88
104 bool ProtectedMediaIdentifierInfoBarDelegate::Cancel() { 89 bool ProtectedMediaIdentifierInfoBarDelegate::Cancel() {
105 SetPermission(true, false); 90 SetPermission(true, false);
106 return true; 91 return true;
107 } 92 }
108 93
109 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetLinkText() const { 94 base::string16 ProtectedMediaIdentifierInfoBarDelegate::GetLinkText() const {
110 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 95 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
111 } 96 }
112 97
113 bool ProtectedMediaIdentifierInfoBarDelegate::LinkClicked( 98 bool ProtectedMediaIdentifierInfoBarDelegate::LinkClicked(
114 WindowOpenDisposition disposition) { 99 WindowOpenDisposition disposition) {
115 const GURL learn_more_url(chrome::kEnhancedPlaybackNotificationLearnMoreURL);
116 InfoBarService::WebContentsFromInfoBar(infobar()) 100 InfoBarService::WebContentsFromInfoBar(infobar())
117 ->OpenURL(content::OpenURLParams( 101 ->OpenURL(content::OpenURLParams(
118 learn_more_url, content::Referrer(), 102 GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL),
103 content::Referrer(),
119 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 104 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
120 ui::PAGE_TRANSITION_LINK, false)); 105 ui::PAGE_TRANSITION_LINK, false));
121 return false; // Do not dismiss the info bar. 106 return false; // Do not dismiss the info bar.
122 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698