OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
10 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 10 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 views::View* child) { | 63 views::View* child) { |
64 if (is_add && child == this && (label_ == NULL)) { | 64 if (is_add && child == this && (label_ == NULL)) { |
65 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 65 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
66 DCHECK(GetDelegate()->HasAudio() || GetDelegate()->HasVideo()); | 66 DCHECK(GetDelegate()->HasAudio() || GetDelegate()->HasVideo()); |
67 if (!GetDelegate()->HasAudio()) | 67 if (!GetDelegate()->HasAudio()) |
68 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 68 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
69 else if (!GetDelegate()->HasVideo()) | 69 else if (!GetDelegate()->HasVideo()) |
70 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 70 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
71 | 71 |
72 label_ = CreateLabel(l10n_util::GetStringFUTF16(message_id, | 72 label_ = CreateLabel(l10n_util::GetStringFUTF16(message_id, |
73 UTF8ToUTF16(GetDelegate()->GetSecurityOrigin().spec()))); | 73 UTF8ToUTF16(GetDelegate()->GetSecurityOriginSpec()))); |
74 AddChildView(label_); | 74 AddChildView(label_); |
75 | 75 |
76 allow_button_ = CreateTextButton(this, | 76 allow_button_ = CreateTextButton(this, |
77 l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_ALLOW), false); | 77 l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_ALLOW), false); |
78 AddChildView(allow_button_); | 78 AddChildView(allow_button_); |
79 | 79 |
80 deny_button_ = CreateTextButton(this, | 80 deny_button_ = CreateTextButton(this, |
81 l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_DENY), false); | 81 l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_DENY), false); |
82 AddChildView(deny_button_); | 82 AddChildView(deny_button_); |
83 | 83 |
84 devices_menu_button_ = CreateMenuButton( | 84 devices_menu_button_ = CreateMenuButton( |
85 l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_DEVICES_MENU_TITLE), this); | 85 l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_DEVICES_MENU_TITLE), this); |
86 AddChildView(devices_menu_button_); | 86 AddChildView(devices_menu_button_); |
87 } | 87 } |
88 | 88 |
89 // This must happen after adding all other children so InfoBarView can ensure | 89 // This must happen after adding all other children so InfoBarView can ensure |
90 // the close button is the last child. | 90 // the close button is the last child. |
91 InfoBarView::ViewHierarchyChanged(is_add, parent, child); | 91 InfoBarView::ViewHierarchyChanged(is_add, parent, child); |
92 } | 92 } |
93 | 93 |
94 void MediaStreamInfoBar::ButtonPressed(views::Button* sender, | 94 void MediaStreamInfoBar::ButtonPressed(views::Button* sender, |
95 const ui::Event& event) { | 95 const ui::Event& event) { |
96 if (!owned()) | 96 if (!owned()) |
97 return; // We're closing; don't call anything, it might access the owner. | 97 return; // We're closing; don't call anything, it might access the owner. |
98 if (sender == allow_button_) { | 98 if (sender == allow_button_) { |
99 std::string audio_id, video_id; | 99 std::string audio_id, video_id; |
100 devices_menu_model_.GetSelectedDeviceId( | 100 devices_menu_model_.GetSelectedAudioDeviceId(&audio_id); |
101 content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, &audio_id); | 101 devices_menu_model_.GetSelectedAudioDeviceId(&video_id); |
102 devices_menu_model_.GetSelectedDeviceId( | |
103 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, &video_id); | |
104 bool always_allow = devices_menu_model_.always_allow(); | 102 bool always_allow = devices_menu_model_.always_allow(); |
105 GetDelegate()->Accept(audio_id, video_id, always_allow); | 103 GetDelegate()->Accept(audio_id, video_id, always_allow); |
106 RemoveSelf(); | 104 RemoveSelf(); |
107 } else if (sender == deny_button_) { | 105 } else if (sender == deny_button_) { |
108 GetDelegate()->Deny(); | 106 GetDelegate()->Deny(); |
109 RemoveSelf(); | 107 RemoveSelf(); |
110 } else { | 108 } else { |
111 InfoBarView::ButtonPressed(sender, event); | 109 InfoBarView::ButtonPressed(sender, event); |
112 } | 110 } |
113 } | 111 } |
(...skipping 11 matching lines...) Expand all Loading... |
125 if (!owned()) | 123 if (!owned()) |
126 return; // We're closing; don't call anything, it might access the owner. | 124 return; // We're closing; don't call anything, it might access the owner. |
127 DCHECK_EQ(devices_menu_button_, source); | 125 DCHECK_EQ(devices_menu_button_, source); |
128 RunMenuAt(&devices_menu_model_, devices_menu_button_, | 126 RunMenuAt(&devices_menu_model_, devices_menu_button_, |
129 views::MenuItemView::TOPRIGHT); | 127 views::MenuItemView::TOPRIGHT); |
130 } | 128 } |
131 | 129 |
132 MediaStreamInfoBarDelegate* MediaStreamInfoBar::GetDelegate() { | 130 MediaStreamInfoBarDelegate* MediaStreamInfoBar::GetDelegate() { |
133 return delegate()->AsMediaStreamInfoBarDelegate(); | 131 return delegate()->AsMediaStreamInfoBarDelegate(); |
134 } | 132 } |
OLD | NEW |