| 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/midi_permission_infobar_delegate.h" | 5 #include "chrome/browser/media/midi_permission_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/content_settings/permission_request_id.h" | 8 #include "chrome/browser/content_settings/permission_request_id.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 committed_entry ? committed_entry->GetUniqueID() : 0, | 31 committed_entry ? committed_entry->GetUniqueID() : 0, |
| 32 display_languages)))); | 32 display_languages)))); |
| 33 } | 33 } |
| 34 | 34 |
| 35 MidiPermissionInfoBarDelegate::MidiPermissionInfoBarDelegate( | 35 MidiPermissionInfoBarDelegate::MidiPermissionInfoBarDelegate( |
| 36 PermissionQueueController* controller, | 36 PermissionQueueController* controller, |
| 37 const PermissionRequestID& id, | 37 const PermissionRequestID& id, |
| 38 const GURL& requesting_frame, | 38 const GURL& requesting_frame, |
| 39 int contents_unique_id, | 39 int contents_unique_id, |
| 40 const std::string& display_languages) | 40 const std::string& display_languages) |
| 41 : ConfirmInfoBarDelegate(), | 41 : PermissionInfobarDelegate(controller, id, requesting_frame), |
| 42 controller_(controller), | |
| 43 id_(id), | |
| 44 requesting_frame_(requesting_frame), | 42 requesting_frame_(requesting_frame), |
| 45 contents_unique_id_(contents_unique_id), | |
| 46 display_languages_(display_languages) { | 43 display_languages_(display_languages) { |
| 47 } | 44 } |
| 48 | 45 |
| 49 MidiPermissionInfoBarDelegate::~MidiPermissionInfoBarDelegate() { | 46 MidiPermissionInfoBarDelegate::~MidiPermissionInfoBarDelegate() { |
| 50 } | 47 } |
| 51 | 48 |
| 52 void MidiPermissionInfoBarDelegate::InfoBarDismissed() { | |
| 53 SetPermission(false, false); | |
| 54 } | |
| 55 | |
| 56 int MidiPermissionInfoBarDelegate::GetIconID() const { | 49 int MidiPermissionInfoBarDelegate::GetIconID() const { |
| 57 return IDR_INFOBAR_MIDI; | 50 return IDR_INFOBAR_MIDI; |
| 58 } | 51 } |
| 59 | 52 |
| 60 infobars::InfoBarDelegate::Type MidiPermissionInfoBarDelegate::GetInfoBarType() | |
| 61 const { | |
| 62 return PAGE_ACTION_TYPE; | |
| 63 } | |
| 64 | |
| 65 bool MidiPermissionInfoBarDelegate::ShouldExpireInternal( | |
| 66 const NavigationDetails& details) const { | |
| 67 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but | |
| 68 // uses the unique ID we set in the constructor instead of that stored in the | |
| 69 // base class. | |
| 70 return (contents_unique_id_ != details.entry_id) || details.is_reload; | |
| 71 } | |
| 72 | |
| 73 base::string16 MidiPermissionInfoBarDelegate::GetMessageText() const { | 53 base::string16 MidiPermissionInfoBarDelegate::GetMessageText() const { |
| 74 return l10n_util::GetStringFUTF16( | 54 return l10n_util::GetStringFUTF16( |
| 75 IDS_MIDI_SYSEX_INFOBAR_QUESTION, | 55 IDS_MIDI_SYSEX_INFOBAR_QUESTION, |
| 76 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_, | 56 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_, |
| 77 net::kFormatUrlOmitUsernamePassword | | 57 net::kFormatUrlOmitUsernamePassword | |
| 78 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 58 net::kFormatUrlOmitTrailingSlashOnBareHostname, |
| 79 net::UnescapeRule::SPACES, NULL, NULL, NULL)); | 59 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
| 80 } | 60 } |
| 81 | |
| 82 base::string16 MidiPermissionInfoBarDelegate::GetButtonLabel( | |
| 83 InfoBarButton button) const { | |
| 84 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | |
| 85 IDS_MIDI_SYSEX_ALLOW_BUTTON : IDS_MIDI_SYSEX_DENY_BUTTON); | |
| 86 } | |
| 87 | |
| 88 bool MidiPermissionInfoBarDelegate::Accept() { | |
| 89 SetPermission(true, true); | |
| 90 return true; | |
| 91 } | |
| 92 | |
| 93 bool MidiPermissionInfoBarDelegate::Cancel() { | |
| 94 SetPermission(true, false); | |
| 95 return true; | |
| 96 } | |
| 97 | |
| 98 void MidiPermissionInfoBarDelegate::SetPermission(bool update_content_setting, | |
| 99 bool allowed) { | |
| 100 content::WebContents* web_contents = | |
| 101 InfoBarService::WebContentsFromInfoBar(infobar()); | |
| 102 controller_->OnPermissionSet(id_, requesting_frame_, web_contents->GetURL(), | |
| 103 update_content_setting, allowed); | |
| 104 } | |
| OLD | NEW |