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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 gfx::Size devices_size = devices_menu_button_->GetPreferredSize(); | 56 gfx::Size devices_size = devices_menu_button_->GetPreferredSize(); |
57 devices_menu_button_->SetBounds(EndX() - devices_size.width(), | 57 devices_menu_button_->SetBounds(EndX() - devices_size.width(), |
58 OffsetY(devices_size), devices_size.width(), devices_size.height()); | 58 OffsetY(devices_size), devices_size.width(), devices_size.height()); |
59 } | 59 } |
60 | 60 |
61 void MediaStreamInfoBar::ViewHierarchyChanged(bool is_add, | 61 void MediaStreamInfoBar::ViewHierarchyChanged(bool is_add, |
62 views::View* parent, | 62 views::View* parent, |
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_MIC_AND_VIDEO; | 65 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
66 DCHECK(GetDelegate()->has_audio() || GetDelegate()->has_video()); | 66 DCHECK(GetDelegate()->HasAudio() || GetDelegate()->HasVideo()); |
67 if (!GetDelegate()->has_audio()) | 67 if (!GetDelegate()->HasAudio()) |
68 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 68 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
69 else if (!GetDelegate()->has_video()) | 69 else if (!GetDelegate()->HasVideo()) |
70 message_id = IDS_MEDIA_CAPTURE_MIC_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()->GetSecurityOrigin().spec()))); |
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, |
(...skipping 13 matching lines...) Expand all Loading... |
94 void MediaStreamInfoBar::ButtonPressed(views::Button* sender, | 94 void MediaStreamInfoBar::ButtonPressed(views::Button* sender, |
95 const views::Event& event) { | 95 const views::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_.GetSelectedDeviceId( |
101 content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, &audio_id); | 101 content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, &audio_id); |
102 devices_menu_model_.GetSelectedDeviceId( | 102 devices_menu_model_.GetSelectedDeviceId( |
103 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, &video_id); | 103 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, &video_id); |
104 GetDelegate()->Accept(audio_id, video_id); | 104 bool always_allow = devices_menu_model_.always_allow(); |
| 105 GetDelegate()->Accept(audio_id, video_id, always_allow); |
105 RemoveSelf(); | 106 RemoveSelf(); |
106 } else if (sender == deny_button_) { | 107 } else if (sender == deny_button_) { |
107 GetDelegate()->Deny(); | 108 GetDelegate()->Deny(); |
108 RemoveSelf(); | 109 RemoveSelf(); |
109 } else { | 110 } else { |
110 InfoBarView::ButtonPressed(sender, event); | 111 InfoBarView::ButtonPressed(sender, event); |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
114 int MediaStreamInfoBar::ContentMinimumWidth() const { | 115 int MediaStreamInfoBar::ContentMinimumWidth() const { |
115 return | 116 return |
116 kEndOfLabelSpacing + | 117 kEndOfLabelSpacing + |
117 (allow_button_->GetPreferredSize().width() + kButtonButtonSpacing + | 118 (allow_button_->GetPreferredSize().width() + kButtonButtonSpacing + |
118 deny_button_->GetPreferredSize().width()) + | 119 deny_button_->GetPreferredSize().width()) + |
119 (kButtonButtonSpacing + devices_menu_button_->GetPreferredSize().width()); | 120 (kButtonButtonSpacing + devices_menu_button_->GetPreferredSize().width()); |
120 } | 121 } |
121 | 122 |
122 void MediaStreamInfoBar::OnMenuButtonClicked(views::View* source, | 123 void MediaStreamInfoBar::OnMenuButtonClicked(views::View* source, |
123 const gfx::Point& point) { | 124 const gfx::Point& point) { |
124 if (!owned()) | 125 if (!owned()) |
125 return; // We're closing; don't call anything, it might access the owner. | 126 return; // We're closing; don't call anything, it might access the owner. |
126 DCHECK_EQ(devices_menu_button_, source); | 127 DCHECK_EQ(devices_menu_button_, source); |
127 RunMenuAt(&devices_menu_model_, devices_menu_button_, | 128 RunMenuAt(&devices_menu_model_, devices_menu_button_, |
128 views::MenuItemView::TOPRIGHT); | 129 views::MenuItemView::TOPRIGHT); |
129 } | 130 } |
130 | 131 |
131 MediaStreamInfoBarDelegate* MediaStreamInfoBar::GetDelegate() { | 132 MediaStreamInfoBarDelegate* MediaStreamInfoBar::GetDelegate() { |
132 return delegate()->AsMediaStreamInfoBarDelegate(); | 133 return delegate()->AsMediaStreamInfoBarDelegate(); |
133 } | 134 } |
OLD | NEW |