| 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 #import "chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h" | 5 #import "chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #import "base/sys_string_conversions.h" | 10 #import "base/sys_string_conversions.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 [super dealloc]; | 93 [super dealloc]; |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Called when "Allow" button is pressed. | 96 // Called when "Allow" button is pressed. |
| 97 - (void)ok:(id)sender { | 97 - (void)ok:(id)sender { |
| 98 std::string audioId, videoId; | 98 std::string audioId, videoId; |
| 99 deviceMenuModel_->GetSelectedDeviceId( | 99 deviceMenuModel_->GetSelectedDeviceId( |
| 100 content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, &audioId); | 100 content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, &audioId); |
| 101 deviceMenuModel_->GetSelectedDeviceId( | 101 deviceMenuModel_->GetSelectedDeviceId( |
| 102 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, &videoId); | 102 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, &videoId); |
| 103 bool alwaysAllow = deviceMenuModel_->always_allow(); |
| 103 | 104 |
| 104 static_cast<MediaStreamInfoBarDelegate*>([self delegate])->Accept(audioId, | 105 static_cast<MediaStreamInfoBarDelegate*>([self delegate])->Accept( |
| 105 videoId); | 106 audioId, videoId, alwaysAllow); |
| 106 | 107 |
| 107 // Remove the infobar, we're done. | 108 // Remove the infobar, we're done. |
| 108 [super removeSelf]; | 109 [super removeSelf]; |
| 109 } | 110 } |
| 110 | 111 |
| 111 // Called when "Deny" button is pressed. | 112 // Called when "Deny" button is pressed. |
| 112 - (void)cancel:(id)sender { | 113 - (void)cancel:(id)sender { |
| 113 static_cast<MediaStreamInfoBarDelegate*>([self delegate])->Deny(); | 114 static_cast<MediaStreamInfoBarDelegate*>([self delegate])->Deny(); |
| 114 | 115 |
| 115 // Remove the infobar, we're done. | 116 // Remove the infobar, we're done. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 [self disablePopUpMenu:[deviceMenu_ menu]]; | 159 [self disablePopUpMenu:[deviceMenu_ menu]]; |
| 159 [super infobarWillClose]; | 160 [super infobarWillClose]; |
| 160 } | 161 } |
| 161 | 162 |
| 162 - (void)setLabelTexts { | 163 - (void)setLabelTexts { |
| 163 MediaStreamInfoBarDelegate* delegate = | 164 MediaStreamInfoBarDelegate* delegate = |
| 164 static_cast<MediaStreamInfoBarDelegate*>([self delegate]); | 165 static_cast<MediaStreamInfoBarDelegate*>([self delegate]); |
| 165 | 166 |
| 166 // Get the requested media type(s) and add corresponding text to the text | 167 // Get the requested media type(s) and add corresponding text to the text |
| 167 // field. | 168 // field. |
| 168 int messageId = IDS_MEDIA_CAPTURE_MIC_AND_VIDEO; | 169 int messageId = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
| 169 DCHECK(delegate->has_audio() || delegate->has_video()); | 170 DCHECK(delegate->HasAudio() || delegate->HasVideo()); |
| 170 if (!delegate->has_audio()) | 171 if (!delegate->HasAudio()) |
| 171 messageId = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 172 messageId = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
| 172 else if (!delegate->has_video()) | 173 else if (!delegate->HasVideo()) |
| 173 messageId = IDS_MEDIA_CAPTURE_MIC_ONLY; | 174 messageId = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
| 174 | 175 |
| 175 string16 securityOrigin = UTF8ToUTF16(delegate->GetSecurityOrigin().spec()); | 176 string16 securityOrigin = UTF8ToUTF16(delegate->GetSecurityOrigin().spec()); |
| 176 NSString* text = l10n_util::GetNSStringF(messageId, securityOrigin); | 177 NSString* text = l10n_util::GetNSStringF(messageId, securityOrigin); |
| 177 [label1_ setStringValue:text]; | 178 [label1_ setStringValue:text]; |
| 178 | 179 |
| 179 // Add text to the buttons. | 180 // Add text to the buttons. |
| 180 [okButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_ALLOW)]; | 181 [okButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_ALLOW)]; |
| 181 [cancelButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_DENY)]; | 182 [cancelButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_DENY)]; |
| 182 | 183 |
| 183 // Populating |deviceMenu_| is handled separately. | 184 // Populating |deviceMenu_| is handled separately. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 233 } |
| 233 } | 234 } |
| 234 [GTMUILocalizerAndLayoutTweaker sizeToFitView:deviceMenu_]; | 235 [GTMUILocalizerAndLayoutTweaker sizeToFitView:deviceMenu_]; |
| 235 } | 236 } |
| 236 | 237 |
| 237 - (void)didChangeFrame:(NSNotification*)notification { | 238 - (void)didChangeFrame:(NSNotification*)notification { |
| 238 [self arrangeInfobarLayout]; | 239 [self arrangeInfobarLayout]; |
| 239 } | 240 } |
| 240 | 241 |
| 241 @end // implementation MediaStreamInfoBarController | 242 @end // implementation MediaStreamInfoBarController |
| OLD | NEW |