| 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.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
| 11 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 14 #include "grit/locale_settings.h" | 15 #include "grit/locale_settings.h" |
| 15 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 16 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 InfoBarDelegate* MIDIPermissionInfoBarDelegate::Create( | 21 InfoBar* MIDIPermissionInfoBarDelegate::Create( |
| 21 InfoBarService* infobar_service, | 22 InfoBarService* infobar_service, |
| 22 PermissionQueueController* controller, | 23 PermissionQueueController* controller, |
| 23 const PermissionRequestID& id, | 24 const PermissionRequestID& id, |
| 24 const GURL& requesting_frame, | 25 const GURL& requesting_frame, |
| 25 const std::string& display_languages) { | 26 const std::string& display_languages) { |
| 26 return infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 27 const content::NavigationEntry* committed_entry = |
| 27 new MIDIPermissionInfoBarDelegate(infobar_service, | 28 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); |
| 28 controller, | 29 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
| 29 id, | 30 scoped_ptr<ConfirmInfoBarDelegate>(new MIDIPermissionInfoBarDelegate( |
| 30 requesting_frame, | 31 controller, id, requesting_frame, |
| 31 display_languages))); | 32 committed_entry ? committed_entry->GetUniqueID() : 0, |
| 33 display_languages)))); |
| 32 } | 34 } |
| 33 | 35 |
| 34 MIDIPermissionInfoBarDelegate::MIDIPermissionInfoBarDelegate( | 36 MIDIPermissionInfoBarDelegate::MIDIPermissionInfoBarDelegate( |
| 35 InfoBarService* infobar_service, | |
| 36 PermissionQueueController* controller, | 37 PermissionQueueController* controller, |
| 37 const PermissionRequestID& id, | 38 const PermissionRequestID& id, |
| 38 const GURL& requesting_frame, | 39 const GURL& requesting_frame, |
| 40 int contents_unique_id, |
| 39 const std::string& display_languages) | 41 const std::string& display_languages) |
| 40 : ConfirmInfoBarDelegate(infobar_service), | 42 : ConfirmInfoBarDelegate(), |
| 41 controller_(controller), | 43 controller_(controller), |
| 42 id_(id), | 44 id_(id), |
| 43 requesting_frame_(requesting_frame), | 45 requesting_frame_(requesting_frame), |
| 46 contents_unique_id_(contents_unique_id), |
| 44 display_languages_(display_languages) { | 47 display_languages_(display_languages) { |
| 45 const content::NavigationEntry* committed_entry = infobar_service-> | 48 } |
| 46 web_contents()->GetController().GetLastCommittedEntry(); | 49 |
| 47 contents_unique_id_ = committed_entry ? committed_entry->GetUniqueID() : 0; | 50 MIDIPermissionInfoBarDelegate::~MIDIPermissionInfoBarDelegate() { |
| 48 } | 51 } |
| 49 | 52 |
| 50 void MIDIPermissionInfoBarDelegate::InfoBarDismissed() { | 53 void MIDIPermissionInfoBarDelegate::InfoBarDismissed() { |
| 51 SetPermission(false, false); | 54 SetPermission(false, false); |
| 52 } | 55 } |
| 53 | 56 |
| 54 int MIDIPermissionInfoBarDelegate::GetIconID() const { | 57 int MIDIPermissionInfoBarDelegate::GetIconID() const { |
| 55 return IDR_INFOBAR_MIDI_SYSEX; | 58 return IDR_INFOBAR_MIDI_SYSEX; |
| 56 } | 59 } |
| 57 | 60 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 87 return true; | 90 return true; |
| 88 } | 91 } |
| 89 | 92 |
| 90 bool MIDIPermissionInfoBarDelegate::Cancel() { | 93 bool MIDIPermissionInfoBarDelegate::Cancel() { |
| 91 SetPermission(true, false); | 94 SetPermission(true, false); |
| 92 return true; | 95 return true; |
| 93 } | 96 } |
| 94 | 97 |
| 95 void MIDIPermissionInfoBarDelegate::SetPermission(bool update_content_setting, | 98 void MIDIPermissionInfoBarDelegate::SetPermission(bool update_content_setting, |
| 96 bool allowed) { | 99 bool allowed) { |
| 97 controller_->OnPermissionSet(id_, requesting_frame_, | 100 controller_->OnPermissionSet(id_, requesting_frame_, web_contents()->GetURL(), |
| 98 web_contents()->GetURL(), | |
| 99 update_content_setting, allowed); | 101 update_content_setting, allowed); |
| 100 } | 102 } |
| 101 | |
| OLD | NEW |