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 "chrome/browser/ui/gtk/infobars/media_stream_infobar_gtk.h" | 5 #include "chrome/browser/ui/gtk/infobars/media_stream_infobar_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 size_t offset = 0; | 38 size_t offset = 0; |
39 | 39 |
40 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 40 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
41 DCHECK(GetDelegate()->HasAudio() || GetDelegate()->HasVideo()); | 41 DCHECK(GetDelegate()->HasAudio() || GetDelegate()->HasVideo()); |
42 if (!GetDelegate()->HasAudio()) | 42 if (!GetDelegate()->HasAudio()) |
43 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 43 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
44 else if (!GetDelegate()->HasVideo()) | 44 else if (!GetDelegate()->HasVideo()) |
45 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 45 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
46 | 46 |
47 string16 security_origin = UTF8ToUTF16( | 47 string16 security_origin = UTF8ToUTF16( |
48 GetDelegate()->GetSecurityOrigin().spec()); | 48 GetDelegate()->GetSecurityOriginSpec()); |
49 string16 text(l10n_util::GetStringFUTF16(message_id, | 49 string16 text(l10n_util::GetStringFUTF16(message_id, |
50 security_origin, &offset)); | 50 security_origin, &offset)); |
51 | 51 |
52 gtk_box_pack_start(GTK_BOX(hbox), CreateLabel(UTF16ToUTF8(text)), | 52 gtk_box_pack_start(GTK_BOX(hbox), CreateLabel(UTF16ToUTF8(text)), |
53 FALSE, FALSE, 0); | 53 FALSE, FALSE, 0); |
54 | 54 |
55 GtkWidget* button = gtk_button_new_with_label( | 55 GtkWidget* button = gtk_button_new_with_label( |
56 l10n_util::GetStringUTF8(IDS_MEDIA_CAPTURE_ALLOW).c_str()); | 56 l10n_util::GetStringUTF8(IDS_MEDIA_CAPTURE_ALLOW).c_str()); |
57 Signals()->Connect(button, "clicked", | 57 Signals()->Connect(button, "clicked", |
58 G_CALLBACK(&OnAllowButtonThunk), this); | 58 G_CALLBACK(&OnAllowButtonThunk), this); |
(...skipping 13 matching lines...) Expand all Loading... |
72 gtk_widget_show_all(devices_menu_button); | 72 gtk_widget_show_all(devices_menu_button); |
73 gtk_util::CenterWidgetInHBox(hbox_, devices_menu_button, true, 0); | 73 gtk_util::CenterWidgetInHBox(hbox_, devices_menu_button, true, 0); |
74 } | 74 } |
75 | 75 |
76 void MediaStreamInfoBarGtk::OnDevicesClicked(GtkWidget* sender) { | 76 void MediaStreamInfoBarGtk::OnDevicesClicked(GtkWidget* sender) { |
77 ShowMenuWithModel(sender, NULL, devices_menu_model_.get()); | 77 ShowMenuWithModel(sender, NULL, devices_menu_model_.get()); |
78 } | 78 } |
79 | 79 |
80 void MediaStreamInfoBarGtk::OnAllowButton(GtkWidget* widget) { | 80 void MediaStreamInfoBarGtk::OnAllowButton(GtkWidget* widget) { |
81 std::string audio_id, video_id; | 81 std::string audio_id, video_id; |
82 devices_menu_model_->GetSelectedDeviceId( | 82 devices_menu_model_->GetSelectedAudioDeviceId(&audio_id); |
83 content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, &audio_id); | 83 devices_menu_model_->GetSelectedVideoDeviceId(&video_id); |
84 devices_menu_model_->GetSelectedDeviceId( | |
85 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, &video_id); | |
86 bool always_allow = devices_menu_model_->always_allow(); | 84 bool always_allow = devices_menu_model_->always_allow(); |
87 GetDelegate()->Accept(audio_id, video_id, always_allow); | 85 GetDelegate()->Accept(audio_id, video_id, always_allow); |
88 RemoveSelf(); | 86 RemoveSelf(); |
89 } | 87 } |
90 | 88 |
91 void MediaStreamInfoBarGtk::OnDenyButton(GtkWidget* widget) { | 89 void MediaStreamInfoBarGtk::OnDenyButton(GtkWidget* widget) { |
92 GetDelegate()->Deny(); | 90 GetDelegate()->Deny(); |
93 RemoveSelf(); | 91 RemoveSelf(); |
94 } | 92 } |
95 | 93 |
96 MediaStreamInfoBarDelegate* MediaStreamInfoBarGtk::GetDelegate() { | 94 MediaStreamInfoBarDelegate* MediaStreamInfoBarGtk::GetDelegate() { |
97 return delegate()->AsMediaStreamInfoBarDelegate(); | 95 return delegate()->AsMediaStreamInfoBarDelegate(); |
98 } | 96 } |
OLD | NEW |