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

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

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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/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.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
(...skipping 10 matching lines...) Expand all
21 InfoBar* MidiPermissionInfoBarDelegate::Create( 21 InfoBar* MidiPermissionInfoBarDelegate::Create(
22 InfoBarService* infobar_service, 22 InfoBarService* infobar_service,
23 PermissionQueueController* controller, 23 PermissionQueueController* controller,
24 const PermissionRequestID& id, 24 const PermissionRequestID& id,
25 const GURL& requesting_frame, 25 const GURL& requesting_frame,
26 const std::string& display_languages) { 26 const std::string& display_languages) {
27 const content::NavigationEntry* committed_entry = 27 const content::NavigationEntry* committed_entry =
28 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); 28 infobar_service->web_contents()->GetController().GetLastCommittedEntry();
29 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 29 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
30 scoped_ptr<ConfirmInfoBarDelegate>(new MidiPermissionInfoBarDelegate( 30 scoped_ptr<ConfirmInfoBarDelegate>(new MidiPermissionInfoBarDelegate(
31 controller, id, requesting_frame, 31 infobar_service->web_contents(),
32 controller,
33 id,
34 requesting_frame,
32 committed_entry ? committed_entry->GetUniqueID() : 0, 35 committed_entry ? committed_entry->GetUniqueID() : 0,
33 display_languages)))); 36 display_languages))));
34 } 37 }
35 38
36 MidiPermissionInfoBarDelegate::MidiPermissionInfoBarDelegate( 39 MidiPermissionInfoBarDelegate::MidiPermissionInfoBarDelegate(
40 content::WebContents* web_contents,
37 PermissionQueueController* controller, 41 PermissionQueueController* controller,
38 const PermissionRequestID& id, 42 const PermissionRequestID& id,
39 const GURL& requesting_frame, 43 const GURL& requesting_frame,
40 int contents_unique_id, 44 int contents_unique_id,
41 const std::string& display_languages) 45 const std::string& display_languages)
42 : ConfirmInfoBarDelegate(), 46 : ContentConfirmInfoBarDelegate(web_contents),
43 controller_(controller), 47 controller_(controller),
44 id_(id), 48 id_(id),
45 requesting_frame_(requesting_frame), 49 requesting_frame_(requesting_frame),
46 contents_unique_id_(contents_unique_id), 50 contents_unique_id_(contents_unique_id),
47 display_languages_(display_languages) { 51 display_languages_(display_languages) {}
48 }
49 52
50 MidiPermissionInfoBarDelegate::~MidiPermissionInfoBarDelegate() { 53 MidiPermissionInfoBarDelegate::~MidiPermissionInfoBarDelegate() {
51 } 54 }
52 55
53 void MidiPermissionInfoBarDelegate::InfoBarDismissed() { 56 void MidiPermissionInfoBarDelegate::InfoBarDismissed() {
54 SetPermission(false, false); 57 SetPermission(false, false);
55 } 58 }
56 59
57 int MidiPermissionInfoBarDelegate::GetIconID() const { 60 int MidiPermissionInfoBarDelegate::GetIconID() const {
58 return IDR_INFOBAR_MIDI_SYSEX; 61 return IDR_INFOBAR_MIDI_SYSEX;
59 } 62 }
60 63
61 InfoBarDelegate::Type MidiPermissionInfoBarDelegate::GetInfoBarType() const { 64 InfoBarDelegate::Type MidiPermissionInfoBarDelegate::GetInfoBarType() const {
62 return PAGE_ACTION_TYPE; 65 return PAGE_ACTION_TYPE;
63 } 66 }
64 67
65 bool MidiPermissionInfoBarDelegate::ShouldExpireInternal( 68 bool MidiPermissionInfoBarDelegate::ShouldExpireInternal(
66 const content::LoadCommittedDetails& details) const { 69 const NavigationDetails& details) const {
67 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but 70 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but
68 // uses the unique ID we set in the constructor instead of that stored in the 71 // uses the unique ID we set in the constructor instead of that stored in the
69 // base class. 72 // base class.
70 return (contents_unique_id_ != details.entry->GetUniqueID()) || 73 return (contents_unique_id_ != details.entry_id) || details.is_reload;
71 (content::PageTransitionStripQualifier(
72 details.entry->GetTransitionType()) ==
73 content::PAGE_TRANSITION_RELOAD);
74 } 74 }
75 75
76 base::string16 MidiPermissionInfoBarDelegate::GetMessageText() const { 76 base::string16 MidiPermissionInfoBarDelegate::GetMessageText() const {
77 return l10n_util::GetStringFUTF16( 77 return l10n_util::GetStringFUTF16(
78 IDS_MIDI_SYSEX_INFOBAR_QUESTION, 78 IDS_MIDI_SYSEX_INFOBAR_QUESTION,
79 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_)); 79 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_));
80 } 80 }
81 81
82 base::string16 MidiPermissionInfoBarDelegate::GetButtonLabel( 82 base::string16 MidiPermissionInfoBarDelegate::GetButtonLabel(
83 InfoBarButton button) const { 83 InfoBarButton button) const {
84 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 84 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
85 IDS_MIDI_SYSEX_ALLOW_BUTTON : IDS_MIDI_SYSEX_DENY_BUTTON); 85 IDS_MIDI_SYSEX_ALLOW_BUTTON : IDS_MIDI_SYSEX_DENY_BUTTON);
86 } 86 }
87 87
88 bool MidiPermissionInfoBarDelegate::Accept() { 88 bool MidiPermissionInfoBarDelegate::Accept() {
89 SetPermission(true, true); 89 SetPermission(true, true);
90 return true; 90 return true;
91 } 91 }
92 92
93 bool MidiPermissionInfoBarDelegate::Cancel() { 93 bool MidiPermissionInfoBarDelegate::Cancel() {
94 SetPermission(true, false); 94 SetPermission(true, false);
95 return true; 95 return true;
96 } 96 }
97 97
98 void MidiPermissionInfoBarDelegate::SetPermission(bool update_content_setting, 98 void MidiPermissionInfoBarDelegate::SetPermission(bool update_content_setting,
99 bool allowed) { 99 bool allowed) {
100 controller_->OnPermissionSet(id_, requesting_frame_, web_contents()->GetURL(), 100 controller_->OnPermissionSet(id_, requesting_frame_, web_contents()->GetURL(),
101 update_content_setting, allowed); 101 update_content_setting, allowed);
102 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698