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/infobars/infobar_service.h" | 7 #include "chrome/browser/infobars/infobar_service.h" |
8 #include "chrome/browser/permissions/permission_queue_controller.h" | |
9 #include "chrome/browser/permissions/permission_request_id.h" | 8 #include "chrome/browser/permissions/permission_request_id.h" |
10 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
11 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
12 #include "components/infobars/core/infobar.h" | 11 #include "components/infobars/core/infobar.h" |
13 #include "components/url_formatter/url_formatter.h" | 12 #include "components/url_formatter/url_formatter.h" |
14 #include "grit/components_strings.h" | 13 #include "grit/components_strings.h" |
15 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.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, | |
22 const PermissionRequestID& id, | 20 const PermissionRequestID& id, |
23 const GURL& requesting_frame, | 21 const GURL& requesting_frame, |
24 const std::string& display_languages) { | 22 const std::string& display_languages, |
23 const base::Callback<void(bool, bool)>& callback) { | |
25 return infobar_service->AddInfoBar( | 24 return infobar_service->AddInfoBar( |
26 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( | 25 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
27 new ProtectedMediaIdentifierInfoBarDelegate( | 26 new ProtectedMediaIdentifierInfoBarDelegate( |
28 controller, id, requesting_frame, display_languages)))); | 27 id, requesting_frame, display_languages, callback)))); |
29 } | 28 } |
30 | 29 |
31 | |
32 ProtectedMediaIdentifierInfoBarDelegate:: | 30 ProtectedMediaIdentifierInfoBarDelegate:: |
33 ProtectedMediaIdentifierInfoBarDelegate( | 31 ProtectedMediaIdentifierInfoBarDelegate( |
34 PermissionQueueController* controller, | |
35 const PermissionRequestID& id, | 32 const PermissionRequestID& id, |
36 const GURL& requesting_frame, | 33 const GURL& requesting_frame, |
37 const std::string& display_languages) | 34 const std::string& display_languages, |
35 const base::Callback<void(bool, bool)>& callback) | |
38 : ConfirmInfoBarDelegate(), | 36 : ConfirmInfoBarDelegate(), |
39 controller_(controller), | |
40 id_(id), | 37 id_(id), |
41 requesting_frame_(requesting_frame), | 38 requesting_frame_(requesting_frame), |
42 display_languages_(display_languages) { | 39 display_languages_(display_languages), |
40 callback_(callback) { | |
43 } | 41 } |
44 | 42 |
45 ProtectedMediaIdentifierInfoBarDelegate:: | 43 ProtectedMediaIdentifierInfoBarDelegate:: |
46 ~ProtectedMediaIdentifierInfoBarDelegate() { | 44 ~ProtectedMediaIdentifierInfoBarDelegate() { |
47 } | 45 } |
48 | 46 |
49 bool ProtectedMediaIdentifierInfoBarDelegate::Accept() { | 47 bool ProtectedMediaIdentifierInfoBarDelegate::Accept() { |
50 SetPermission(true, true); | 48 SetPermission(true, true); |
51 return true; | 49 return true; |
52 } | 50 } |
53 | 51 |
54 void ProtectedMediaIdentifierInfoBarDelegate::SetPermission( | 52 void ProtectedMediaIdentifierInfoBarDelegate::SetPermission( |
mlamouri (slow - plz ping)
2015/09/15 12:55:59
Why is that needed? Could it directly inherits fro
Lalit Maganti
2015/09/15 13:16:53
IDK why but right now it does not inherit from Per
Lalit Maganti
2015/09/15 14:19:24
Done.
| |
55 bool update_content_setting, | 53 bool update_content_setting, |
56 bool allowed) { | 54 bool allowed) { |
57 content::WebContents* web_contents = | 55 callback_.Run(update_content_setting, allowed); |
58 InfoBarService::WebContentsFromInfoBar(infobar()); | |
59 controller_->OnPermissionSet(id_, requesting_frame_, | |
60 web_contents->GetLastCommittedURL().GetOrigin(), | |
61 update_content_setting, allowed); | |
62 } | 56 } |
63 | 57 |
64 infobars::InfoBarDelegate::Type | 58 infobars::InfoBarDelegate::Type |
65 ProtectedMediaIdentifierInfoBarDelegate::GetInfoBarType() const { | 59 ProtectedMediaIdentifierInfoBarDelegate::GetInfoBarType() const { |
66 return PAGE_ACTION_TYPE; | 60 return PAGE_ACTION_TYPE; |
67 } | 61 } |
68 | 62 |
69 int ProtectedMediaIdentifierInfoBarDelegate::GetIconId() const { | 63 int ProtectedMediaIdentifierInfoBarDelegate::GetIconId() const { |
70 return IDR_INFOBAR_PROTECTED_MEDIA_IDENTIFIER; | 64 return IDR_INFOBAR_PROTECTED_MEDIA_IDENTIFIER; |
71 } | 65 } |
(...skipping 28 matching lines...) Expand all Loading... | |
100 bool ProtectedMediaIdentifierInfoBarDelegate::LinkClicked( | 94 bool ProtectedMediaIdentifierInfoBarDelegate::LinkClicked( |
101 WindowOpenDisposition disposition) { | 95 WindowOpenDisposition disposition) { |
102 InfoBarService::WebContentsFromInfoBar(infobar()) | 96 InfoBarService::WebContentsFromInfoBar(infobar()) |
103 ->OpenURL(content::OpenURLParams( | 97 ->OpenURL(content::OpenURLParams( |
104 GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL), | 98 GURL(chrome::kEnhancedPlaybackNotificationLearnMoreURL), |
105 content::Referrer(), | 99 content::Referrer(), |
106 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 100 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
107 ui::PAGE_TRANSITION_LINK, false)); | 101 ui::PAGE_TRANSITION_LINK, false)); |
108 return false; // Do not dismiss the info bar. | 102 return false; // Do not dismiss the info bar. |
109 } | 103 } |
OLD | NEW |